跳转至

ReqExecOrderInsert

执行宣告录入请求

错误响应: OnErrRtnExecOrderInsertOnRspExecOrderInsert

正确响应: OnRtnExecOrder

1.函数原型

virtual int ReqExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, int nRequestID) = 0;

2.参数

pInputExecOrder:输入的执行宣告

字段类型字段名称含义
TThostFtdcBrokerIDType BrokerID 经纪公司代码 必填
TThostFtdcInvestorIDType InvestorID 投资者代码 必填
TThostFtdcInstrumentIDType InstrumentID 合约代码 必填
TThostFtdcOrderRefType ExecOrderRef 执行宣告引用 选填
TThostFtdcUserIDType UserID 用户代码
TThostFtdcBusinessUnitType BusinessUnit 业务单元
TThostFtdcExchangeIDType ExchangeID 交易所代码
TThostFtdcInvestUnitIDType InvestUnitID 投资单元代码
TThostFtdcAccountIDType AccountID 投资者帐号
TThostFtdcCurrencyIDType CurrencyID 币种代码
TThostFtdcClientIDType ClientID 客户代码
TThostFtdcIPAddressType IPAddress IP地址
TThostFtdcMacAddressType MacAddress Mac地址
TThostFtdcVolumeType Volume 数量 必填
TThostFtdcRequestIDType RequestID 请求编号
TThostFtdcOffsetFlagType OffsetFlag 开平标志 必填
TThostFtdcHedgeFlagType HedgeFlag 投机套保标志 投机或套保
TThostFtdcActionTypeType ActionType 执行类型 必填
TThostFtdcPosiDirectionType PosiDirection 保留头寸申请的持仓方向 多头
TThostFtdcExecOrderPositionFlagType ReservePositionFlag 期权行权后是否保留期货头寸的标记,该字段已废弃 该字段已废弃,调用时不能为空
TThostFtdcExecOrderCloseFlagType CloseFlag 期权行权后生成的头寸是否自动平仓 必填
TThostFtdcOldInstrumentIDType reserve1 保留的无效字段
TThostFtdcOldIPAddressType reserve2 保留的无效字段

ExecOrderRef:需要纯数字递增,不填则ctp自动填写

IPAddress:手工填写本机IP地址,不自动获取。填写规则如下:ipv4原样填写,ipv6要转成非零压缩地址,即原始地址,同时要去掉冒号,eg:AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH

nRequestID:请求ID,对应响应里的nRequestID,无递增规则,由用户自行维护。

3.返回

0,代表成功。

-1,表示网络连接失败;

-2,表示未处理请求超过许可数;

-3,表示每秒发送请求数超过许可数。

4.调用示例

CThostFtdcInputExecOrderField OrderInsert = { 0 };
strcpy_s(OrderInsert.BrokerID, "9999");
strcpy_s(OrderInsert.InvestorID, "1000001");
strcpy_s(OrderInsert.InstrumentID, "rb1809");
strcpy_s(OrderInsert.ExchangeID, "SHFE");
strcpy_s(OrderInsert.ExecOrderRef, "00001");
strcpy_s(OrderInsert.UserID, "1000001");
OrderInsert.Volume = 1;
OrderInsert.RequestID = 1; 
OrderInsert.OffsetFlag = THOST_FTDC_OF_Close;//开平标志
OrderInsert.HedgeFlag = THOST_FTDC_HF_Speculation;//投机套保标志
OrderInsert.ActionType = THOST_FTDC_ACTP_Exec;//执行类型类型
OrderInsert.PosiDirection = THOST_FTDC_PD_Long;//持仓多空方向类型
OrderInsert.ReservePositionFlag = THOST_FTDC_EOPF_Reserve;//期权行权后是否保留期货头寸的标记类型
OrderInsert.CloseFlag = THOST_FTDC_EOCF_NotToClose;//期权行权后生成的头寸是否自动平仓类型
m_pUserApi->ReqExecOrderInsert(&OrderInsert, nRequestID++);

5.FAQ

盘中通过api进行中金所行权,报错“CTP:不支持的功能”为什么?

中金所不支持通过api行权,只能盘后通过会服提交行权申请。