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); }
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); }
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); }
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(); }
public void Load(XmlElement xmlElem) { double time = double.Parse(xmlElem.GetAttribute("time")); this.forwardPeriod = new ForwardPeriod(); this.forwardPeriod.Load(xmlElem); this.dataForForward_Code = new DataForForward_Code(dataCenter); this.dataForForward_Code.Load(xmlElem); this.NavigateTo(time); }
private void Init(IDataPackage_Code dataPackage, Dictionary <KLinePeriod, IKLineData_RealTime> allKLineData, IList <int> tradingDays, KLinePeriod forwardPeriod) { this.dataPackage = dataPackage; this.dic_Period_KLineData = allKLineData; this.tradingDays = tradingDays; this.forwardPeriod = new ForwardPeriod(true, forwardPeriod); InitData(); timer.Elapsed += Timer_Elapsed; timer.AutoReset = true; }
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(); }
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)); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (!(obj is ForwardPeriod)) { return(false); } ForwardPeriod fp = (ForwardPeriod)obj; return(this.isTickForward == fp.isTickForward && this.klineForwardPeriod.Equals(fp.klineForwardPeriod)); }
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); }
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); }
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()) { } }
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; }
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)); }
public IDataForward CreateHistoryDataForward(IDataPackage_Code[] dataPackage, ForwardReferedPeriods[] referedPeriods, ForwardPeriod forwardPeriod) { return(new DataForward(this, dataPackage, referedPeriods, forwardPeriod)); }
public HistoryDataForward_Code(IDataPackage_Code dataPackage, ForwardReferedPeriods referedPeriods, ForwardPeriod forwardPeriod) { Init(dataPackage, referedPeriods, forwardPeriod); }
public IDataForward CreateHistoryDataForward(string[] codes, int startDate, int endDate, ForwardReferedPeriods[] referedPeriods, ForwardPeriod forwardPeriod) { IDataPackage_Code[] dataPackages = new IDataPackage_Code[codes.Length]; for (int i = 0; i < codes.Length; i++) { string code = codes[i]; IDataPackage_Code dataPackage = dataCenter.DataPackageFactory.CreateDataPackage_Code(code, startDate, endDate); dataPackages[i] = dataPackage; } return(CreateHistoryDataForward(dataPackages, referedPeriods, forwardPeriod)); }
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)); }