CTP穿透式监管怎么实现代码, 穿透测试API

    xiaoxiao2023-11-09  152

    做量化交易的朋友都支持,2019年6月要开始实行穿透式监管了, 老的代码可能不再能够接入,那么如何将老的CTP程序实现升级到穿透式监管呢?本文就讲一下修改的方法。(1)先替换为最新的CTP api CTP API下载地址http://www.simnow.com.cn/static/softwareDownload.action

     

     

     

    百度 搜索 “VNPY学习资料全集”,前三行可以找到详细教程导航

    http://www.vnpy.top

     

     

     

    附带宏源期货开户和CTP穿透式接入步骤、申请表http://www.kaihucn.cn/comm/topic/1882/

    同时免费提供期货APP下单掌上宏源https://mp.weixin.qq.com/s/j_xLax6qM74dcUlM2jZCww

    主要涉及以下2个方法

    ///客户端认证响应 virtual void OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; ///客户端认证请求 virtual int ReqAuthenticate(CThostFtdcReqAuthenticateField *pReqAuthenticateField, int nRequestID) = 0;

    这2个方法分别是:客户端认证请求,客户端认证响应

    (2)代码方面的修改:

    之前大家做CTP都需要调用ReqUserLogin();这个登录请求,现在如果要接入穿透式监管的流程改变了,请将ReqUserLogin();替换为ReqAuthenticate(CThostFtdcReqAuthenticateField *pReqAuthenticateField, int nRequestID) 认证请求,然后在认证回调里添加ReqUserLogin();

    简单的说代码修改流程即为: 先认证再登录 1.把以前登录请求替换为认证请求 2.就是把登录请求放到认证回调里

    向期货公司申请获得信息 在认证请求的结构体定义如下:

    ///客户端认证响应 struct CThostFtdcRspAuthenticateField { ///经纪公司代码 TThostFtdcBrokerIDType BrokerID; ///用户代码 TThostFtdcUserIDType UserID; ///用户端产品信息 TThostFtdcProductInfoType UserProductInfo; ///App代码 TThostFtdcAppIDType AppID; ///App类型 TThostFtdcAppTypeType AppType; };

    (3)认证的函数定义

    ReqAuthenticate(UserProductInfo, AuthCode); void CTraderSpi::ReqAuthenticate(const char *UserProductInfo,const char *AuthCode) { if(pUserApi[accountid] == NULL ){return;} //认证码 CThostFtdcReqAuthenticateField pReqAuthenticateField; memset(&pReqAuthenticateField, 0, sizeof(CThostFtdcReqAuthenticateField)); strcpy(pReqAuthenticateField.BrokerID, BROKER_ID); strcpy(pReqAuthenticateField.UserID, INVESTOR_ID); strcpy(pReqAuthenticateField.UserProductInfo, UserProductInfo); //产品标识 strcpy(pReqAuthenticateField.AuthCode, AuthCode); //认证码 int iResult = pUserApi[accountid]->ReqAuthenticate(&pReqAuthenticateField, ++iRequestID); cerr << "--->>> 发送认证请求: " << ((iResult == 0) ? "成功" : "失败") << endl; }

    其中产品信息UserProductInfo、AppID、AppType 需要通过咨询期货公司获得。

    《Quicklib程序化交易框架www.quicklib.cn》http://www.mdshare.cn/comm/topic/2750/《期货跟单软件视频教学4集》《开户中国期货低佣金开户》《mdshare财经数据接口包》《QuicklibTrade A股行情接口,Level2接口》

    python量化交易

    http://www.coolquant.cn/python3.0量化交易书籍推荐

    《优秀量化资源导航》《TradeApi A股程序化交易接口》《酷操盘手期货跟单软件》

    Quicklib 下载地址http://www.quicklib.cn/ 期货行情数据下载地址http://www.mdshare.cnhttp://www.pythonpai.com/topic/4206/ 免费商品期货股指期货跟单系统和资管系统http://www.kucps.com/ 参考代码打包下载http://mdshare.cn/source.zip 期货低佣金开户 ,期货低佣金开户步骤(交易所标准+1分,交反40%~90%)http://www.kaihucn.cn/

    vn.py

    最新回复(0)