CTP开发——期权操作

CTP现在也支持期权操作了,买卖期权和买卖期货一样,不一样的地方主要在行权这一块。

下面,我们就来看看期权的相关操作。


一、请求查询执行宣告:(行权委托查询)

CThostFtdcQryExecOrderField req = {0};
			strcpy(req.BrokerID,m_BrokerID);
			strcpy(req.InvestorID, m_InvestorInfos[reqInfo.lAccIdx].InvestorID);
			req.InstrumentID; //可以查询指定的合约,不填就是所有
			//req.ExchangeID;
			//req.ExecOrderSysID;
			//req.InsertTimeStart;
			//req.InsertTimeEnd;
			ReqQryExecOrder(&req,reqInfo.nRequestID);


二、/执行宣告录入请求:(行权)

CThostFtdcInputExecOrderField req = {0};
			strcpy(req.BrokerID,m_BrokerID);
			strcpy(req.InvestorID, m_InvestorInfos[reqInfo.lAccIdx].InvestorID);
			req.InstrumentID //必填
			ASSERT(m_nOrderRef);
			sprintf(req.ExecOrderRef, "%d", m_nExecOrderRef++);  
			strcpy(req.UserID,m_UserID);
			//买卖方向
			//req.Direction;
			//开平方向
			req.OffsetFlag = THOST_FTDC_OF_Close;//必填;
			//套保标志
			req.HedgeFlag = //必填;
			//价格
			//req.LimitPrice;
			//数量
			req.Volume; //必填
			///执行类型
			req.ActionType = THOST_FTDC_ACTP_Exec; //必填
			///保留头寸申请的持仓方向
			req.PosiDirection = THOST_FTDC_PD_Long; //必填
			///期权行权后是否保留期货头寸的标记
			req.ReservePositionFlag = THOST_FTDC_EOPF_UnReserve;//这是中金所的填法,大商所郑商所填THOST_FTDC_EOPF_Reserve
			///期权行权后生成的头寸是否自动平仓
			req.CloseFlag = THOST_FTDC_EOCF_AutoClose;//这是中金所的填法,大商所郑商所填THOST_FTDC_EOCF_NotToClose
			req.RequestID = reqInfo.nRequestID;
			
			ReqExecOrderInsert(&req, reqInfo.nRequestID);

三、执行宣告操作请求:(行权撤单)
CThostFtdcInputExecOrderActionField req = {0};
			strcpy(req.BrokerID,m_BrokerID);
			strcpy(req.InvestorID, m_InvestorInfos[reqInfo.lAccIdx].InvestorID);
			req.ExecOrderActionRef = m_nOrderActionRef++;
			req.ExecOrderRef; //指向行权委托的OrderRef
			req.RequestID = reqInfo.nRequestID;
			req.FrontID = //指向行权委托的FrontID;
			req.SessionID = //指向行权委托的SessionID;
			req.ExchangeID; //指向行权委托的市场ID
			req.ExecOrderSysID; //指向行权委托的OrderSysID
			req.ActionFlag = THOST_FTDC_AF_Delete;
			//req.LimitPrice =	
			//req.VolumeChange = 
			strcpy(req.UserID, m_UserID);
			req.InstrumentID; //指向行权委托的合约
			
			ReqExecOrderAction(&req,reqInfo.nRequestID);

四、行权的回应和推送

和前面下单的逻辑基本一直,请参考前面文章。

http://blog.csdn.net/zhangzq86/article/details/49585253



你可能感兴趣的:(金融,ctp,CTP开发)