Пример #1
0
        public override int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, int pCustom, OrderType pType = OrderType.Limit, HedgeType pHedge = HedgeType.Speculation)
        {
            //限价
            var OrderPriceType  = TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice;
            var TimeCondition   = TThostFtdcTimeConditionType.THOST_FTDC_TC_GFD;          //THOST_FTDC_TC_GFD
            var VolumeCondition = TThostFtdcVolumeConditionType.THOST_FTDC_VC_AV;

            if (pType == OrderType.Market)             //市价
            {
                OrderPriceType = TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_AnyPrice;
                TimeCondition  = TThostFtdcTimeConditionType.THOST_FTDC_TC_IOC;
                //max = instField.MaxMarketOrderVolume;
                pPrice = 0;
            }
            else if (pType == OrderType.FAK)             //FAK
            {
                OrderPriceType = TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice;
                TimeCondition  = TThostFtdcTimeConditionType.THOST_FTDC_TC_IOC;
            }
            else if (pType == OrderType.FOK)             //FOK
            {
                OrderPriceType  = TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice;
                TimeCondition   = TThostFtdcTimeConditionType.THOST_FTDC_TC_IOC;
                VolumeCondition = TThostFtdcVolumeConditionType.THOST_FTDC_VC_CV;                 //全部数量
            }

            return((int)_t.ReqOrderInsert(
                       _broker,
                       _investor,
                       InstrumentID: pInstrument,
                       OrderRef: string.Format("{0:000000}{1:000000}", _ref++, pCustom % 1000000),
                       CombHedgeFlag: new string((char)(pHedge == HedgeType.Speculation ? TThostFtdcHedgeFlagType.THOST_FTDC_HF_Speculation : pHedge == HedgeType.Arbitrage ? TThostFtdcHedgeFlagType.THOST_FTDC_HF_Arbitrage : TThostFtdcHedgeFlagType.THOST_FTDC_HF_Hedge), 1),
                       CombOffsetFlag: new String((char)(pOffset == OffsetType.Open ? TThostFtdcOffsetFlagType.THOST_FTDC_OF_Open : pOffset == OffsetType.Close ? TThostFtdcOffsetFlagType.THOST_FTDC_OF_Close : TThostFtdcOffsetFlagType.THOST_FTDC_OF_CloseToday), 1),
                       Direction: pDirection == DirectionType.Buy ? TThostFtdcDirectionType.THOST_FTDC_D_Buy : TThostFtdcDirectionType.THOST_FTDC_D_Sell,
                       VolumeTotalOriginal: pVolume,
                       ForceCloseReason: TThostFtdcForceCloseReasonType.THOST_FTDC_FCC_NotForceClose,
                       ContingentCondition: TThostFtdcContingentConditionType.THOST_FTDC_CC_Immediately,
                       VolumeCondition: VolumeCondition,
                       LimitPrice: pPrice,
                       IsSwapOrder: 0,
                       MinVolume: 1,
                       UserForceClose: 0,
                       TimeCondition: TimeCondition,
                       OrderPriceType: OrderPriceType));
        }