CTP Quantitative Investment API Classification Summary Quick Reference Manual

CTP official API header file includes the following files:

  • ThostFtdcMdApi.h : Implements market-related subscription and reception functions. The Api class is responsible for initiating active requests, and the Spi response class is responsible for receiving request notifications and broadcast notifications.
  • ThostFtdcTraderApi.h : Implements transaction-related (buy, sell, close, etc.) order and query functions. The Api class is responsible for initiating active requests, and the Spi response class is responsible for receiving request notifications and broadcast notifications.
  • ThostFtdcUserApiDataType.h : Structure parameter definition of request function and callback function.
  • ThostFtdcUserApiStruct.h : Field type of structure parameters.
  • error.xml : Error ID and error description.

Only by clarifying the function definition, structure parameter definition, and field definition can the function be used correctly; only by matching the Api request with the Spi callback can the business process be processed correctly; only by knowing all the interrelated businesses can the most appropriate operation be selected.

Therefore, classification and summarization are essential tasks for understanding the CTP interface from a global perspective.

Due to space limitations, this article publishes the basic trading interfaces that traders are most concerned about. For more information, please view the " CTP Quantitative Investment API User Manual " ( www.ctp.plus/?/column/details/1 ).

Enter order

ask

///报单录入请求
int ReqOrderInsert(CThostFtdcInputOrderField *pInputOrder, int nRequestID) = 0;

response

///报单录入请求的响应
void OnRspOrderInsert(CThostFtdcInputOrderField* pInputOrder, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) {
    
    };
///报单录入请求错误的回报
void OnErrRtnOrderInsert(CThostFtdcInputOrderField* pInputOrder, CThostFtdcRspInfoField* pRspInfo) {
    
    };
///报单通知
void OnRtnOrder(CThostFtdcOrderField* pOrder) {
    
    };
///成交通知
void OnRtnTrade(CThostFtdcTradeField* pTrade) {
    
    };
///提示条件单校验错误
virtual void OnRtnErrorConditionalOrder(CThostFtdcErrorConditionalOrderField* pErrorConditionalOrder) {
    
    };

CThostFtdcInputOrderField
Insert image description here
CThostFtdcOrderField (略)
CThostFtdcTradeField (略)
CThostFtdcErrorConditionalOrderField (略)

Query order

ask

///查询报单请求
int ReqQryOrder(CThostFtdcQryOrderField *pQryOrder, int nRequestID) = 0;

response

///查询报单请求的响应
void OnRspQryOrder(CThostFtdcOrderField* pOrder, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) {
    
    };

CThostFtdcQryOrderField (omitted)

Check transaction

ask

///查询成交请求
int ReqQryTrade(CThostFtdcQryTradeField *pQryTrade, int nRequestID) = 0;

response

///查询成交请求的响应
void OnRspQryTrade(CThostFtdcTradeField* pTrade, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) {
    
    };

CThostFtdcQryTradeField (omitted)

Enter cancellation order

ask

///撤单录入请求
int ReqOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, int nRequestID) = 0;

response

///撤单录入请求的响应
void OnRspOrderAction(CThostFtdcInputOrderActionField* pInputOrderAction, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) {
    
    };
///撤单错误的回报
void OnErrRtnOrderAction(CThostFtdcOrderActionField* pOrderAction, CThostFtdcRspInfoField* pRspInfo) {
    
    };

CThostFtdcInputOrderActionField (略)
CThostFtdcOrderActionField (略)

Enter batch cancellation orders

ask

///批量撤单录入请求
int ReqBatchOrderAction(CThostFtdcInputBatchOrderActionField *pInputBatchOrderAction, int nRequestID) = 0;

response

///批量撤单录入请求的响应
virtual void OnRspBatchOrderAction(CThostFtdcInputBatchOrderActionField* pInputBatchOrderAction, CThostFtdcRspInfoField* pRspInfo, int nRequestID, bool bIsLast) {
    
    };
///批量撤单错误的回报
virtual void OnErrRtnBatchOrderAction(CThostFtdcBatchOrderActionField* pBatchOrderAction, CThostFtdcRspInfoField* pRspInfo) {
    
    };

CThostFtdcInputBatchOrderActionField (略)
CThostFtdcBatchOrderActionField (略)

Guess you like

Origin blog.csdn.net/AlgoPlus/article/details/102084652