Beispiel #1
0
        private void Init(IKLineData klineData, IList <ITradingTime> tradingTimes)
        {
            int currentKLineBarPos = 0;

            for (int i = 0; i < tradingTimes.Count; i++)
            {
                ITradingTime tradingTime = tradingTimes[i];
                KLineDataTradingTimeInfo_Day timeInfo = CalcKLineTimeInfo_Day(tradingTime, klineData, currentKLineBarPos);
                if (timeInfo == null)
                {
                    continue;
                }
                this.dic_TradingDay_KLineTimeInfo.Add(timeInfo.TradingDay, timeInfo);
                this.timeInfo_DayList.Add(timeInfo);
                currentKLineBarPos = timeInfo.EndPos;
                tradingDays.Add(tradingTime.TradingDay);
            }

            for (int i = 1; i < timeInfo_DayList.Count; i++)
            {
                int lastTradingDay = timeInfo_DayList[i - 1].TradingDay;
                KLineDataTradingTimeInfo_Day tradingTimeInfo_Day = (KLineDataTradingTimeInfo_Day)timeInfo_DayList[i];
                int currentTradingDay = tradingTimeInfo_Day.TradingDay;
                tradingTimeInfo_Day.holidayCount = TimeUtils.Substract(currentTradingDay, lastTradingDay).Days - 1;
            }
        }
Beispiel #2
0
 private void Init_Day(IKLineData klineData, IList <ITradingTime> tradingTimes)
 {
     for (int i = 0; i < tradingTimes.Count; i++)
     {
         ITradingTime tradingTime = tradingTimes[i];
         int          tradingDay  = (int)klineData.GetBar(i).Time;
         KLineDataTradingTimeInfo_Day timeInfo = new KLineDataTradingTimeInfo_Day(tradingDay);
         timeInfo.StartPos = i;
         timeInfo.EndPos   = i;
         this.dic_TradingDay_KLineTimeInfo.Add(timeInfo.TradingDay, timeInfo);
         this.timeInfo_DayList.Add(timeInfo);
         tradingDays.Add(tradingTime.TradingDay);
     }
 }
Beispiel #3
0
        private KLineDataTradingTimeInfo_Day CalcKLineTimeInfo_Day(ITradingTime tradingTime, IKLineData klineData, int currentBarPos)
        {
            if (tradingTime.PeriodCount == 0)
            {
                return(null);
            }
            KLineDataTradingTimeInfo_Day klineTimeInfo_Day = new KLineDataTradingTimeInfo_Day(tradingTime.TradingDay);

            for (int i = 0; i < tradingTime.PeriodCount; i++)
            {
                double[] periodTime = tradingTime.GetPeriodTime(i);
                int      startPos   = CalcEndBarPos(klineData, periodTime[0], currentBarPos);
                int      endPos     = CalcEndBarPos(klineData, periodTime[1], startPos + 1);
                currentBarPos = endPos + 1;
                KLineDataTradingTimeInfo_Periods timeInfo = new KLineDataTradingTimeInfo_Periods(i, startPos, endPos);
                klineTimeInfo_Day.AddTradingPeriods(timeInfo);
            }
            int dayStartPos = klineTimeInfo_Day.TradingPeriods[0].StartPos;
            int dayEndPos   = klineTimeInfo_Day.TradingPeriods[klineTimeInfo_Day.TradingPeriods.Count - 1].EndPos;

            klineTimeInfo_Day.StartPos = dayStartPos;
            klineTimeInfo_Day.EndPos   = dayEndPos;
            return(klineTimeInfo_Day);
        }