Example #1
0
        private void AssertText(string code, int start, int end, string fileName)
        {
            List <string>      list_OnBar  = new List <string>();
            IDataPackage_Code  datapackage = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, end, 0, 0);
            IKLineData_Extend  klineData   = datapackage.GetKLineData(KLinePeriod.KLinePeriod_1Minute);
            ITickData          tickData    = datapackage.GetTickData(start);
            KLineToTickIndeier indeier     = new KLineToTickIndeier(tickData, klineData);

            int lastBarPos;

            for (int i = 0; i < tickData.Length; i++)
            {
                list_OnBar.Add("tick:" + tickData.GetBar(i));
                Console.WriteLine("tick:" + tickData.GetBar(i));
                int pos = indeier.GetKLineBarPosIfFinished(i, out lastBarPos);
                if (pos >= 0)
                {
                    list_OnBar.Add(klineData.Period + ":" + klineData.GetBar(pos));
                    Console.WriteLine(klineData.Period + ":" + klineData.GetBar(pos));
                    for (int m = pos + 1; m <= lastBarPos; m++)
                    {
                        list_OnBar.Add(klineData.Period + ":" + klineData.GetBar(m));
                        Console.WriteLine(klineData.Period + ":" + klineData.GetBar(m));
                        //lastBarPos = 1;
                    }
                }
            }
            AssertUtils.AssertEqual_List(fileName, GetType(), list_OnBar);
        }
Example #2
0
 public ForwardDataIndeier(DataForForward_Code dataForForward)
 {
     this.dataForForward = dataForForward;
     if (this.dataForForward.ReferedKLinePeriods.Count > 1)
     {
         List <IKLineData_Extend> indexKLines = new List <IKLineData_Extend>();
         for (int i = 0; i < this.dataForForward.ReferedKLinePeriods.Count; i++)
         {
             KLinePeriod klinePeriod = this.dataForForward.ReferedKLinePeriods[i];
             if (this.dataForForward.MainKLinePeriod == klinePeriod)
             {
                 continue;
             }
             indexKLines.Add(this.dataForForward.GetKLineData(klinePeriod));
         }
         this.klineToKlineIndeier = new KLineToKLineIndeier(dataForForward.MainKLine, indexKLines);
     }
     if (this.dataForForward.UseTickData)
     {
         int tradingDay            = dataForForward.TradingDay;
         ITickData_Extend tickData = this.dataForForward.CurrentTickData;
         this.klineToTickIndeier = new KLineToTickIndeier(tickData, dataForForward.MainKLine);
     }
     if (this.dataForForward.UseTimeLineData)
     {
         int tradingDay = dataForForward.TradingDay;
         ITimeLineData_Extend timeLineData = this.dataForForward.CurrentTimeLineData;
         this.timeToKLineIndeier = new TimeLineToKLineIndeier(dataForForward.MainKLine, timeLineData);
     }
 }
Example #3
0
        public void TestKLineToTick_Days()
        {
            string code  = "RB1710";
            int    start = 20170601;
            int    end   = 20170605;

            List <string>     list_OnBar  = new List <string>();
            IDataPackage_Code datapackage = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, end, 0, 0);
            IKLineData_Extend klineData   = datapackage.GetKLineData(KLinePeriod.KLinePeriod_1Minute);

            IList <int>        tradingDays = datapackage.GetTradingDays();
            ITickData          tickData    = datapackage.GetTickData(tradingDays[0]);
            KLineToTickIndeier indeier     = new KLineToTickIndeier(tickData, klineData);

            DoIndex(list_OnBar, klineData, tickData, indeier);

            for (int i = 1; i < tradingDays.Count; i++)
            {
                tickData = datapackage.GetTickData(tradingDays[i]);
                indeier.ChangeTradingDay(tickData);
                DoIndex(list_OnBar, klineData, tickData, indeier);
            }
        }
Example #4
0
        private static void DoIndex(List <string> list_OnBar, IKLineData_Extend klineData, ITickData tickData, KLineToTickIndeier indeier)
        {
            int lastBarPos;

            for (int i = 0; i < tickData.Length; i++)
            {
                list_OnBar.Add("tick:" + tickData.GetBar(i));
                Console.WriteLine("tick:" + tickData.GetBar(i));
                int pos = indeier.GetKLineBarPosIfFinished(i, out lastBarPos);
                if (pos >= 0)
                {
                    list_OnBar.Add(klineData.Period + ":" + klineData.GetBar(pos));
                    Console.WriteLine(klineData.Period + ":" + klineData.GetBar(pos));
                    for (int m = pos + 1; m <= lastBarPos; m++)
                    {
                        list_OnBar.Add(klineData.Period + ":" + klineData.GetBar(m));
                        Console.WriteLine(klineData.Period + ":" + klineData.GetBar(m));
                    }
                }
            }
        }