/// <summary> /// 行情数据回调函数,同时引发_OnTick多播事件。 /// </summary> /// <param name="pDepthMarketData"></param> private void CMdApi_OnRtnDepthMarketData(ref CThostFtdcDepthMarketDataField pDepthMarketData) { //添加到字典中 string instrumentIDKey = pDepthMarketData.InstrumentID; DepthMarketData dmd = this._DictDepthMarketData[instrumentIDKey]; dmd.CThostFtdcMarketDepthDataFieldInstance = pDepthMarketData; this._OnRtnDMD?.Invoke(dmd); //后台线程调用OnTick多播委托 //Task.Run(() => //{ Tick tick = new Tick(); tick.AskPrice = dmd.AskPrice1; tick.BidPrice = dmd.BidPrice1; tick.AskVolume = dmd.AskVolume1; tick.BidVolume = dmd.BidVolume1; tick.InstrumentID = dmd.InstrumentID; tick.LastPrice = dmd.LastPrice; tick.OpenInt = dmd.OpenInterest; tick.UpdateTime = dmd.TradingDay + " " + dmd.UpdateTime; tick.UpdateMillisec = dmd.UpdateMillisec; tick.Volume = dmd.Volume; _OnRtnTick?.Invoke(tick); //} //); //引发更新事件 //this._queueDepthMarketDataField.Enqueue(pDepthMarketData); //Task.Run(() => TaskProcessor(this._queueDepthMarketDataField, _cts.Token)); }
/// <summary> /// 启动,绑定OnRtnDMD /// </summary> public void Run(DepthMarketData dmd) { lock (_lock) { if (!this._isOrderSent && dmd.InstrumentID == this.InstrumentID && this._isPriceConditionSatisfied != null && this._isRunning && this._isPriceConditionSatisfied(dmd) && this._conditionOrderExecutionStatus == ConditionOrderExecutionStatus.Running) { this._isRunning = false; this._conditionOrderExecutionTrigger?.Invoke(this); this._isOrderSent = true; this._conditionOrderExecutionStatus = ConditionOrderExecutionStatus.Complete; Notify(""); } } }