Example #1
0
 private int SendInsertOrder(CZQThostFtdcInputOrderField order)
 {
     //return CTPWrapper.TraderReqOrderInsert(this._instance, order, CreateRequestID());
       Trace.WriteLine(string.Format("{0} [{1}]:{2},{3},{4}", this.wallTimeStopwatch.ElapsedMilliseconds, this.UserKey, "SendInsertOrder", order.OrderRef, order.RequestID));
       return InvokeAPI(CTPStockRequestAction.OrderInsertAction, order);
 }
Example #2
0
        public CZQThostFtdcInputOrderActionField DeleteOrder(CZQThostFtdcInputOrderField order)
        {
            //撤单时,会引发报单时间小于登录时间的报单回报,
              //因此需要关闭过滤 FLag
              this.filterRestart = false;

              CZQThostFtdcInputOrderActionField orderAction = new CZQThostFtdcInputOrderActionField();

              orderAction.BrokerID = order.BrokerID;
              orderAction.InvestorID = order.InvestorID;

              orderAction.FrontID = this.FrontID;
              orderAction.SessionID = this.SessionID;
              orderAction.OrderRef = order.OrderRef;

              orderAction.InstrumentID = order.InstrumentID;

              orderAction.ActionFlag = CTPStockActionFlagType.Delete;

              //CTPWrapper.TraderReqOrderAction(this._instance, orderAction, CreateRequestID());
              InvokeAPI(CTPStockRequestAction.OrderActionAction, orderAction);

              return orderAction;
        }
Example #3
0
        private CZQThostFtdcInputOrderField CreateInputOrder(string exchangeID,string symbolCode, CTPStockDirectionType direct, CTPStockOffsetFlagType flag,double price,int volume, string orderRef = "")
        {
            CZQThostFtdcInputOrderField order = new CZQThostFtdcInputOrderField();

              order.BrokerID = this.BrokerID;
              order.InvestorID = this.InvestorID;

              //合约
              order.ExchangeID = exchangeID;
              order.InstrumentID = symbolCode;

              if (string.IsNullOrEmpty(orderRef))
              {
            order.OrderRef = System.Threading.Interlocked.Increment(ref this.currentOrderRef).ToString();
              }
              else
              {
            order.OrderRef = orderRef;
              }

              //限价单
              order.OrderPriceType = CTPStockOrderPriceType.LimitPrice;

              //方向
              order.Direction = direct;

              //开平仓
              order.CombOffsetFlag = new byte[] { (byte)flag, 0, 0, 0, 0 };

              //投机/套保
              order.CombHedgeFlag = new byte[] { (byte)CTPStockHedgeFlagType.Speculation, 0, 0, 0, 0 };

              ///价格
              order.LimitPrice = price.ToString();
              ///数量: 1
              order.VolumeTotalOriginal = volume;
              ///有效期类型: 当日有效
              order.TimeCondition = CTPStockTimeConditionType.GFD;
              ///GTD日期
              //	TThostFtdcDateType	GTDDate;
              ///成交量类型: 任何数量
              order.VolumeCondition = CTPStockVolumeConditionType.AV;
              ///最小成交量: 1
              order.MinVolume = 1;
              ///触发条件: 立即
              order.ContingentCondition = CTPStockContingentConditionType.Immediately;
              ///强平原因: 非强平
              order.ForceCloseReason = CTPStockForceCloseReasonType.NotForceClose;
              ///自动挂起标志: 是
              order.IsAutoSuspend = true;

              ///用户强评标志: 否
              order.UserForceClose = false;

              //条件单处理内容
              //if (parameter.OrderType == OrderType.ConditionOrder)
              //{

              //  //条件触发价
              //  order.StopPrice = (double)parameter.ConditionPrice;

              //  //报价方式
              //  if (order.OrderPriceType != CTPStockOrderPriceType.LimitPrice)
              //  {
              //    order.LimitPrice = "0";
              //  }
              //}

              return order;
        }