private void CurrentNavigate_Code_OnRealTimeChanged(object sender, RealTimeChangedArgument argument) { if (this.OnRealTimeChanged != null) { this.OnRealTimeChanged(sender, argument); } }
private void RealTimeDataReader_Code_OnRealTimeChanged(object sender, RealTimeChangedArgument argument) { if (OnRealTimeChanged != null) { OnRealTimeChanged(this, argument); } }
private void HistoryDataForward_OnRealTimeChanged(object sender, RealTimeChangedArgument e) { if (this.OnRealTimeChanged != null) { this.OnRealTimeChanged(this, e); } }
//public RealTimeReader_Strategy(IDataReader dataReader, RealTimeReader_StrategyArguments args) //{ // //this.dataPackage = DataPackageFactory.CreateDataPackage(dataReader,) // this.dataReader = dataReader; // this.code = args.Code; // this.startDate = args.StartDate; // this.endDate = args.EndDate; // this.referedPeriods = args.ReferedPeriods; // this.forwardPeriod = new ForwardPeriod(args.IsTickForward, args.ForwardKLinePeriod); // this.allKLineData = new Dictionary<KLinePeriod, KLineData_RealTime>(); // for (int i = 0; i < referedPeriods.UsedKLinePeriods.Count; i++) // { // KLinePeriod period = referedPeriods.UsedKLinePeriods[i]; // IKLineData klineData = this.dataReader.KLineDataReader.GetData(code, startDate, endDate, period); // KLineData_RealTime klineData_RealTime = new KLineData_RealTime(klineData); // allKLineData.Add(period, klineData_RealTime); // } // IList<int> allTradingDays = dataReader.TradingDayReader.GetTradingDays(startDate, endDate); // if (args.IsTickForward) // { // this.klineDataForward = new HistoryDataForward_Code_TickPeriod(dataReader, code, allKLineData, allTradingDays, args.ForwardKLinePeriod); // } // else // { // KLinePeriod mainPeriod = args.ForwardKLinePeriod; // KLineData_RealTime mainKLineData = allKLineData[mainPeriod]; // this.klineDataForward = new HistoryDataForward_Code_KLinePeriod(code, mainKLineData, allKLineData); // } // this.klineDataForward.OnTick += KlineDataForward_OnTick; // this.klineDataForward.OnBar += KlineDataForward_OnBar; //} private void KlineDataForward_OnRealTimeChanged(object sender, RealTimeChangedArgument e) { if (OnRealTimeChanged != null) { OnRealTimeChanged(this, e); } }
private void DataForward_OnRealTimeChanged(object sender, RealTimeChangedArgument argument) { if (OnRealTimeChanged != null) { OnRealTimeChanged(this, new RealTimeChangedArgument(argument.PrevTime, this.Time, this)); } if (OnNavigateTo != null) { OnNavigateTo(this, new DataNavigateEventArgs(Code, Code, argument.PrevTime, argument.Time)); } }
private void RealTimeDataReader_RealTimeChanged(object sender, RealTimeChangedArgument e) { lock (lockObj) { this.time = e.Time; //过了新的一天,昨日的委托需要全部清除 if (e.TradingDayChanged) { CancelAllOrder(); return; } loopOrders.Clear(); loopOrders.AddRange(waitingOrders); //TODO 价格变化后需要修改现金余额 for (int i = 0; i < loopOrders.Count; i++) { OrderInfo order = loopOrders[i]; if (AccountSetting.TradeType == AccountTradeType.DELAYTIME) { double delayTime = AccountSetting.DelayTime; double betweenTime = e.Time - order.OrderTime; if (betweenTime <= delayTime) { continue; } } else if (accountSetting.TradeType == AccountTradeType.DELAYTICK) { ITickData tickData = this.realTimeDataReader.GetRealTimeData(order.Instrumentid).GetTickData(); if (tickData != null) { if (this.dic_Code_OrderDelayInfo.ContainsKey(order.OrderID)) { OrderDelayInfo delayInfo = this.dic_Code_OrderDelayInfo[order.OrderID]; int tickIndex = delayInfo.orderTickIndex; int delayTick = AccountSetting.DelayTick; if (tickData.BarPos - tickIndex < delayTick) { continue; } } } } DoTrade(order); } } }
private void DataForward_Code_OnRealTimeChanged(object sender, RealTimeChangedArgument argument) { if (this.OnRealTimeChanged != null) { double prevTime = argument.PrevTime; double time = argument.Time; this.OnRealTimeChanged(this, new RealTimeChangedArgument(prevTime, time, this)); } if (this.OnNavigateTo != null) { string prevCode = Code; string code = Code; double prevTime = argument.PrevTime; double time = argument.Time; this.OnNavigateTo(this, new DataNavigateEventArgs(prevCode, code, prevTime, time)); } }