public void SubmitOrder(OptionOrder order) { var input = new ThostFtdcInputOrderField { BrokerID = this._config.BrokerId, InvestorID = this._config.Account, InstrumentID = order.InstrumentID, OrderRef = this._session.NextOrderRef().ToString(), UserID = this._config.Account, OrderPriceType = EnumOrderPriceTypeType.LimitPrice, Direction = order.Side == OrderSide.Buy ? EnumDirectionType.Buy : EnumDirectionType.Sell, CombOffsetFlag_0 = order.OpenClose == OpenClose.Open ? EnumOffsetFlagType.Open : EnumOffsetFlagType.Close, CombHedgeFlag_0 = EnumHedgeFlagType.Speculation, LimitPrice = Math.Round(order.Price, 4), VolumeTotalOriginal = order.Qty, TimeCondition = EnumTimeConditionType.GFD, VolumeCondition = EnumVolumeConditionType.AV, ContingentCondition = EnumContingentConditionType.Immediately, ForceCloseReason = EnumForceCloseReasonType.NotForceClose, IsAutoSuspend = 0, }; var ret = this._trade.ReqOrderInsert(input, this._session.NextRequestID()); if (ret != 0) { this.OnLog(string.Format("下单失败,返回{0}", ret)); } }
public void Start() { this.Running = true; var exchange = ExchangeManager.GetExchange <IOptionExchange>(); var instrument = exchange.Instruments.First(); var market = exchange.Market(instrument); var order = new OptionOrder { InstrumentID = instrument.ID, Qty = 100, Price = market.Asks.First().Price, Side = OrderSide.Buy, OpenClose = OpenClose.Open }; exchange.SubmitOrder(order); this.Log?.Invoke(LogType.Trade, order.ToString()); }
public void CancelOrder(OptionOrder order) { var native = new List <ThostFtdcOrderField>(this._orders).First(_ => _.OrderSysID == order.OrderID); var action = new ThostFtdcInputOrderActionField { BrokerID = this._config.BrokerId, InvestorID = this._config.Account, OrderSysID = native.OrderSysID, ActionFlag = EnumActionFlagType.Delete, UserID = this._config.Account, ExchangeID = native.ExchangeID, OrderRef = native.OrderRef, InstrumentID = order.InstrumentID }; var ret = this._trade.ReqOrderAction(action, this._session.NextRequestID()); if (ret != 0) { this.OnLog(string.Format("发送撤单请求失败,返回{0}", ret)); } }