Exemplo n.º 1
0
        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));
                }
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到今日的TICK数据
 /// </summary>
 /// <returns></returns>
 public ITickData_Extend GetTickData()
 {
     if (currentTickData == null || currentTickData.TradingDay != tradingDay)
     {
         currentTickData = dataPackage.GetTickData(tradingDay);
     }
     DataNavigate_ChangeTime.ChangeTime_TickData(currentTickData, time);
     return(currentTickData);
 }
Exemplo n.º 4
0
 public ITickData_Extend GetTickData()
 {
     if (currentTickData == null || currentTickData.TradingDay != tradingDay)
     {
         currentTickData = dataPackage_Code.GetTickData(tradingDay);
     }
     RealTimeDataPackageTimeChangeUtils.ChangeTime_TickData(currentTickData, time);
     return(currentTickData);
 }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        public void ChangeTime(double time)
        {
            if (this.time == time)
            {
                return;
            }
            this.time = time;
            int date = this.sessionReader.GetTradingDay(time);

            if (date < 0)
            {
                date = this.sessionReader.GetRecentTradingDay(time);
            }
            if (this.date != date)
            {
                this.date     = date;
                this.tickData = dataPackage.GetTickData(date);
            }
            int index = TimeIndeierUtils.IndexOfTime_Tick(tickData, time, true);

            tickData.BarPos = index < 0 ? 0 : index;
        }
Exemplo n.º 7
0
 private TimeLineData_RealTime GetTimeLineData_RealTime(int date, double time)
 {
     this.tickData     = dataPackage.GetTickData(date);
     this.timeLineData = (TimeLineData)dataPackage.GetTimeLineData(date);
     return(GetTimeLineData_RealTime(timeLineData, tickData, time));
 }
Exemplo n.º 8
0
 private KLineData_RealTime GetKLineData_RealTime(int date, double time)
 {
     this.tickData  = dataPackage.GetTickData(date);
     this.klineData = dataPackage.GetKLineData(klinePeriod);
     return(GetKLineData_RealTime(klineData, tickData, time));
 }