private IDataForward_Code GetDataForward() { if (isTickForward) { return(dataForward); } if (this.dataForward != null) { this.dataForward.NavigateTo(Time); return(this.dataForward); } ForwardPeriod forwardPeriod = new ForwardPeriod(true, KLinePeriod.KLinePeriod_1Minute); ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods(); referedPeriods.UseTickData = true; referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute); referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute); referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_15Minute); referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Hour); referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Day); this.dataForward = DataCenter.Default.HistoryDataForwardFactory.CreateDataForward_Code(this.DataPackage, referedPeriods, forwardPeriod); this.dataForward.Forward(); this.dataForward.NavigateTo(this.Time); this.dataForward.OnRealTimeChanged += DataForward_OnRealTimeChanged; return(this.dataForward); }
public void TestSaveLoad_DataForward_Code() { string code = "rb1710"; int startDate = 20170601; int endDate = 20170602; ForwardPeriod forwardPeriod = new ForwardPeriod(true, KLinePeriod.KLinePeriod_1Minute); ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods(new KLinePeriod[] { KLinePeriod.KLinePeriod_1Minute, KLinePeriod.KLinePeriod_15Minute, KLinePeriod.KLinePeriod_1Hour, KLinePeriod.KLinePeriod_1Day }, true, false); IDataForward_Code dataForward = DataCenter.Default.HistoryDataForwardFactory.CreateDataForward_Code(code, startDate, endDate, referedPeriods, forwardPeriod); for (int i = 0; i < 100; i++) { dataForward.Forward(); } Console.WriteLine(XmlUtils.ToString(dataForward)); XmlElement root = GetXmlRoot(); dataForward.Save(root); IDataForward_Code dataForward2 = DataCenter.Default.HistoryDataForwardFactory.CreateDataForward_Code(root); for (int i = 0; i < 100; i++) { dataForward.Forward(); dataForward2.Forward(); } Console.WriteLine(XmlUtils.ToString(dataForward2)); Assert.AreEqual(dataForward.Time, dataForward2.Time); }
private void AssertForwardData(string code, int start, int end, List <string> list_OnBar) { IDataPackage_Code dataPackage = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, end, 0, 0); List <KLinePeriod> usedKLinePeriods = new List <KLinePeriod>(); usedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute); usedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute); usedKLinePeriods.Add(KLinePeriod.KLinePeriod_15Minute); usedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Hour); usedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Day); ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods(usedKLinePeriods, true, true); DataForForward_Code dataForForward = new DataForForward_Code(dataPackage, referedPeriods); List <int> tradingDays = dataForForward.TradingDayReader.GetAllTradingDays(); dataForForward.TradingDay = tradingDays[0]; ForwardDataIndeier indeier = new ForwardDataIndeier(dataForForward); IKLineData_Extend klineData = dataForForward.MainKLine; int currentBarPos = klineData.BarPos; for (int i = 0; i < tradingDays.Count; i++) { int tradingDay = tradingDays[i]; dataForForward.TradingDay = tradingDay; currentBarPos = Forward(dataForForward, indeier, tradingDay, currentBarPos, list_OnBar); } }
private void AssertMockStrategy_Ma_Object1(IStrategy strategyObject) { ForwardReferedPeriods periods = strategyObject.GetStrategyPeriods(); Assert.AreEqual(false, periods.UseTickData); Assert.AreEqual(2, periods.UsedKLinePeriods.Count); Assert.AreEqual(KLinePeriod.KLinePeriod_1Minute, periods.UsedKLinePeriods[0]); Assert.AreEqual(KLinePeriod.KLinePeriod_5Minute, periods.UsedKLinePeriods[1]); }
public void TestSaveLoad_ReferedPeriod() { ForwardReferedPeriods rp = new ForwardReferedPeriods(new KLinePeriod[] { KLinePeriod.KLinePeriod_1Minute, KLinePeriod.KLinePeriod_15Minute, KLinePeriod.KLinePeriod_1Hour, KLinePeriod.KLinePeriod_1Day }, true, false); XmlElement root = GetXmlRoot(); rp.Save(root); ForwardReferedPeriods rp2 = new ForwardReferedPeriods(); rp2.Load(root); Assert.AreEqual(rp, rp2); }
public void Play() { this.isPlaying = true; if (dataForward_Code == null || this.LastOperator == OPERATOR_NAVIGATE) { if (this.dataForward_Code != null) { this.dataForward_Code.OnRealTimeChanged -= DataForward_Code_OnRealTimeChanged; } ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods(new KLinePeriod[] { KLinePeriod.KLinePeriod_1Minute, KLinePeriod.KLinePeriod_5Minute, KLinePeriod.KLinePeriod_15Minute, KLinePeriod.KLinePeriod_1Hour, KLinePeriod.KLinePeriod_1Day }, true, true); ForwardPeriod forwardPeriod = new ForwardPeriod(true, KLinePeriod.KLinePeriod_1Minute); this.dataForward_Code = dataCenter.HistoryDataForwardFactory.CreateDataForward_Code(this.DataPackage, referedPeriods, forwardPeriod); this.dataForward_Code.OnRealTimeChanged += DataForward_Code_OnRealTimeChanged; this.dataForward_Code.NavigateTo(Time); } this.LastOperator = OPERATOR_PLAY; this.dataForward_Code.Play(); }
public RealTimeReader_Strategy(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod) { this.dataPackage = dataPackage; this.code = dataPackage.Code; this.startDate = dataPackage.StartDate; this.endDate = dataPackage.EndDate; this.referedPeriods = referedPeriods; this.forwardPeriod = forwardPeriod; this.allKLineData = new Dictionary <KLinePeriod, KLineData_RealTime>(); for (int i = 0; i < referedPeriods.UsedKLinePeriods.Count; i++) { KLinePeriod period = referedPeriods.UsedKLinePeriods[i]; IKLineData klineData = dataPackage.GetKLineData(period); KLineData_RealTime klineData_RealTime = new KLineData_RealTime(klineData); allKLineData.Add(period, klineData_RealTime); } IList <int> allTradingDays = dataPackage.GetTradingDays(); if (forwardPeriod.IsTickForward) { this.klineDataForward = new HistoryDataForward_Code_TickPeriod(dataPackage, allKLineData, allTradingDays, forwardPeriod.KlineForwardPeriod); } else { KLinePeriod mainPeriod = forwardPeriod.KlineForwardPeriod; KLineData_RealTime mainKLineData = allKLineData[mainPeriod]; this.klineDataForward = new HistoryDataForward_Code_KLinePeriod(code, mainKLineData, allKLineData); } this.klineDataForward.OnRealTimeChanged += KlineDataForward_OnRealTimeChanged; this.klineDataForward.OnTick += KlineDataForward_OnTick; this.klineDataForward.OnBar += KlineDataForward_OnBar; //this.klineDataForward = HistoryDataForwardFactory.CreateHistoryDataForward_Code(dataPackage, referedPeriods, forwardPeriod); //this.klineDataForward.OnTick += KlineDataForward_OnTick; //this.klineDataForward.OnBar += KlineDataForward_OnBar; }
public DataForward_AttachCode_Tick(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods) { this.dataPackage = dataPackage; this.referedPeriods = referedPeriods; this.dataForForward = new DataForForward_Code(dataPackage, referedPeriods); }
public void AttachOtherData(string code, ForwardReferedPeriods referedPeriods) { }