Exemplo n.º 1
0
        private void DataForward_OnTick(object sender, IForwardOnTickArgument argument)
        {
            double time = argument.Time;
            //if (time < 20170601.205900)
            //    return;
            int tradingDay = argument.TickInfo.TickData.TradingDay;

            if (prevTime == time)
            {
                return;
            }
            this.prevTime = time;
            ITickData_Extend tickData = GetTickData(tradingDay);

            //Console.WriteLine(tickData);
            DataNavigate_ChangeTime.ChangeTime_TickData(tickData, time);
            Assert.AreEqual(argument.TickInfo.TickBar.ToString(), tickData.ToString());

            IRealTimeData_Code realTimeData = ((IRealTimeData_Code)sender);

            DataNavigate_ChangeTime.ChangeTime_KLineData(klineData_1Minute, tradingDay, time, tickData);
            Assert.AreEqual(realTimeData.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString(), klineData_1Minute.ToString());
            DataNavigate_ChangeTime.ChangeTime_KLineData(klineData_5Minute, tradingDay, time, tickData);
            Assert.AreEqual(realTimeData.GetKLineData(KLinePeriod.KLinePeriod_5Minute).ToString(), klineData_5Minute.ToString());
            DataNavigate_ChangeTime.ChangeTime_KLineData(klineData_15Minute, tradingDay, time, tickData);
            Assert.AreEqual(realTimeData.GetKLineData(KLinePeriod.KLinePeriod_15Minute).ToString(), klineData_15Minute.ToString());
            DataNavigate_ChangeTime.ChangeTime_KLineData(klineData_1Day, tradingDay, time, tickData);
            Assert.AreEqual(realTimeData.GetKLineData(KLinePeriod.KLinePeriod_1Day).ToString(), klineData_1Day.ToString());

            ITimeLineData_RealTime timeLineData = GetTimeLineData(tradingDay);

            DataNavigate_ChangeTime.ChangeTime_TimeLineData(timeLineData, time, tickData);
            Assert.AreEqual(realTimeData.GetTimeLineData().ToString(), timeLineData.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到指定周期的K线
        /// </summary>
        /// <param name="period"></param>
        /// <returns></returns>
        public IKLineData GetKLineData(KLinePeriod klinePeriod)
        {
            if (klinePeriod.PeriodType == KLineTimeType.SECOND)
            {
                IKLineData_RealTime klineData_Second = dataPackage.CreateKLineData_RealTime_Second(tradingDay, klinePeriod);
                DataNavigate_ChangeTime.ChangeTime_KLineData(klineData_Second, tradingDay, time, GetTickData());
                return(klineData_Second);
            }

            IKLineData_RealTime klineData;

            if (this.dic_Period_KLineData.ContainsKey(klinePeriod))
            {
                klineData = this.dic_Period_KLineData[klinePeriod];
            }
            else
            {
                klineData = dataPackage.CreateKLineData_RealTime(klinePeriod);
                this.dic_Period_KLineData.Add(klinePeriod, klineData);
            }
            DataNavigate_ChangeTime.ChangeTime_KLineData(klineData, tradingDay, time, GetTickData());
            return(klineData);
        }