Esempio n. 1
0
        /// <summary>
        /// 得到指定BarPos在交易时段的Index
        /// </summary>
        /// <param name="barPos"></param>
        /// <returns></returns>
        public int GetIndexInTradingPeriods(int barPos)
        {
            IKLineDataTradingTimeInfo_Periods tradingPeriods = GetTradingPeriodsByBarPos(barPos);
            int startBarPos = tradingPeriods.StartPos;

            return(barPos - startBarPos);
        }
Esempio n. 2
0
        /// <summary>
        /// 是否是一天结束
        /// </summary>
        /// <param name="barPos"></param>
        /// <returns></returns>
        public bool IsDayEnd(int barPos)
        {
            IKLineDataTradingTimeInfo_Periods tradingPeriods = GetTradingPeriodsByBarPos(barPos);

            if (tradingPeriods.PeriodIndex != tradingPeriods.KlineTimeInfo_Day.TradingPeriods.Count - 1)
            {
                return(false);
            }
            return(tradingPeriods.EndPos == barPos && (tradingPeriods.EndPos == tradingPeriods.KlineTimeInfo_Day.EndPos));
        }
Esempio n. 3
0
        /// <summary>
        /// 指定的barPos是否是一天的开始
        /// </summary>
        /// <param name="barPos"></param>
        /// <returns></returns>
        public bool IsDayStart(int barPos)
        {
            IKLineDataTradingTimeInfo_Periods tradingPeriods = GetTradingPeriodsByBarPos(barPos);

            if (tradingPeriods.PeriodIndex != 0)
            {
                return(false);
            }
            return(tradingPeriods.StartPos == barPos && (tradingPeriods.StartPos == tradingPeriods.KlineTimeInfo_Day.StartPos));
        }
Esempio n. 4
0
 public IKLineDataTradingTimeInfo_Periods FindPeriods(int barPos)
 {
     for (int i = 0; i < TradingPeriods.Count; i++)
     {
         IKLineDataTradingTimeInfo_Periods periods = TradingPeriods[i];
         if (periods.StartPos <= barPos && periods.EndPos >= barPos)
         {
             return(periods);
         }
     }
     return(null);
 }
Esempio n. 5
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("TradingDay:");
            sb.Append(tradingDay).Append(",");
            sb.Append(startPos).Append(",");
            sb.Append(endPos).Append(",");
            sb.Append(holidayCount).Append("\r\n");
            for (int i = 0; i < tradingPeriodsArr.Count; i++)
            {
                IKLineDataTradingTimeInfo_Periods periods = tradingPeriodsArr[i];
                sb.Append(periods.ToString()).Append("\r\n");
            }
            return(sb.ToString());
        }
Esempio n. 6
0
 public KLineData_Extend(IKLineData klineData, IList <ITradingTime> tradingTimes)
 {
     if (klineData == null)
     {
         return;
     }
     this.klineData    = klineData;
     this.tradingTimes = tradingTimes;
     for (int i = 0; i < tradingTimes.Count; i++)
     {
         ITradingTime tradingTime = tradingTimes[i];
         dic_TradingDay_TradingTime.Add(tradingTime.TradingDay, tradingTime);
     }
     this.klineTimeInfo         = new KLineDataTradingTimeInfo(klineData, tradingTimes);
     this.currentTradingPeriods = klineTimeInfo.GetTradingPeriodsByBarPos(klineData.BarPos);
 }
Esempio n. 7
0
        public void TestGetKLineTimeInfo_Day()
        {
            string                   code          = "rb1805";
            int                      start         = 20170928;
            int                      end           = 20171020;
            IKLineData               klineData     = DataCenter.Default.DataReader.KLineDataReader.GetData(code, start, end, KLinePeriod.KLinePeriod_1Minute);
            IList <ITradingTime>     tradingTimes  = DataCenter.Default.DataReader.CreateTradingTimeReader(code).GetTradingTime(start, end);
            KLineDataTradingTimeInfo klineTimeInfo = new KLineDataTradingTimeInfo(klineData, tradingTimes);

            AssertUtils.PrintList(klineTimeInfo.TradingDays);
            Console.WriteLine();
            //for(int i = 0; i < klineTimeInfo.TradingDays.Count; i++)
            //{
            //    int tradingDay = klineTimeInfo.TradingDays[i];
            //    // klineTimeInfo.GetKLineTimeInfo_Day(tradingDay);
            //}
            Console.WriteLine(klineTimeInfo);

            IKLineDataTradingTimeInfo_Periods periods = klineTimeInfo.GetTradingPeriodsByBarPos(350);

            Assert.AreEqual("TradingPeriods:0,345,464", periods.ToString());
            //Console.WriteLine(periods);
        }
Esempio n. 8
0
 public void AddTradingPeriods(IKLineDataTradingTimeInfo_Periods tradingPeriods)
 {
     ((KLineDataTradingTimeInfo_Periods)tradingPeriods).klineTimeInfo_Day = this;
     this.tradingPeriodsArr.Add(tradingPeriods);
 }
Esempio n. 9
0
        /// <summary>
        /// 得到指定BarPos是否是一个开盘周期结束
        /// </summary>
        /// <param name="barPos"></param>
        /// <returns></returns>
        public bool IsTradingPeriodEnd(int barPos)
        {
            IKLineDataTradingTimeInfo_Periods tradingPeriods = GetTradingPeriodsByBarPos(barPos);

            return(tradingPeriods.EndPos == barPos);
        }