Example #1
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);
 }
Example #2
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);
        }