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));
                }
            }
        }
Esempio n. 2
0
        private TimeLineData_RealTime GetTimeLineData_RealTime(TimeLineData timeLineData, ITickData tickData, double time)
        {
            this.timeLineData_RealTime = new TimeLineData_RealTime(this.timeLineData);
            int timeLineIndex = TimeIndeierUtils.IndexOfTime_TimeLine(this.timeLineData, time);
            //this.timeLineData_RealTime.IndexOfTime(time);
            int    tickIndex      = TimeIndeierUtils.IndexOfTime_Tick(tickData, time);
            double klineTime      = timeLineData_RealTime.Arr_Time[timeLineIndex];
            int    startTickIndex = TimeIndeierUtils.IndexOfTime_Tick(tickData, klineTime);

            //IKLineData klineData = dataPackage.GetKLineData(date, date, 1, 0, KLinePeriod.KLinePeriod_1Day);
            float       lastEndPrice = dataPackage.GetLastEndPrice(date);
            TimeLineBar klineBar     = GetTimeLineBar(tickData, startTickIndex, tickIndex, lastEndPrice);

            timeLineData_RealTime.ChangeCurrentBar(klineBar, timeLineIndex);
            return(timeLineData_RealTime);
        }