Example #1
0
        public CThostFtdcInputOrderField InsertOrder(string symbolCode, double price, CTPDirectionType direct, int volume, CTPOffsetFlagType flag,string orderRef = "")
        {
            CThostFtdcInputOrderField order = new CThostFtdcInputOrderField();

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

              //合约
              order.InstrumentID = symbolCode;

              if (string.IsNullOrEmpty(orderRef))
              {
            order.OrderRef = this.IncrementOrderRef().ToString();
              }
              else
              {
            order.OrderRef = orderRef;
              }

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

              //方向
              order.Direction = direct;

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

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

              //套利合约
              if (this.instrumentDictionary.ContainsKey(symbolCode))
              {
            if (this.instrumentDictionary[symbolCode].ProductClass == CTPProductClassType.Combination)
            {
              //开平仓
              order.CombOffsetFlag = new byte[] { (byte)flag, (byte)flag, 0, 0, 0 };

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

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

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

              SendInsertOrder(order);

              return order;
        }
Example #2
0
 public int SendInsertOrder(CThostFtdcInputOrderField order)
 {
     //Trace.WriteLine(string.Format("{0} [{1}]:{2},{3},{4}", this.wallTimeStopwatch.ElapsedMilliseconds, this.UserKey, "SendInsertOrder", order.OrderRef, order.RequestID));
       return InvokeAPI(CTPRequestAction.OrderInsertAction, order);
 }
Example #3
0
        public CThostFtdcInputOrderActionField DeleteOrder(CThostFtdcInputOrderField order)
        {
            CThostFtdcInputOrderActionField orderAction = new CThostFtdcInputOrderActionField();

              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 = CTPActionFlagType.Delete;

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

              return orderAction;
        }