示例#1
0
        public StrategyI(StrategySettings settings, NeuralStockSettings appSettings)
        {
            Settings = settings ?? new StrategySettings();

            lock (Locker)
            {
                StatisticsService    = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IStatisticsService>();
                DataProcessorService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IDataProcessorService>();
                DownloaderService    = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IDownloaderService>();
            }
        }
示例#2
0
        public Task <bool> SaveSettings(NeuralStockSettings settings)
        {
            return(Task.Run(
                       () =>
            {
                try
                {
                    var settingsDTO = settings.GetDTO();

                    var settingsTable = _db.GetCollection <NeuralStockSettingsDTO>(DbCollectionStringSettings);
                    settingsTable.Upsert(settingsDTO);

                    return true;
                }
                catch (Exception ex)
                {
                    _loggingService.Warn($"{nameof(SaveSettings)}: {ex}");
                    return false;
                }
            }));
        }
示例#3
0
        public Task <NeuralStockSettings> GetSettings()
        {
            return(Task.Run(
                       () =>
            {
                if (_db.CollectionExists(DbCollectionStringSettings))
                {
                    try
                    {
                        var settingsDto = _db.GetCollection <NeuralStockSettingsDTO>(DbCollectionStringSettings).FindAll();

                        return NeuralStockSettings.FromDTO(settingsDto.FirstOrDefault());
                    }
                    catch (Exception ex)
                    {
                        _loggingService.Warn($"{nameof(GetSettings)}: {ex}");
                    }
                }

                return null;
            }));
        }
示例#4
0
 private async Task LoadSettings()
 {
     this._settings = await this.PersistenceService.GetSettings().ConfigureAwait(false) ?? new NeuralStockSettings();
 }
示例#5
0
 private async void LoadSettings()
 {
     this.Settings = await this.PersistenceService.GetSettings() ?? NeuralStockSettings.GetDefault();
 }