示例#1
0
        public Main()
        {
            _settingsManager = Factories.CreateSettingsManager();
            this.seconds     = _settingsManager.GetSettingValue(AppSettingsKey.Seconds).ToInt();


            this._timeManager = Factories.CreateTimeManager(_settingsManager.GetSettingValue(AppSettingsKey.Open),
                                                            _settingsManager.GetSettingValue(AppSettingsKey.Close));

            _logger = LoggerFactory.Create(_settingsManager.LogFilePath);


            string siteUrl       = _settingsManager.GetSettingValue(AppSettingsKey.SiteUrl);
            string adminUser     = _settingsManager.GetSettingValue(AppSettingsKey.Admin);
            string adminPassword = _settingsManager.GetSettingValue(AppSettingsKey.AdminPassword);
            string dbKey         = _settingsManager.GetSettingValue(AppSettingsKey.DBKey);

            this._apiService = ServiceFactory.CreateApiService(siteUrl, adminUser, adminPassword, dbKey);

            string hubUrl   = _settingsManager.GetSettingValue(AppSettingsKey.HubUrl);
            string quoteKey = _settingsManager.GetSettingValue(AppSettingsKey.QuoteKey);

            _hubManager = Factories.CreateHubManager(hubUrl, quoteKey);


            // init source
            string provider = _settingsManager.GetSettingValue(AppSettingsKey.Provider);
            string sid      = _settingsManager.GetSettingValue(AppSettingsKey.SID);
            string password = _settingsManager.GetSettingValue(AppSettingsKey.Password);

            this._source = SourceFactory.Create(provider, sid, password);
            this._source.ExceptionOccured  += Source_ExceptionOccured;
            this._source.ActionExecuted    += Source_ActionExecuted;
            this._source.NotifyStockTick   += Source_NotifyStockTick;
            this._source.NotifyFuturesTick += Source_NotifyFuturesTick;

            Thread.Sleep(1500);


            InitializeComponent();
        }
示例#2
0
        public API_TestForm()
        {
            _settingsManager = Factories.CreateSettingsManager();
            _logger          = LoggerFactory.Create(_settingsManager.LogFilePath);


            string name = _settingsManager.GetSettingValue(AppSettingsKey.OrderMaker);
            string ip   = _settingsManager.GetSettingValue(AppSettingsKey.OrderMakerIP);
            string sid  = _settingsManager.GetSettingValue(AppSettingsKey.SID);
            string pw   = CryptoGraphy.DecryptCipherTextToPlainText(_settingsManager.GetSettingValue(AppSettingsKey.Password));

            _orderMaker                 = ProviderFactory.Create(name, ip, sid, pw);
            _orderMaker.Ready          += this.OnOrderMakerReady;
            _orderMaker.ActionExecuted += this.OnActionExcuted;
            if (_orderMaker.Name == ProviderName.HUA_NAN)
            {
                _orderMaker.AccountPositionUpdated += OrderMaker_AccountPositionUpdated;
            }

            InitializeComponent();
        }
示例#3
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;
        }