Example #1
0
        public RealTimeDataReceiver_Code(string code, int date, IDataReader dataReader, List <KLinePeriod> periods, List <double[]> openTime)
        {
            this.code = code;
            this.date = date;
            int lastOpenDate = dataReader.TradingDayReader.GetPrevTradingDay(date);
            RecentKLineDataLoader recentKLineDataLoader = new RecentKLineDataLoader(dataReader);

            for (int i = 0; i < periods.Count; i++)
            {
                KLinePeriod period = periods[i];
                this.dic_Period_KLineData.Add(period, new KLineData_RealTime(recentKLineDataLoader.GetRecentKLineData(code, lastOpenDate, period), KLineTimeListUtils.GetKLineTimeList(date, lastOpenDate, openTime, period), period));
            }

            List <double> timeList  = KLineTimeListUtils.GetKLineTimeList(date, lastOpenDate, openTime, KLinePeriod.KLinePeriod_1Minute);
            IKLineData    klineData = dataReader.KLineDataReader.GetData(code, date, date, KLinePeriod.KLinePeriod_1Day);
            //this.timeLineData = new TimeLineData_RealTime(timeList);
        }
Example #2
0
        private static void InitKLineData(IKLineData klineData_History, KLinePeriod klinePeriod, int openDate, int lastOpenDate, List <double[]> openTime)
        {
            DataReaderFactory fac      = ResourceLoader.GetDefaultDataReaderFactory();
            ITickData         tickData = fac.TickDataReader.GetTickData("m05", openDate);

            List <double>     klineTimeList = KLineTimeListUtils.GetKLineTimeList(openDate, lastOpenDate, openTime, klinePeriod);
            KLineData_Present klineData     = new KLineData_Present(klineData_History, klineTimeList, klinePeriod);

            for (int i = 0; i < tickData.Length; i++)
            {
                tickData.BarPos = i;
                klineData.Receive(tickData);
                Console.WriteLine(klineData);
            }

            Console.WriteLine();
            for (int i = 0; i < klineData.Length; i++)
            {
                klineData.BarPos = i;
                Console.WriteLine(klineData);
            }
        }