GithubHelp home page GithubHelp logo

pyctp

ctp wrapper for python

简介

(仅仅只是)对于CTP API的Python封装(使用时遇到问题可以在Issues中反馈,但不要咨询实际的交易事项,因为我没实践过╮(╯_╰)╭

CTP版本:futures目录是期货版(包括win32、linux32、linux64),option目录是期权版(包括win32、linux32、linux64),stock目录是linux64股票版,stock2目录是win32股票版

环境:python2.5 ~ python3.4,Windows或者Linux

编译:在本目录或者分别进入futures、option、stock/stock2目录执行python setup.py build

安装: 在本目录编译后复制build/lib.xxx-x.x目录下的ctp目录到site-packages目录:

# 通过以下方式使用期货版API
from ctp.futures import ApiStruct, MdApi, TraderApi
# 通过以下方式使用股票版API
from ctp.stock import ApiStruct, MdApi, TraderApi

或者进入futures或option、stock/stock2子目录python setup.py build编译后python setup.py install安装:

# 通过以下方式使用期货/股票版API
from ctp import ApiStruct, MdApi, TraderApi

推荐使用第一种方式。

关于代码风格

本项目只是对于CTP api的封装,大部分代码是生成并非手写,api是给人用而不是给人欣赏内部如何实现的,实用性才是第一考虑:

  • 一套代码支持Python2.5 ~ Python3.x多个版本,直接python setup.py build即可编译,不强求特定Python版本或者复杂配置;
  • 干净的模块空间,除了__author__、__version__等特殊Python变量,模块中其他变量与API头文件中的符号一一对应;
  • 简洁清晰的注释,每个函数、枚举、typedef、结构体的注释都与API头文件一致,并且标明结构体每个成员的实际基础类型;
  • 结构体和函数参数支持IDE自动补全,并且自动补全时可知道每个参数是字符串、int还是float类型,默认值与提示值一致。

如何配合原版pyctp使用

  • 如果在Windows下使用,首先需要安装与Python对应的VS,例如Python2.6 ~ Python3.2可以安装一个VC++ 2008 Express;如果在Linux下使用,安装好GCC;
  • 在本目录执行python setup.py build进行编译;
  • 编译后复制build/lib.xxx-x.x目录下的ctp目录到example目录下(如果使用Windows + Python2.7,这3步都可以跳过,因为example目录下已有的ctp就是这个环境下编译的);
  • 按照原版pyctp的配置说明对example/config目录下的文件进行配置;
  • 通过example/main.py加参数运行。

通过以上步骤可知,这里基本上只是对原版安装指南进行了替换;

Windows下除了编译需要安装VC++ 2008 Express外,直接使用已编译好的貌似是不需要安装的。

pyctp's Projects

actions-openwrt icon actions-openwrt

A template for building OpenWrt with GitHub Actions | 使用 GitHub Actions 云编译 OpenWrt

agentgpt icon agentgpt

🤖 Assemble, configure, and deploy autonomous AI Agents in your browser.

akshare icon akshare

AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库

apt-fast icon apt-fast

apt-fast: A shellscript wrapper for apt that speeds up downloading of packages.

autobuild-openwrt icon autobuild-openwrt

Build OpenWrt using GitHub Actions | 使用 GitHub Actions 编译 OpenWrt | 感谢P3TERX的项目源码|感谢KFERMercer的项目源码

awesome-data icon awesome-data

Awesome-data shows most interesting data-source around the financial world!

book icon book

个人认为对技术提升很不错的书

charlesscripts icon charlesscripts

My awesome scripts for Arch Linux or Ubuntu Gnome latest LTS or MacBook.

ctpwrapper icon ctpwrapper

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

cursor icon cursor

An editor made for programming with AI 🤖

deeplearning icon deeplearning

深度学习入门教程, 优秀文章, Deep Learning Tutorial

fujisaki icon fujisaki

An ongoing (fast prototyping) project to create your own doppelgänger based on your Twitter archive and LoRA+Alpaca

fushare icon fushare

A utility for fundamentals data of China commodity futures

gost icon gost

GO Simple Tunnel - a simple tunnel written in golang

hf_ctp_py_proxy icon hf_ctp_py_proxy

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

hist icon hist

The source code and data of the paper "HIST: A Graph-based Framework for Stock Trend Forecasting via Mining Concept-Oriented Shared Information".

mlc-llm icon mlc-llm

Enable everyone to develop, optimize and deploy AI models natively on everyone's devices.

onepy icon onepy

Python Backtesting library for OnePiece in trading.

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.