Esempio n. 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;
            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));
        }