public static IIndicator Create(string entity, IStockService stockService, IFuturesService futuresService) { if (entity == nameof(BlueChips)) { return(new BlueChips(stockService)); } else if (entity == nameof(Prices)) { return(new Prices(futuresService)); } else if (entity == nameof(Powers)) { return(new Powers(futuresService)); } throw new Exception(String.Format("Can Not Create Indicator Entity Name = {0}", entity)); }
public Powers(IFuturesService futuresService) { this.futuresService = futuresService; }
public Prices(IFuturesService futuresService) { this.futuresService = futuresService; }
async Task Init() { try { await _apiService.Login(); } catch (Exception ex) { _logger.LogException(new Exception("apiService.Login Failed")); _logger.LogException(ex); initSuccess = false; return; } try { var holidays = await _apiService.GetHolidays(); this._dateManager = Factories.CreateDateManager(holidays); if (!IsDevelopment) { if (!IsBusinessDay) { this.Close(); return; } } var stocks = await _apiService.GetStocks(); stocks = stocks.Where(s => !s.ignore).ToList(); string tickFileFolder = _settingsManager.GetSettingValue(AppSettingsKey.TickFile); var tickDBService = ServiceFactory.CreateTickDBService(stocks.Select(s => s.code), tickFileFolder); string baseStock = _settingsManager.GetSettingValue(AppSettingsKey.BaseStock); _stockService = ServiceFactory.CreateStockService(stocks, baseStock, tickDBService); _futuresService = ServiceFactory.CreateFuturesService(tickDBService); var indicatorDataList = await _apiService.GetIndicators(); foreach (var item in indicatorDataList) { this._indicators.Add(IndicatorFactory.Create(item.entity, _stockService, _futuresService)); } _source.SymbolCodes = _stockService.GetStockCodes(); _source.Connect(); } catch (Exception ex) { _logger.LogException(ex); initSuccess = false; return; } initSuccess = true; }