使用ctp的python接口


在github上查到一個項目
ctpwrapper

在按照文檔按照的時候報錯

>>>pip install cython --upgrade
>>>pip install ctpwrapper --upgrade

在安裝第二個命令的時候

第一個問題

安裝yum install -y gcc-c++ 解決

第二個問題
ctpwrapper/MdApi.cpp:39:20: 致命錯誤:Python.h:沒有那個文件或目錄

查找問題,需要python的dev文件 沒有正確安裝pythondev的頭文件和靜態庫
下載對應的python包的dev

為apt (烏本圖Debian.。):
sudo apt-get install python-dev   # for python2.x installssudo apt-get install python3-dev  # for python3.x installs
為yum (CentOS,RHEL.。):
sudo yum install python-devel   # for python2.x installssudo yum install python34-devel   # for python3.4 installs
為dnf (軟呢帽.。):
sudo dnf install python2-devel  # for python2.x installssudo dnf install python3-devel  # for python3.x installs
為zypper (開誠布公.。):
sudo zypper in python-devel   # for python2.x installssudo zypper in python3-devel  # for python3.x installs
為apk (阿爾卑斯山.。):
# This is a departure from the normal Alpine naming# scheme, which uses py2- and py3- prefixessudo apk add python2-dev   # for python2.x installssudo apk add python3-dev  # for python3.x installs
為apt-cyg (西格溫.。):
apt-cyg install python-devel   # for python2.x installsapt-cyg install python3-devel  # for python3.x installs

如果需要用最新的上期api,可使用項目中的setup文件中心生成,生成的ctpwrapper替換到site-package下的文件即可使用,請求方法會調用原生的api,響應的返回可以根據自己的需要進行定制,
需要注意的點,在請求與返回之間最好加上time.sleep,


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM