CTP期货 API Python Wrapper
Version: v6.7.13
Platform: Linux 64bit, Windows 64bit
Python Requirement: x86-64
Especially Support PyPy3-3.6 Linux 64bit
Inspire By lovelylain
Install
Before you install ctpwrapper package, you need to make sure you have already install cython package.
>>>pip install cython --upgrade
>>>pip install ctpwrapper --upgrade
Donate [捐助]
⚠️⚠️ notice ⚠️⚠️
sometimes quote the market futures data, but there is no trading data from the API stream,
better just add time.sleep(2) func call after Init() method invoked, this could help to solve no data response issue.
Demo
sample code samples
issues
https://github.com/nooperpudd/ctpwrapper/issues/62 this is a temporary solution for the UnicodeDecodeError issue.
Traceback (most recent call last):
File "ctpwrapper/TraderApi.pyx", line 1402, in ctpwrapper.TraderApi.TraderSpi_OnRspQrySettlementInfo
File "/root/python/futures/trader_main.py", line 149, in OnRspQrySettlementInfo
print(pSettlementInfo.Content)
File "/root/python/futures/.venv/lib/python3.9/site-packages/ctpwrapper/base.py", line 28, in __getattribute__
return value.decode("gbk")
UnicodeDecodeError: 'gbk' codec can't decode byte 0xd2 in position 499: incomplete multibyte sequence
error_message = ""
def OnRspQryTradingAccount(self, pTradingAccount, pRspInfo, nRequestID, bIsLast):
print("OnRspQryTradingAccount")
print("nRequestID:", nRequestID)
print("bIsLast:", bIsLast)
print("pRspInfo:", pRspInfo)
print("pTradingAccount:", pTradingAccount)
# need to check is last message from the server.
global error_message
if not bIsLast:
error_message+=pRspInfo.ErrorMsg
else:
error_message+=pRspInfo.ErrorMsg
if isinstance(error_message,bytes):
error_message.decode("gbk")
Documentation
CTP documentation can be found in the docs
Contact
If you have any question about the ctpwrapper API, contact 365504029@qq.com
Metadata
Release files for ctpwrapper 6.7.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ctpwrapper-6.7.13.tar.gz | 8.2 MB | Without provenance | Details |
Release files / ctpwrapper-6.7.13.tar.gz
| Download URL | ctpwrapper-6.7.13.tar.gz |
|---|---|
| Size | 8.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
94be58b8360e26f6c3b57f5a991a6c5bdac0f7707234e41ceb69c42c006e778e
|
|
BLAKE2b-256 checksum How to use checksums |
b7d7ba4b0482f6182c5326089652773a4efaa41a09f5cdde4c815ac4f0871c42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for ctpwrapper 6.7.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.