ctp穿透测试过程记录

以冠通期货为例子(windows11):

根据期货经理发过来的文档进行申请即可:https://mp.weixin.qq.com/s/L5p5QiPj61WGzd2dcEsccA

在贯通期货app里面有个“掌厅 –> 外部信息系统接入申请”

按要求填写,或者直接按照文档中的示例填写,完成后需要阅读四个协议并署名。然后等待审核

这期间你可以准备ctptest软件,这里使用vnpy,去其官网下载并进行安装,安装过程需要python环境,可以使用conda

官网有两种安装方式,如果选择手动安装则在安装结束后再手动安装 pip install vnpy_ctptest

见:https://toscode.gitee.com/vnpy/vnpy_ctptest/

在vnpy的 vnpy-3.6.0\examples 目录下创建一个veighna_cpttest目录并在其中创建一个run.py文件,内容如下:

from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp

from vnpy_ctptest import CtptestGateway


def main():
    """主入口函数"""
    qapp = create_qapp()

    event_engine = EventEngine()
    main_engine = MainEngine(event_engine)
    main_engine.add_gateway(CtptestGateway)
    
    main_window = MainWindow(main_engine, event_engine)
    main_window.showMaximized()

    qapp.exec()


if __name__ == "__main__":
    main()

然后使用 python ./run.py 就能运行了。

审核通过后期货经理就会把申请得到的一些信息发给你,对应填写在vnpy的ctptest软件上,得到的信息如下

由于它们的系统要求api版本必须为6.3.13_T4,故我这里需要做替换掉原来的dll和lib

https://files.woyou.cool/s/3fcTEoCx6PDZFRs

找到vnpy_ctptest包的路径,例如我这里是“C:\Users\zouhe.conda\envs\vnpy\Lib\site-packages\vnpy_ctptest\api”,将原来的dll删除或重命名,并将需要的版本拷贝进来

然后点击vnpy的连接按钮,左下角就能看到验证成功的信息

参考:

https://www.vnpy.com/forum/topic/603-kan-wan-zhe-pian-che-di-gao-ding-qi-huo-chuan-tou-shi-ctp-apijie-ru

Leave a Comment