Exemple #1
0
        private static IDataForward_Code GetKLineDataForward(string code, int start, int endDate)
        {
            //KLineData_RealTime klineData_1Minute = CommonData.GetKLineData_RealTime(code, start, endDate, KLinePeriod.KLinePeriod_1Minute);
            //KLineData_RealTime klineData_5Minute = CommonData.GetKLineData_RealTime(code, start, endDate, KLinePeriod.KLinePeriod_5Minute);
            //KLineData_RealTime klineData_15Minute = CommonData.GetKLineData_RealTime(code, start, endDate, KLinePeriod.KLinePeriod_15Minute);
            //KLineData_RealTime klineData_1Day = CommonData.GetKLineData_RealTime(code, start, endDate, KLinePeriod.KLinePeriod_1Day);
            //Dictionary<KLinePeriod, KLineData_RealTime> dic = new Dictionary<KLinePeriod, KLineData_RealTime>();

            //IList<int> tradingDays = CommonData.GetDataReader().TradingDayReader.GetTradingDays(start, endDate);
            //dic.Add(KLinePeriod.KLinePeriod_1Minute, klineData_1Minute);
            //dic.Add(KLinePeriod.KLinePeriod_5Minute, klineData_5Minute);
            //dic.Add(KLinePeriod.KLinePeriod_15Minute, klineData_15Minute);
            //dic.Add(KLinePeriod.KLinePeriod_1Day, klineData_1Day);

            IDataPackage_Code     dataPackage    = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, endDate);
            ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods();

            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_15Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Day);
            referedPeriods.UseTickData = true;

            ForwardPeriod     forwardPeriod    = new ForwardPeriod(true, KLinePeriod.KLinePeriod_1Minute);
            IDataForward_Code klineDataForward = DataCenter.Default.HistoryDataForwardFactory.CreateDataForward_Code(dataPackage, referedPeriods, forwardPeriod);

            //new HistoryDataForward_Code_TickPeriod(, code, periods, KLinePeriod.KLinePeriod_1Minute);
            return(klineDataForward);
        }
Exemple #2
0
        public void TestForwardCodeIndeier()
        {
            string code    = "RB1710";
            int    start   = 20170601;
            int    endDate = 20170603;

            IDataPackage_Code     dataPackage    = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, endDate);
            ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods();

            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_15Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Hour);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Day);
            referedPeriods.UseTickData     = true;
            referedPeriods.UseTimeLineData = true;

            printLine.Clear();
            DataForForward_Code        data1   = new DataForForward_Code(dataPackage, referedPeriods);
            DataForForward_CodeIndeier indeier = new DataForForward_CodeIndeier(data1);

            int len = data1.GetMainKLineData().Length;

            for (int i = 0; i < len; i++)
            {
                IKLineBar bar = data1.GetMainKLineData().GetBar(i);
                Print(bar, indeier.GetFinishedBarsRelativeToMainKLine(i), data1);
            }

            AssertUtils.AssertEqual_List("forwardcodeindeier", GetType(), printLine);
        }
Exemple #3
0
 public DataForward_Code_Tick2(IDataCenter dataCenter, IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod)
 {
     this.dataCenter          = dataCenter;
     this.dataPackage         = dataPackage;
     this.referedPeriods      = referedPeriods;
     this.forwardPeriod       = forwardPeriod;
     this.dataForForward_Code = new DataForForward_Code(dataPackage, referedPeriods);
 }
Exemple #4
0
        public HistoryDataForward_Code(IDataReader dataReader, string code, HistoryDataForwardArguments args)
        {
            IDataPackage_Code     dataPackage    = DataPackageFactory.CreateDataPackage(dataReader, code, args.StartDate, args.EndDate);
            ForwardReferedPeriods referedPeriods = args.ReferedPeriods;
            ForwardPeriod         forwardPeriod  = new ForwardPeriod(args.IsTickForward, args.ForwardKLinePeriod);

            this.Init(dataPackage, referedPeriods, forwardPeriod);
        }
Exemple #5
0
 public DataForForward_Code(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods)
 {
     this.dataPackage          = dataPackage;
     this.referedPeriods       = referedPeriods;
     this.dic_Period_KLineData = dataPackage.CreateKLineData_RealTimes(referedPeriods.UsedKLinePeriods);
     this.mainKLinePeriod      = referedPeriods.GetMinPeriod();
     this.mainKLineData        = this.dic_Period_KLineData[mainKLinePeriod];
     this.cache_TradingDay     = new CacheUtils_TradingDay(dataPackage.GetTradingDays());
 }
Exemple #6
0
        public void Load(XmlElement xmlElem)
        {
            this.dataPackage    = this.dataCenter.DataPackageFactory.CreateDataPackage_Code(xmlElem);
            this.referedPeriods = new ForwardReferedPeriods();
            this.referedPeriods.Load(xmlElem);

            this.dic_Period_KLineData = dataPackage.CreateKLineData_RealTimes(referedPeriods.UsedKLinePeriods);
            this.cache_TradingDay     = new CacheUtils_TradingDay(dataPackage.GetTradingDays());
            this.TradingDay           = int.Parse(xmlElem.GetAttribute("tradingDay"));
        }
Exemple #7
0
        private static IDataForward_Code GetDataForward(string code, int start, int endDate)
        {
            ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods();

            referedPeriods.UseTickData     = false;
            referedPeriods.UseTimeLineData = true;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_15Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Day);
            ForwardPeriod forwardPeriod = new ForwardPeriod(false, KLinePeriod.KLinePeriod_1Minute);

            return(DataCenter.Default.HistoryDataForwardFactory.CreateDataForward_Code(code, start, endDate, referedPeriods, forwardPeriod));
        }
Exemple #8
0
        public static IDataForward_Code GetHistoryDataForward_Code(string code, int startDate, int endDate, bool useTickData, bool useTimeLineData, IList <KLinePeriod> klinePeriods)
        {
            ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods();

            referedPeriods.UseTimeLineData = useTimeLineData;
            referedPeriods.UseTickData     = useTickData;
            referedPeriods.UsedKLinePeriods.AddRange(klinePeriods);

            ForwardPeriod forwardPeriod = new ForwardPeriod(useTickData, referedPeriods.GetMinPeriod());

            IDataPackage_Code dataPackage = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, startDate, endDate);
            //DataPackageFactory.CreateDataPackage(GetDataReader(), code, startDate, endDate);
            IDataForward_Code realTimeReader = DataCenter.Default.HistoryDataForwardFactory.CreateDataForward_Code(dataPackage, referedPeriods, forwardPeriod);

            return(realTimeReader);
        }
Exemple #9
0
        public DataForward(IDataForwardFactory fac, IDataPackage_Code[] dataPackage, ForwardReferedPeriods[] referedPeriods, ForwardPeriod forwardPeriod)
        {
            this.dataPackage    = dataPackage;
            this.referedPeriods = referedPeriods;
            this.forwardPeriod  = forwardPeriod;
            this.tradingDays    = dataPackage[0].GetTradingDays();

            this.historyDataForwards = new List <IDataForward_Code>();

            for (int i = 0; i < dataPackage.Length; i++)
            {
                ForwardReferedPeriods referedPeriod           = referedPeriods[i];
                ForwardPeriod         currentForwardPeriod    = new ForwardPeriod(referedPeriod.UseTickData, referedPeriod.GetMinPeriod());
                IDataForward_Code     historyDataForward_Code = fac.CreateDataForward_Code(dataPackage[i], referedPeriod, currentForwardPeriod);
                this.historyDataForwards.Add(historyDataForward_Code);
            }
        }
        private static IDataForward_Code GetKLineDataForward(string code, int start, int endDate)
        {
            IDataPackage_Code     dataPackage    = DataCenter.Default.DataPackageFactory.CreateDataPackage_Code(code, start, endDate);
            ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods();

            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_5Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_15Minute);
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Day);
            referedPeriods.UseTickData     = true;
            referedPeriods.UseTimeLineData = true;

            ForwardPeriod     forwardPeriod    = new ForwardPeriod(true, KLinePeriod.KLinePeriod_1Minute);
            IDataForward_Code klineDataForward = DataCenter.Default.HistoryDataForwardFactory.CreateDataForward_Code(dataPackage, referedPeriods, forwardPeriod);

            //new HistoryDataForward_Code_TickPeriod(, code, periods, KLinePeriod.KLinePeriod_1Minute);
            return(klineDataForward);
        }
Exemple #11
0
 public override bool Equals(object obj)
 {
     if (!(obj is ForwardReferedPeriods))
         return false;
     ForwardReferedPeriods referedPeriods = (ForwardReferedPeriods)obj;
     if (this.useTickData != referedPeriods.useTickData || this.useTimeLineData != referedPeriods.useTimeLineData)
         return false;
     if (this.usedKLinePeriods.Count != referedPeriods.usedKLinePeriods.Count)
         return false;
     this.usedKLinePeriods.Sort();
     referedPeriods.usedKLinePeriods.Sort();
     for (int i = 0; i < this.usedKLinePeriods.Count; i++)
     {
         if (!this.usedKLinePeriods[i].Equals(referedPeriods.usedKLinePeriods[i]))
             return false;
     }
     return true;
 }
        private static IDataForward_Code GetRealTimeReader(string code, int start, int endDate, bool useTickData)
        {
            ForwardReferedPeriods referedPeriods = new ForwardReferedPeriods();

            referedPeriods.UseTimeLineData = false;
            referedPeriods.UseTickData     = useTickData;
            referedPeriods.UsedKLinePeriods.Add(KLinePeriod.KLinePeriod_1Minute);

            //HistoryDataForwardArguments args = new HistoryDataForwardArguments();
            //args.StartDate = start;
            //args.EndDate = endDate;
            //args.ReferedPeriods = referedPeriods;
            //args.IsTickForward = useTickData;
            //args.ForwardKLinePeriod = KLinePeriod.KLinePeriod_1Minute;

            IDataPackage_Code dataPackage = ForwardDataGetter.GetDataPackage(code, start, endDate);
            //HistoryDataForward_Code realTimeReader = new HistoryDataForward_Code(CommonData.GetDataReader(), code, args);
            IDataForward_Code realTimeReader = DataCenter.Default.HistoryDataForwardFactory.CreateDataForward_Code(dataPackage, referedPeriods, new ForwardPeriod(useTickData, KLinePeriod.KLinePeriod_1Minute));

            return(realTimeReader);
        }
Exemple #13
0
        public void TestHistoryDataForward_TickKLine()
        {
            //主做螺纹钢,跟踪螺纹钢指数15分钟线和日线
            //跟踪郑醇的分钟线
            string[] codes = new string[] { "RB1801", "RB0000", "MA801" };
            int      start = 20170601;
            int      end   = 20170603;

            ForwardReferedPeriods[] referedPeriods = new ForwardReferedPeriods[3];
            referedPeriods[0] = new ForwardReferedPeriods(new KLinePeriod[] { KLinePeriod.KLinePeriod_1Minute, KLinePeriod.KLinePeriod_15Minute, KLinePeriod.KLinePeriod_1Day }, true, true);
            referedPeriods[1] = new ForwardReferedPeriods(new KLinePeriod[] { KLinePeriod.KLinePeriod_15Minute, KLinePeriod.KLinePeriod_1Day }, true, true);
            referedPeriods[2] = new ForwardReferedPeriods(new KLinePeriod[] { KLinePeriod.KLinePeriod_1Minute }, true, true);
            ForwardPeriod forwardPeriod = new ForwardPeriod(true, KLinePeriod.KLinePeriod_1Minute);
            IDataForward  forward       = DataCenter.Default.HistoryDataForwardFactory.CreateHistoryDataForward(codes, start, end, referedPeriods, forwardPeriod);

            forward.OnBar  += Forward_OnBar2;
            forward.OnTick += Forward_OnTick2;

            while (forward.Forward())
            {
            }
        }
Exemple #14
0
        private void Init(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod)
        {
            this.dataPackage    = dataPackage;
            this.referedPeriods = referedPeriods;
            this.forwardPeriod  = forwardPeriod;

            Dictionary <KLinePeriod, KLineData_RealTime> allKLineData = new Dictionary <KLinePeriod, KLineData_RealTime>();

            for (int i = 0; i < referedPeriods.UsedKLinePeriods.Count; i++)
            {
                KLinePeriod        period             = referedPeriods.UsedKLinePeriods[i];
                IKLineData         klineData          = this.dataPackage.GetKLineData(period);
                KLineData_RealTime klineData_RealTime = new KLineData_RealTime(klineData);
                allKLineData.Add(period, klineData_RealTime);
            }

            //ITimeLineData timelineData = this.dataReader.TimeLineDataReader.GetData(code, startDate);
            //this.timeLineData_RealTime = new TimeLineData_RealTime(timelineData);

            IList <int> allTradingDays = dataPackage.GetTradingDays();

            if (forwardPeriod.IsTickForward)
            {
                //this.historyDataForward = new HistoryDataForward_Code_TickPeriod(dataReader, code, allKLineData, allTradingDays, forwardPeriod.KlineForwardPeriod);
                this.historyDataForward = new HistoryDataForward_Code_TickPeriod(dataPackage, allKLineData, allTradingDays, forwardPeriod.KlineForwardPeriod);
            }
            else
            {
                KLinePeriod        mainPeriod    = forwardPeriod.KlineForwardPeriod;
                KLineData_RealTime mainKLineData = allKLineData[mainPeriod];
                this.historyDataForward = new HistoryDataForward_Code_KLinePeriod(Code, mainKLineData, allKLineData);
            }

            this.historyDataForward.OnRealTimeChanged += HistoryDataForward_OnRealTimeChanged;
            this.historyDataForward.OnTick            += KlineDataForward_OnTick;
            this.historyDataForward.OnBar             += KlineDataForward_OnBar;
        }
Exemple #15
0
 public IDataForward_Code CreateDataForward_Code(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod)
 {
     if (forwardPeriod.IsTickForward)
     {
         return(new DataForward_Code_Tick2(dataCenter, dataPackage, referedPeriods, forwardPeriod));
     }
     //return new HistoryDataForward_Code_TickPeriod(dataPackage, referedPeriods.UsedKLinePeriods, forwardPeriod.KlineForwardPeriod, referedPeriods.UseTimeLineData);
     return(new DataForward_Code_KLine(dataCenter, dataPackage, referedPeriods, forwardPeriod));
 }
Exemple #16
0
 public DataForward_Code_KLine(IDataCenter dataCenter, IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod)
 {
     this.dataCenter              = dataCenter;
     this.navigateData            = new DataForForward_Code(dataPackage, referedPeriods);
     this.navigateData.TradingDay = navigateData.StartDate;
     this.forwardPeriod           = forwardPeriod;
     this.mainKLineData           = this.navigateData.GetKLineData(forwardPeriod.KlineForwardPeriod);
     this.listenedCodes[0]        = mainKLineData.Code;
     this.onBarArgument           = new ForwardOnBarArgument(this.barFinishedInfos, this);
     InitKLine();
 }
Exemple #17
0
 public DataForward_AttachCode_Tick(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods)
 {
     this.dataPackage    = dataPackage;
     this.referedPeriods = referedPeriods;
     this.dataForForward = new DataForForward_Code(dataPackage, referedPeriods);
 }
Exemple #18
0
 public DataForward_Code_Tick3(IDataCenter dataCenter, IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod)
 {
     this.dataCenter         = dataCenter;
     this.forwardData        = new DataForForward_Code(dataPackage, referedPeriods);
     this.forwardDataIndeier = new DataForForward_CodeIndeier(forwardData);
     this.forwardPeriod      = forwardPeriod;
     Init();
     InitData();
 }
Exemple #19
0
 public HistoryDataForward_Code(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod)
 {
     Init(dataPackage, referedPeriods, forwardPeriod);
 }
Exemple #20
0
        public IDataForward_Code CreateDataForward_Code(string code, int startDate, int endDate, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod)
        {
            IDataPackage_Code dataPackage = dataCenter.DataPackageFactory.CreateDataPackage_Code(code, startDate, endDate);

            return(CreateDataForward_Code(dataPackage, referedPeriods, forwardPeriod));
        }
Exemple #21
0
 public HistoryDataForwardArguments(int startDate, int endDate, ForwardReferedPeriods referedPeriods, bool isTickForward, KLinePeriod forwardKLinePeriod)
 {
     this.startDate = startDate;
     this.endDate   = endDate;
 }