Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(
            SettingsViewModel settingsViewModel,
            MarketsViewModel marketsViewModel,
            AccountsViewModel accountsViewModel,
            StrategiesViewModel strategiesViewModel,
            ResearchViewModel researchViewModel,
            LogViewModel logViewModel)
        {
            SettingsViewModel   = settingsViewModel;
            MarketsViewModel    = marketsViewModel;
            AccountsViewModel   = accountsViewModel;
            StrategiesViewModel = strategiesViewModel;
            ResearchViewModel   = researchViewModel;
            LogViewModel        = logViewModel;

            SaveCommand     = new RelayCommand(() => SaveConfig(), () => !IsBusy);
            SettingsCommand = new RelayCommand(async() => await DoSettings(), () => !IsBusy);
            ExitCommand     = new RelayCommand <Window>(window => DoExit(window), window => !IsBusy);
            Messenger.Default.Register <NotificationMessage>(this, OnStatusMessage);

            // Set working directory
            string appData = MainService.GetAppDataFolder();

            Directory.SetCurrentDirectory(appData);

            // Async initialize without blocking UI
            _initializer = Initialize();
        }
Esempio n. 2
0
        public StrategyViewModel(StrategiesViewModel parent, StrategyModel model, MarketService markets, AccountService accounts, SettingService settings)
        {
            _parent   = parent;
            Model     = model ?? throw new ArgumentNullException(nameof(model));
            _markets  = markets;
            _accounts = accounts;
            _settings = settings;

            StartCommand                = new RelayCommand(() => DoRunStrategy(), () => true);
            StopCommand                 = new RelayCommand(() => { }, () => false);
            CloneCommand                = new RelayCommand(() => DoCloneStrategy(), () => true);
            CloneAlgorithmCommand       = new RelayCommand(() => DoCloneAlgorithm(), () => !string.IsNullOrEmpty(Model.AlgorithmName));
            ExportCommand               = new RelayCommand(() => DoExportStrategy(), () => true);
            DeleteCommand               = new RelayCommand(() => _parent?.DoDeleteStrategy(this), () => true);
            DeleteAllTracksCommand      = new RelayCommand(() => DoDeleteTracks(null), () => true);
            DeleteSelectedTracksCommand = new RelayCommand <IList>(m => DoDeleteTracks(m), m => true);
            UseParametersCommand        = new RelayCommand <IList>(m => DoUseParameters(m), m => true);
            AddSymbolCommand            = new RelayCommand(() => DoAddSymbol(), () => true);
            DeleteSymbolsCommand        = new RelayCommand <IList>(m => DoDeleteSymbols(m), m => SelectedSymbol != null);
            ImportSymbolsCommand        = new RelayCommand(() => DoImportSymbols(), () => true);
            ExportSymbolsCommand        = new RelayCommand <IList>(m => DoExportSymbols(m), trm => SelectedSymbol != null);
            TrackDoubleClickCommand     = new RelayCommand <TrackViewModel>(m => DoSelectItem(m));
            MoveUpSymbolsCommand        = new RelayCommand <IList>(m => OnMoveUpSymbols(m), m => SelectedSymbol != null);
            MoveDownSymbolsCommand      = new RelayCommand <IList>(m => OnMoveDownSymbols(m), m => SelectedSymbol != null);
            SortSymbolsCommand          = new RelayCommand(() => Symbols.Sort(), () => true);

            Model.NameChanged          += StrategyNameChanged;
            Model.MarketChanged        += MarketChanged;
            Model.AlgorithmNameChanged += AlgorithmNameChanged;
            DataFromModel();

            Model.EndDate = DateTime.Now;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(
            SettingsViewModel settingsViewModel,
            MarketsViewModel marketsViewModel,
            AccountsViewModel accountsViewModel,
            StrategiesViewModel strategiesViewModel,
            ResearchViewModel researchViewModel,
            LogViewModel logViewModel)
        {
            SettingsViewModel   = settingsViewModel;
            MarketsViewModel    = marketsViewModel;
            AccountsViewModel   = accountsViewModel;
            StrategiesViewModel = strategiesViewModel;
            ResearchViewModel   = researchViewModel;
            LogViewModel        = logViewModel;

            SaveCommand     = new RelayCommand(() => SaveAll(), () => !IsBusy);
            SettingsCommand = new RelayCommand(() => DoSettings(), () => !IsBusy);
            ExitCommand     = new RelayCommand <Window>(window => DoExit(window), window => !IsBusy);
            Messenger.Default.Register <NotificationMessage>(this, OnStatusMessage);

            Config.Set("map-file-provider", "QuantConnect.Data.Auxiliary.LocalDiskMapFileProvider");
            ProviderFactory.RegisterProviders();

            // Initialize data folders
            MainService.InitializeFolders();

            // Set working directory
            string appData = MainService.GetAppDataFolder();

            Directory.SetCurrentDirectory(appData);

            // Read configuration
            _ = ReadConfigAsync(appData);
        }