public static PositionDetail CreateDetail(CLRDFITCMatchRtnField pos) { PositionDetail result = new PositionDetail(); switch (pos.exchangeID) { case "DCE": result.ExchangeID = ExchangeID.DCE; break; case "CZCE": result.ExchangeID = ExchangeID.CZCE; break; case "SHFE": result.ExchangeID = ExchangeID.SHFE; break; case "CFFEX": result.ExchangeID = ExchangeID.CFFEX; break; case "INE": result.ExchangeID = ExchangeID.INE; break; } result.InstrumentID = pos.instrumentID; switch (pos.buySellType) { case (short)CLRDFITCBuySellType.SPD_BUY: result.Direction = Direction.Buy; break; case (short)CLRDFITCBuySellType.SPD_SELL: result.Direction = Direction.Sell; break; } result.PositionPrice = pos.matchedPrice; result.VolumeAll = pos.matchedAmount; switch (pos.speculator) { case (int)CLRDFITCSpeculatorType.SPD_SPECULATOR: result.Flag = Flag.Speculator; break; case (int)CLRDFITCSpeculatorType.SPD_HEDGE: result.Flag = Flag.Hedge; break; case (int)CLRDFITCSpeculatorType.SPD_ARBITRAGE: result.Flag = Flag.Arbitrage; break; } return(result); }
protected override void OnRtnMatchedInfo(CLRDFITCMatchRtnField RtnMatchData) { if (ProgramTradeEvents.RspEventHandler.ContainsKey(RspSpiModules.OrderDeal) && null != ProgramTradeEvents.RspEventHandler[RspSpiModules.OrderDeal]) { TypedRspEventArgs <CLRDFITCMatchRtnField, object> evt = new TypedRspEventArgs <CLRDFITCMatchRtnField, object> { RequestID = -1, ErrorID = 0, Message = RtnMatchData.matchedTime, Data = RtnMatchData, Error = null, IsLast = true }; Parallel.ForEach(ProgramTradeEvents.RspEventHandler[RspSpiModules.OrderDeal].GetInvocationList(), handler => { (handler as EventHandler <RspEventArgs>).BeginInvoke(this, evt, null, null); }); } }