Exemple #1
0
        /// <summary>
        /// 获取K线生成器。
        /// </summary>
        /// <param name="instrument"></param>
        /// <returns></returns>
        private List <KLineFactory> GetIndexKLineFactory(USeInstrument instrument)
        {
            Debug.Assert(instrument.Market != USeMarket.Unknown);
            string varieties = USeTraderProtocol.GetVarieties(instrument.InstrumentCode);


            List <KLineFactory> factoryList = null;

            if (m_indexkLineFactoryDic.TryGetValue(varieties, out factoryList) == false)
            {
                USeProduct product = m_productManager.GetPruduct(varieties);

                factoryList = new List <KLineFactory>();
                DayTradeRange tradeRange      = m_tradeRangeManager.CreateTradeRange(varieties);
                DateTime      tradeDay        = tradeRange.GetTradeDay(DateTime.Now);
                USeInstrument indexInstrument = USeTraderProtocol.GetVarietiesIndexCode(product);
                USeKLine      dayKLine        = GetDayKLine(tradeDay, indexInstrument);

                List <USeInstrument> instrumentList = m_instrumentManager.GetAllInstruments(varieties, product.Market);


                IndexDayKLineFactory dayFactory = new IndexDayKLineFactory(product, instrumentList, dayKLine, m_dayKLinePublishInterval, m_kLinePublisher, tradeRange, m_eventLogger, m_instrumentManager);
                factoryList.Add(dayFactory);
                IndexMinKLineFactory min1Factory = new IndexMinKLineFactory(product, instrumentList, USeCycleType.Min1, m_kLinePublisher, tradeRange, m_eventLogger, m_instrumentManager);
                factoryList.Add(min1Factory);

                m_indexkLineFactoryDic.Add(varieties, factoryList);
            }

            Debug.Assert(factoryList != null && factoryList.Count == 2);
            return(factoryList);
        }
Exemple #2
0
        /// <summary>
        /// 获取K线生成器。
        /// </summary>
        /// <param name="instrument"></param>
        /// <returns></returns>
        private List <KLineFactory> GetKLineFactory(USeInstrument instrument)
        {
            Debug.Assert(instrument.Market != USeMarket.Unknown);
            List <KLineFactory> factoryList = null;

            if (m_kLineFactoryDic.TryGetValue(instrument.InstrumentCode, out factoryList) == false)
            {
                factoryList = new List <KLineFactory>();
                DayTradeRange tradeRange    = m_tradeRangeManager.CreateTradeRange(instrument);
                bool          isMainConract = m_mainContractManager.IsMainContract(instrument.InstrumentCode);
                DateTime      tradeDay      = tradeRange.GetTradeDay(DateTime.Now);
                USeKLine      dayKLine      = GetDayKLine(tradeDay, instrument);

                DayKLineFactory dayFactory = new DayKLineFactory(instrument, dayKLine, m_kLinePublisher, tradeRange, m_eventLogger, m_dayKLinePublishInterval, isMainConract, m_instrumentManager);
                factoryList.Add(dayFactory);
                MinKLineFactory min1Factory = new MinKLineFactory(instrument, m_kLinePublisher, tradeRange, m_eventLogger, USeCycleType.Min1, isMainConract);
                factoryList.Add(min1Factory);

                m_kLineFactoryDic.Add(instrument.InstrumentCode, factoryList);
            }

            Debug.Assert(factoryList != null && factoryList.Count == 2);

            return(new List <KLineFactory>(factoryList));
        }