Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建主力合约管理类。
        /// </summary>
        private void CreateMainContractManager()
        {
            string dbConnStr = ConfigurationManager.ConnectionStrings["KLineDB"].ConnectionString;

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

            if (string.IsNullOrEmpty(alphaDBName))
            {
                throw new ArgumentException("Not found alphaDBName config");
            }
            try
            {
                MainContractManager manager = new MainContractManager(dbConnStr, alphaDBName);
                manager.Initialize();
                m_mainContractManager = manager;

                string text = String.Format("{0} Create {1} OK.", this, manager);
                m_eventLogger.WriteInformation(text);

                Debug.Assert(manager != null);
                Dictionary <string, USeInstrument> mainContractDic = manager.MainContractDictionary;
                foreach (KeyValuePair <string, USeInstrument> kv in mainContractDic)
                {
                    m_eventLogger.WriteInformation(kv.Key + "--" + kv.Value.InstrumentCode);
                }
            }
            catch (Exception ex)
            {
                string text = "Create MainContractManager object failed, " + ex.Message;
                throw new ApplicationException(text, ex);
            }
        }