private void ForwardToday_KLineData(IKLineData_RealTime klineData, KLinePeriod period) { ITickData_Extend currentTickData = forwardData.CurrentTickData; ITickBar nextTickBar = currentTickData.GetBar(currentTickData.BarPos + 1); //日线,肯定不会跳到下一个bar if (period.Equals(KLinePeriod.KLinePeriod_1Day)) { dic_KLinePeriod_IsEnd[period] = false; klineData.ChangeCurrentBar(GetKLineBar(klineData, nextTickBar)); return; } double nextTickTime = nextTickBar.Time; int nextKLineIndex = FindNextKLineIndex(klineData, nextTickTime); if (nextKLineIndex == klineData.BarPos) { dic_KLinePeriod_IsEnd[period] = false; klineData.ChangeCurrentBar(GetKLineBar(klineData, nextTickBar)); } else { dic_KLinePeriod_IsEnd[period] = true; klineData.ChangeCurrentBar(GetKLineBar(nextTickBar), nextKLineIndex); } }
private static void ForwardNextDay_KLine(DataForForward_Code forwardData, IKLineData_RealTime klineData, KLinePeriod period) { ITickBar tickBar = forwardData.CurrentTickData.GetCurrentBar(); int nextbarPos = klineData.BarPos + 1; klineData.ChangeCurrentBar(KLineUtils.GetKLineBar(tickBar), nextbarPos); }
private void InitData() { int currentTradingDay = tradingDays[0]; this.currentTickData = dataPackage.GetTickData(currentTradingDay); foreach (KLinePeriod period in dic_Period_KLineData.Keys) { IKLineData_RealTime klineData = dic_Period_KLineData[period]; klineData.ChangeCurrentBar(GetKLineBar(currentTickData)); if (period == forwardPeriod.KlineForwardPeriod) { mainKlineData = klineData; } } //初始化分时线 //int lastTradingDay = dataReader.TradingDayReader.GetPrevTradingDay(currentTradingDay); //IKLineData lastDayklineData = dataReader.KLineDataReader.GetData(code, lastTradingDay, lastTradingDay, KLinePeriod.KLinePeriod_1Day); //if (lastDayklineData.Length == 0) // lastEndPrice = currentTickData.Arr_Price[0]; //else // lastEndPrice = lastDayklineData.End; this.lastEndPrice = dataPackage.GetLastEndPrice(currentTradingDay); if (useTimeLineData) { ITimeLineData timeLineData = dataPackage.GetTimeLineData(currentTradingDay); if (timeLineData != null) { this.currentTimeLineData = new TimeLineData_RealTime(timeLineData); this.currentTimeLineData.ChangeCurrentBar(GetTimeLineBar(currentTickData, lastEndPrice)); } } }
private void ForwardKLine(IKLineData_RealTime klineData, bool isBarFinished, bool isBarStart) { ITickBar tickBar = dataForForward_Code.CurrentTickData; if (isBarFinished) { klineData.ResetCurrentBar(); } else if (isBarStart) { KLineBar klineBar = KLineUtils.GetKLineBar(tickBar); klineData.ChangeCurrentBar(klineBar, klineData.BarPos + 1); } else { KLineBar klineBar = KLineUtils.GetKLineBar(klineData, tickBar); klineData.ChangeCurrentBar(klineBar); } dic_KLinePeriod_IsEnd[klineData.Period] = isBarFinished; }
private void ForwardToday_KLine(IKLineData_RealTime klineData, double time, ITickData tickData, int prevTickIndex) { if (klineData.Period.Equals(KLinePeriod.KLinePeriod_1Day)) { klineData.ChangeCurrentBar(KLineUtils.GetKLineBar(klineData, tickData, prevTickIndex, tickData.BarPos)); return; } int nextKLineIndex = DataForward_Code_Tick.FindNextKLineIndex(klineData, time); if (nextKLineIndex == klineData.BarPos) { klineData.ChangeCurrentBar(KLineUtils.GetKLineBar(klineData, tickData, prevTickIndex, tickData.BarPos)); } else { double periodStartTime = klineData.Arr_Time[nextKLineIndex]; int startTickIndex = FindNextTickIndex(tickData, prevTickIndex, time); klineData.ChangeCurrentBar(KLineUtils.GetKLineBar(tickData, startTickIndex, tickData.BarPos), nextKLineIndex); } }
private static void ForwardNextDay_KLine(DataForForward_Code forwardData, IKLineData_RealTime klineData, KLinePeriod period) { ITickBar tickBar = forwardData.CurrentTickData.GetCurrentBar(); int nextbarPos = klineData.BarPos + 1; //TODO 这样nextday算法还是不够准确 while (!klineData.IsDayStart(nextbarPos)) { nextbarPos = klineData.BarPos + 1; } klineData.ChangeCurrentBar(GetKLineBar(tickBar), nextbarPos); }
private void InitKLine() { foreach (KLinePeriod period in dic_Period_KLineData.Keys) { IKLineData_RealTime klineData = dic_Period_KLineData[period]; //主K线最后前进 if (klineData == mainKLineData) { dic_KLinePeriod_IsEnd[period] = true; continue; } klineData.ChangeCurrentBar(mainKLineData); } }
private void InitKLine() { foreach (KLinePeriod period in this.navigateData.ReferedKLinePeriods) { IKLineData_RealTime klineData = this.navigateData.GetKLineData(period); //主K线最后前进 if (klineData == mainKLineData) { dic_KLinePeriod_IsEnd[period] = true; continue; } klineData.ChangeCurrentBar(mainKLineData); } }
private void ForwardKLine_NextPeriod(IKLineData_RealTime klineData, int newBarPos, ITickBar tickBar) { KLineBar bar = new KLineBar(); bar.Time = tickBar.Time; bar.Start = tickBar.Price; bar.High = tickBar.Price; bar.Low = tickBar.Price; bar.End = tickBar.Price; bar.Money = tickBar.Mount * tickBar.Price; bar.Mount = tickBar.Mount; bar.Hold = tickBar.Hold; klineData.BarPos = newBarPos; klineData.ChangeCurrentBar(bar); }
private void ForwardNextDay_KLine(IKLineData_RealTime klineData, KLinePeriod period) { if (period.PeriodType >= KLineTimeType.DAY) { double day = currentTickData.TradingDay; int nextKLineIndex = FindNextKLineIndex(klineData, day); if (nextKLineIndex != klineData.BarPos) { dic_KLinePeriod_IsEnd[period] = true; klineData.ChangeCurrentBar(GetKLineBar(currentTickData), nextKLineIndex); } else { dic_KLinePeriod_IsEnd[period] = false; klineData.ChangeCurrentBar(GetKLineBar(klineData, currentTickData)); } return; } ITickBar tickBar = currentTickData.GetCurrentBar(); int nextbarPos = klineData.BarPos + 1; klineData.ChangeCurrentBar(GetKLineBar(tickBar), nextbarPos); }
private void PrepareData() { this.listenedCodes[0] = this.dataForForward_Code.Code; this.dataForForward_Code.TradingDay = dataPackage.StartDate; this.forwardDataIndeier = new ForwardDataIndeier(dataForForward_Code); this.onBarArgument = new ForwardOnBarArgument(barFinishedInfos, this); foreach (KLinePeriod period in referedPeriods.UsedKLinePeriods) { IKLineData_RealTime klineData = this.dataForForward_Code.GetKLineData(period); klineData.ChangeCurrentBar(KLineUtils.GetKLineBar(dataForForward_Code.CurrentTickData)); } if (dataForForward_Code.UseTimeLineData) { ITimeLineData_RealTime timeLineData = dataForForward_Code.CurrentTimeLineData; timeLineData.ChangeCurrentBar(TimeLineUtils.GetTimeLineBar(dataForForward_Code.CurrentTickData, timeLineData.YesterdayEnd)); } }
private void InitData() { this.forwardData.TradingDay = forwardData.StartDate; foreach (KLinePeriod period in forwardData.ReferedKLinePeriods) { IKLineData_RealTime klineData = forwardData.GetKLineData(period); klineData.ChangeCurrentBar(GetKLineBar(forwardData.CurrentTickData)); } if (this.forwardData.UseTimeLineData) { float lastEndPrice = this.forwardData.CurrentTimeLineData.YesterdayEnd; //dataPackage.GetLastEndPrice(forwardData.StartDate); this.forwardData.CurrentTimeLineData.ChangeCurrentBar(GetTimeLineBar(forwardData.CurrentTickData, lastEndPrice)); } foreach (string code in dic_Code_DataForward.Keys) { dic_Code_DataForward[code].ForwardNextDay(forwardData.TradingDay, this.Time); } }
public static void ChangeTime_KLineData(IKLineData_RealTime klineData_RealTime, int date, double time, ITickData_Extend tickData) { KLinePeriod klinePeriod = klineData_RealTime.Period; int klineIndex = IndexOfTime(klineData_RealTime, klinePeriod, time, date); //if(tickData.TradingDay !=date) // tickData = int tickIndex = TimeIndeierUtils.IndexOfTime_Tick(tickData, time, true); if (IsPeriodEnd(klineData_RealTime, klineIndex, tickData, tickIndex)) { klineData_RealTime.BarPos = klineIndex; klineData_RealTime.ResetCurrentBar(); return; } int startTickIndex = GetStartTickIndex(klineData_RealTime, tickData, klinePeriod, klineIndex); KLineBar klineBar = GetKLineBar(tickData, startTickIndex, tickIndex); klineData_RealTime.ChangeCurrentBar(klineBar, klineIndex); }
private void ForwardBar_CurrentPeriod(IKLineData_RealTime klineData, IKLineBar klineBar) { double time = klineBar.Time; IKLineBar oldbar = klineData.GetBar(klineData.BarPos); KLineBar bar = new KLineBar(); bar.Time = klineBar.Time; bar.Start = oldbar.Start; bar.High = klineBar.High > oldbar.High ? klineBar.High : oldbar.High; bar.Low = klineBar.Low < oldbar.Low ? klineBar.Low : oldbar.Low; bar.End = klineBar.End; bar.Mount = oldbar.Mount + klineBar.Mount; bar.Money = oldbar.Money + klineBar.Money; bar.Hold = klineBar.Hold; klineData.ChangeCurrentBar(bar); }
private void ForwardBar_NextPeriod(IKLineData_RealTime klineData, IKLineBar klineBar) { klineData.BarPos++; klineData.ChangeCurrentBar(klineBar); }