Giter Site home page Giter Site logo

leafyoung / ctpwrapper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nooperpudd/ctpwrapper

0.0 0.0 0.0 61.26 MB

上海期货交易所CTP接口 Shanghai Future CTP Interface CTP Python API Wrapper

License: Other

C++ 5.98% Python 40.85% C 30.99% Makefile 0.03% Batchfile 0.17% Cython 21.98% Dockerfile 0.01%

ctpwrapper's Introduction

CTP期货 API Python Wrapper

build action Build status Codacy Badge pypi status pyversion implementation Downloads

CTP Website

Version: v6.7.0

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

nooperpudd#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 [email protected]

ctpwrapper's People

Contributors

nooperpudd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.