1 Star 0 Fork 61

疯子 / pyctp

forked from 海风 / pyctp 
加入 Gitee
与超过 1000 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md

hf_ctp_py_proxy

上期技术期货交易 api 之 python 封装,实现接口调用。支持 windows linux.

环境需求

  • VS2017
  • python 3.6+

使用说明

  • 运行 pyton generate\\run.py 生成所有文件
  • C++编译
    • Windows
      • 环境要求 vs2017
      • 设置项目为 x64,否则会提示找不到 windows.h
      • 打开 ctp_c\ctp.sln
      • 编译 ctp_quote 和 ctp_trade 项目
      • 编译后生成的 dll 放在 py_ctp/lib64 目录下
    • Linux
      • 设置系统语言为:zh_CN.UTF-8
      • 执行以下指令, -Wl,rpath=指定 so 路径(需要与 setup.py 中的 data_files 配合使用)
        • export VERSION=v6.5.1
          1. 代码生成
            pip3 uninstall py-ctp -y && python generate/run.py $VERSION
          2. 编译 so
            cd py_ctp/lib64 && \
            \cp ../../$VERSION/lnx/*.so . \
            && g++ -shared -fPIC -Wl,-rpath . -o ./ctp_trade.so ../../ctp_c/trade.cpp thosttraderapi_se.so \
            && g++ -shared -fPIC -Wl,-rpath . -o ./ctp_quote.so ../../ctp_c/quote.cpp  thostmduserapi_se.so \
            && cd ../..
          3. 测试
            sed -i "s#version=.*#version='$VERSION.`date '+%Y%m%d'`',#g" setup.py && \
            python setup.py install && python test_trade.py
          4. 上传
            pip install wheel twine setuptool setuptools_rust
            python setup.py sdist && twine upload -u haifengat dist/*$VERSION.`date '+%Y%m%d'`*.gz && \
            python setup.py bdist_wheel && twine upload -u haifengat dist/*$VERSION.`date '+%Y%m%d'`*.whl

更新

20201104

更新:接口更新到 6.3.15;不再支持 32 位; 解决 lnx 下 so 路径问题;解决合约过多导致的 bug;

20210115

更新:接口更新到 6.5.1;大商所非交易合约数量庞大导致的问题。

20220504

更新: 重新编译封装的 C 接口, trade 登录不再需要 productInfo

简介

上期技术期货交易api之python封装,实现接口调用。支持windows linux x64. 展开 收起
Python
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/abcda/pyctp.git
git@gitee.com:abcda/pyctp.git
abcda
pyctp
pyctp
master

搜索帮助

10d9f8b4 4838521 8bde8327 4838521