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); RealTimeDataPackageTimeChangeUtils.ChangeTime_TickData(tickData, time); Assert.AreEqual(argument.TickInfo.TickBar.ToString(), tickData.ToString()); IRealTimeDataReader_Code realTimeData = ((IRealTimeDataReader_Code)sender); RealTimeDataPackageTimeChangeUtils.ChangeTime_KLineData(klineData_1Minute, tradingDay, time, tickData); Assert.AreEqual(realTimeData.GetKLineData(KLinePeriod.KLinePeriod_1Minute).ToString(), klineData_1Minute.ToString()); RealTimeDataPackageTimeChangeUtils.ChangeTime_KLineData(klineData_5Minute, tradingDay, time, tickData); Assert.AreEqual(realTimeData.GetKLineData(KLinePeriod.KLinePeriod_5Minute).ToString(), klineData_5Minute.ToString()); RealTimeDataPackageTimeChangeUtils.ChangeTime_KLineData(klineData_15Minute, tradingDay, time, tickData); Assert.AreEqual(realTimeData.GetKLineData(KLinePeriod.KLinePeriod_15Minute).ToString(), klineData_15Minute.ToString()); RealTimeDataPackageTimeChangeUtils.ChangeTime_KLineData(klineData_1Day, tradingDay, time, tickData); Assert.AreEqual(realTimeData.GetKLineData(KLinePeriod.KLinePeriod_1Day).ToString(), klineData_1Day.ToString()); ITimeLineData_RealTime timeLineData = GetTimeLineData(tradingDay); RealTimeDataPackageTimeChangeUtils.ChangeTime_TimeLineData(timeLineData, time, tickData); Assert.AreEqual(realTimeData.GetTimeLineData().ToString(), timeLineData.ToString()); }
public IKLineData_Extend GetKLineData(KLinePeriod klinePeriod) { if (klinePeriod.PeriodType == KLineTimeType.SECOND) { IKLineData_RealTime klineData_Second = dataPackage_Code.CreateKLineData_RealTime_Second(tradingDay, klinePeriod); RealTimeDataPackageTimeChangeUtils.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_Code.CreateKLineData_RealTime(klinePeriod); this.dic_Period_KLineData.Add(klinePeriod, klineData); } RealTimeDataPackageTimeChangeUtils.ChangeTime_KLineData(klineData, tradingDay, time, GetTickData()); return(klineData); }