public DataForForward_Code(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods) { this.dataPackage = dataPackage; this.referedPeriods = referedPeriods; this.dic_Period_KLineData = dataPackage.CreateKLineData_RealTimes(referedPeriods.UsedKLinePeriods); this.mainKLinePeriod = referedPeriods.GetMinPeriod(); this.mainKLineData = this.dic_Period_KLineData[mainKLinePeriod]; this.cache_TradingDay = new CacheUtils_TradingDay(dataPackage.GetTradingDays()); }
private void InitStrategyExecutorInfo() { this.strategyExecutorInfo = new StrategyExecutorInfo(codePeriod, dataPackage.GetTradingDays().Count); this.strategyExecutorInfo.CurrentDay = dataPackage.GetTradingDays()[0]; this.strategyExecutorInfo.CurrentDayIndex = 0; this.tempBarFinishedArguments = new StrategyBarFinishedArguments(this.strategyExecutorInfo); this.tempDayFinishedArguments = new StrategyDayFinishedArguments(this.strategyExecutorInfo); }
public void Load(XmlElement xmlElem) { this.dataPackage = this.dataCenter.DataPackageFactory.CreateDataPackage_Code(xmlElem); this.referedPeriods = new ForwardReferedPeriods(); this.referedPeriods.Load(xmlElem); this.dic_Period_KLineData = dataPackage.CreateKLineData_RealTimes(referedPeriods.UsedKLinePeriods); this.cache_TradingDay = new CacheUtils_TradingDay(dataPackage.GetTradingDays()); this.TradingDay = int.Parse(xmlElem.GetAttribute("tradingDay")); }
public HistoryDataForward_Code_TickPeriod(IDataPackage_Code dataPackage, IList <KLinePeriod> periods, KLinePeriod forwardPeriod, bool useTimeLineData) { this.allKLinePeriods = periods; Dictionary <KLinePeriod, IKLineData_RealTime> allKLineData = dataPackage.CreateKLineData_RealTimes(periods); IList <int> tradingDays = dataPackage.GetTradingDays(); this.useTimeLineData = useTimeLineData; this.onBarArgument = new ForwardOnBarArgument(barFinishedInfos); Init(dataPackage, allKLineData, tradingDays, forwardPeriod); }
public void TestTimeLineToKLine() { string code = "RB1710"; int start = 20170601; int end = 20170605; IDataPackage_Code datapackage = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, end, 0, 0); IKLineData_Extend klineData = datapackage.GetKLineData(KLinePeriod.KLinePeriod_1Minute); //IKLineData_Extend klineData = datapackage.GetKLineData(KLinePeriod.KLinePeriod_5Minute); IList <int> tradingDays = datapackage.GetTradingDays(); ITimeLineData timeLineData = datapackage.GetTimeLineData(tradingDays[0]); TimeLineToKLineIndeier indeier = new TimeLineToKLineIndeier(klineData, timeLineData); int tradingDayIndex = 0; bool isFirst = true; for (int i = klineData.BarPos; i < klineData.Length; i++) { if (!isFirst && klineData.IsDayStart(i)) { tradingDayIndex++; if (tradingDayIndex >= tradingDays.Count) { return; } timeLineData = datapackage.GetTimeLineData(tradingDays[tradingDayIndex]); indeier.ChangeTradingDay(timeLineData); } isFirst = false; klineData.BarPos = i; Console.WriteLine(klineData.Period + ":" + klineData.GetBar(i)); int barPos = indeier.GetTimeLineBarPosIfFinished(i); if (barPos >= 0) { timeLineData.BarPos = barPos; Console.WriteLine("分时线:" + timeLineData.GetBar(barPos)); } Assert.AreEqual(klineData.Time, timeLineData.Time); Assert.AreEqual(klineData.End, timeLineData.Price); } }
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 void TestKLineToTick_Days() { string code = "RB1710"; int start = 20170601; int end = 20170605; List <string> list_OnBar = new List <string>(); IDataPackage_Code datapackage = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, end, 0, 0); IKLineData_Extend klineData = datapackage.GetKLineData(KLinePeriod.KLinePeriod_1Minute); IList <int> tradingDays = datapackage.GetTradingDays(); ITickData tickData = datapackage.GetTickData(tradingDays[0]); KLineToTickIndeier indeier = new KLineToTickIndeier(tickData, klineData); DoIndex(list_OnBar, klineData, tickData, indeier); for (int i = 1; i < tradingDays.Count; i++) { tickData = datapackage.GetTickData(tradingDays[i]); indeier.ChangeTradingDay(tickData); DoIndex(list_OnBar, klineData, tickData, indeier); } }
private void Init(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod) { this.dataPackage = dataPackage; this.referedPeriods = referedPeriods; this.forwardPeriod = forwardPeriod; Dictionary <KLinePeriod, KLineData_RealTime> allKLineData = new Dictionary <KLinePeriod, KLineData_RealTime>(); for (int i = 0; i < referedPeriods.UsedKLinePeriods.Count; i++) { KLinePeriod period = referedPeriods.UsedKLinePeriods[i]; IKLineData klineData = this.dataPackage.GetKLineData(period); KLineData_RealTime klineData_RealTime = new KLineData_RealTime(klineData); allKLineData.Add(period, klineData_RealTime); } //ITimeLineData timelineData = this.dataReader.TimeLineDataReader.GetData(code, startDate); //this.timeLineData_RealTime = new TimeLineData_RealTime(timelineData); IList <int> allTradingDays = dataPackage.GetTradingDays(); if (forwardPeriod.IsTickForward) { //this.historyDataForward = new HistoryDataForward_Code_TickPeriod(dataReader, code, allKLineData, allTradingDays, forwardPeriod.KlineForwardPeriod); this.historyDataForward = new HistoryDataForward_Code_TickPeriod(dataPackage, allKLineData, allTradingDays, forwardPeriod.KlineForwardPeriod); } else { KLinePeriod mainPeriod = forwardPeriod.KlineForwardPeriod; KLineData_RealTime mainKLineData = allKLineData[mainPeriod]; this.historyDataForward = new HistoryDataForward_Code_KLinePeriod(Code, mainKLineData, allKLineData); } this.historyDataForward.OnRealTimeChanged += HistoryDataForward_OnRealTimeChanged; this.historyDataForward.OnTick += KlineDataForward_OnTick; this.historyDataForward.OnBar += KlineDataForward_OnBar; }
public IList <int> GetTradingDays() { return(dataPackage_Code.GetTradingDays()); }