Exemplo n.º 1
0
        public void TestOrderInsert()
        {
            _api.OnRtnOrder += new TradeApi.RtnOrder((ref CThostFtdcOrderField pOrder) =>
            {
                Console.WriteLine("下单成功, BrokerID: {0}, OrderSysID: {1}", pOrder.BrokerID, pOrder.OrderSysID);
            });
            _api.OnRspOrderInsert += new TradeApi.RspOrderInsert((ref CThostFtdcInputOrderField pInputOrder, ref CThostFtdcRspInfoField pRspInfo,
                                                                  int nRequestID, byte bIsLast) =>
            {
                if (pRspInfo.ErrorID != 0)
                {
                    Console.WriteLine(pRspInfo.ErrorMsg);
                    Assert.IsTrue(pRspInfo.ErrorID == 0);
                }
            });
            CThostFtdcInputOrderField order = new CThostFtdcInputOrderField();

            order.BrokerID            = _brokerID;
            order.InvestorID          = _investorID;
            order.InstrumentID        = "TF1809";
            order.OrderRef            = "1";
            order.UserID              = _investorID;
            order.OrderPriceType      = TThostFtdcOrderPriceTypeType.LimitPrice;
            order.Direction           = TThostFtdcDirectionType.Sell;
            order.CombOffsetFlag      = TThostFtdcOffsetFlagType.Open;
            order.CombHedgeFlag       = TThostFtdcHedgeFlagType.Speculation;
            order.LimitPrice          = 97.550;
            order.VolumeTotalOriginal = 1;
            order.TimeCondition       = TThostFtdcTimeConditionType.GFD;
            order.VolumeCondition     = TThostFtdcVolumeConditionType.AV;
            order.MinVolume           = 1;
            order.ContingentCondition = TThostFtdcContingentConditionType.Immediately;
            order.ForceCloseReason    = TThostFtdcForceCloseReasonType.NotForceClose;
            order.IsAutoSuspend       = (int)TThostFtdcBoolType.No;
            order.BusinessUnit        = null;
            order.UserForceClose      = (int)TThostFtdcBoolType.No;
            _api.OrderInsert(1, order);
            Thread.Sleep(500);
        }