Exemplo n.º 1
0
        private void Initialize()
        {
            _metaDataStore.Initialize();
            _uaSource.Connect(Settings.UaServerUrl, USER_NAME, PASSWORD);
            _eventHub.Open();

            new Thread(KeepSettingsUpToDate).Start();

            if (Settings.PublishToEventHub)
            {
                new Thread(Publisher).Start();
            }
        }
Exemplo n.º 2
0
        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;
        }