Esempio n. 1
0
        public MarketViewModel(MarketsViewModel marketsViewModel, MarketModel marketModel, SettingService settings)
        {
            if (marketsViewModel == null)
            {
                throw new ArgumentNullException(nameof(marketsViewModel));
            }

            _parent   = marketsViewModel;
            Model     = marketModel;
            _settings = settings;

            CheckAllCommand           = new RelayCommand <IList>(m => DoCheckAll(m), m => !_parent.IsBusy && !Active && SelectedSymbol != null);
            AddSymbolCommand          = new RelayCommand(() => DoAddSymbol(), () => !_parent.IsBusy);
            DownloadSymbolListCommand = new RelayCommand(() => DoDownloadSymbolList(), !_parent.IsBusy);
            DeleteSymbolsCommand      = new RelayCommand <IList>(m => DoDeleteSymbols(m), m => !_parent.IsBusy && !Active && SelectedSymbol != null);
            ImportSymbolsCommand      = new RelayCommand(() => DoImportSymbols(), !_parent.IsBusy);
            ExportSymbolsCommand      = new RelayCommand <IList>(m => DoExportSymbols(m), m => !_parent.IsBusy && !Active && SelectedSymbol != null);
            AddToSymbolListCommand    = new RelayCommand <IList>(m => DoAddToSymbolList(m), m => !_parent.IsBusy && !Active && SelectedSymbol != null);
            DeleteCommand             = new RelayCommand(() => _parent?.DoDeleteMarket(this), () => !_parent.IsBusy && !Active);
            NewFolderCommand          = new RelayCommand(() => Folders.Add(new FolderViewModel(this, new FolderModel())), () => !_parent.IsBusy && !Active);
            ImportFolderCommand       = new RelayCommand(() => DoImportFolder(), () => !_parent.IsBusy && !Active);
            ActiveCommand             = new RelayCommand(() => DoActiveCommand(Model.Active), !_parent.IsBusy);
            StartCommand = new RelayCommand(() => DoStartCommand(), () => !_parent.IsBusy && !Active);
            StopCommand  = new RelayCommand(() => DoStopCommand(), () => !_parent.IsBusy && Active);

            Model.ModelChanged += DataFromModel;

            DataFromModel();
            DoActiveCommand(Active);
        }
Esempio n. 2
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. 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);
        }
Esempio n. 4
0
        public MarketViewModel(MarketsViewModel marketsViewModel, MarketModel marketModel, SettingModel settings)
        {
            _parent   = marketsViewModel ?? throw new ArgumentNullException(nameof(marketsViewModel));
            Model     = marketModel;
            _settings = settings;

            CheckAllCommand        = new RelayCommand <IList>(m => DoCheckAll(m), m => !IsBusy && !Active && SelectedSymbol != null);
            AddSymbolCommand       = new RelayCommand(() => DoAddSymbol(), () => !IsBusy);
            DeleteSymbolsCommand   = new RelayCommand <IList>(m => DoDeleteSymbols(m), m => !IsBusy && !Active && SelectedSymbol != null);
            ImportSymbolsCommand   = new RelayCommand(() => DoImportSymbols(), !IsBusy);
            ExportSymbolsCommand   = new RelayCommand <IList>(m => DoExportSymbols(m), m => !IsBusy && !Active && SelectedSymbol != null);
            AddToSymbolListCommand = new RelayCommand <IList>(m => DoAddToSymbolList(m), m => !IsBusy && !Active && SelectedSymbol != null);
            DeleteCommand          = new RelayCommand(() => _parent?.DoDeleteMarket(this), () => !IsBusy && !Active);
            NewListCommand         = new RelayCommand(() => DoNewList(), () => !IsBusy && !Active);
            ImportListCommand      = new RelayCommand(() => DoImportList(), () => !IsBusy && !Active);
            ActiveCommand          = new RelayCommand(() => DoActiveCommand(Model.Active), !IsBusy);
            StartCommand           = new RelayCommand(() => DoStartCommand(), () => !IsBusy && !Active);
            StopCommand            = new RelayCommand(() => DoStopCommand(), () => !IsBusy && Active);

            Model.ModelChanged += DataFromModel;

            DataFromModel();
            DoActiveCommand(Active);
        }