Exemplo n.º 1
0
        /// <summary>
        /// 创建Alpha数据库访问器。
        /// </summary>
        private void CreateAlphaDBVistor()
        {
            string dbConnStr = ConfigurationManager.ConnectionStrings["KLineDB"].ConnectionString;

            if (string.IsNullOrEmpty(dbConnStr))
            {
                throw new ArgumentException("Not found KLineDB ConnectionString");
            }
            string alpahDBName = ConfigurationManager.AppSettings["AlphaDBName"];

            if (string.IsNullOrEmpty(alpahDBName))
            {
                throw new ArgumentException("Not foun AlphaDBName config");
            }

            try
            {
                AlphaDBVistor alphaDBVistor = new AlphaDBVistor(dbConnStr, alpahDBName);

                m_alphaDBVisotr = alphaDBVistor;
                string text = String.Format("{0} Create {1} OK.", this, alphaDBVistor);
                m_eventLogger.WriteInformation(text);
            }
            catch (Exception ex)
            {
                string text = "Create AlphaDBVistor object failed, " + ex.Message;
                throw new ApplicationException(text, ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 启动。
        /// </summary>
        /// <param name="marketDataProvider"></param>
        /// <param name="dbStore"></param>
        public void Start(List <IKLineDataListener> storers, ITradeRangeManager tradeRangeManager,
                          MainContractManager mainContractManager, USeProductManager productManager, AlphaDBVistor alphaDBVistor,
                          USeTradingInstrumentManager instrumentManager,
                          IAppLogger eventLogger)
        {
            m_runFlag = true;

            if (storers == null)
            {
                throw new ArgumentNullException("storers");
            }
            if (tradeRangeManager == null)
            {
                throw new ArgumentNullException("tradeRangeManager");
            }
            if (mainContractManager == null)
            {
                throw new ArgumentNullException("mainContractManager");
            }
            if (productManager == null)
            {
                throw new ArgumentNullException("productManager");
            }
            if (alphaDBVistor == null)
            {
                throw new ArgumentNullException("kLineVistor");
            }
            if (instrumentManager == null)
            {
                throw new ArgumentNullException("instrumentManager");
            }
            if (eventLogger == null)
            {
                throw new ArgumentNullException("eventLogger");
            }

            m_storers             = storers;
            m_tradeRangeManager   = tradeRangeManager;
            m_productManager      = productManager;
            m_mainContractManager = mainContractManager;
            m_alphaDBVistor       = alphaDBVistor;
            m_instrumentManager   = instrumentManager;
            m_eventLogger         = eventLogger;

            KLinePublisher kLinePublisher = new KLinePublisher();

            kLinePublisher.SetMarketDataStore(storers);
            m_kLinePublisher = kLinePublisher;

            this.m_workThread = new Thread(new ThreadStart(DoWork));
            this.m_workThread.Start();
        }