Skip to main content

TianQin SDK

Project description

TqSdk 是一套依托 DIFF协议 (Differential Information Flow for Finance) 的开源 python 框架. 它支持用户使用较少的工作量构建量化交易或分析程序.

与其它 python 框架相比, TqSdk 致力于在以下几方面为用户提供价值:

  1. 用最低部署运行成本实现完整功能栈

    • 无需用户部署维护历史数据库, 直接提供所有期货品种的报价盘口, K线数据, Tick序列的实时推送

    • 支持通过CTP接口发送交易指令

  2. 鼓励 Quick & Simple 的用户代码风格

    • 策略代码按线性逻辑编写, 避免复杂的回调函数/状态机

    • 策略运行中用到的所有数据都在内存中, 且不需读写锁, 避免读写过程引入延时

    • 所有行情及交易接口都返回 object refrence, 一次调用获取, 内容可自动更新

    • 统一易用的超时及异常管理机制

  3. 可通过搭配天勤终端为用户代码提供支持, 避免用户在非核心功能上花费时间精力

    • 通过历史复盘及模拟交易功能, 将用户程序带回特定历史环境测试

    • 在天勤终端中构建自定义组合, 并获得组合的报价和K线数据

    • 提供委托单/成交/持仓情况监控的UI界面

TqSdk 主要包括的组件如下:

  • api: 一个结合了网络通讯和全内存数据管理的接口, 提供了基础的行情和交易功能

  • lib: 基于api构建的常用功能函数库(例如: 目标持仓模型)

  • sim: 提供模拟交易功能, 并可输出交易报告

  • backtest.py: 提供回测功能, 支持逐tick回测

Install

系统要求:

  • Windows 或 Linux

  • Python 3.6+

直接使用pip安装:

pip install tqsdk

或从github下载 tqsdk:

git clone https://github.com/shinnytech/tqsdk-python.git
python setup.py install

另外如果希望使用自定义组合, 历史复盘等 天勤终端 提供的功能, 可以参见: 与天勤终端配合工作

Run

运行demo目录下的任一程序:

python demo/tutorial/t10.py

注意: TqSdk 使用了 python3 的原生协程和异步通讯库 asyncio,部分 IDE 不支持 asyncio,例如:

可以直接运行示例代码(例如: “python demo/tutorial/t10.py”),或使用支持 asyncio 的 IDE (例如: pycharm)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tqsdk-0.9.1.tar.gz (69.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tqsdk-0.9.1-py3-none-any.whl (86.1 kB view details)

Uploaded Python 3

File details

Details for the file tqsdk-0.9.1.tar.gz.

File metadata

  • Download URL: tqsdk-0.9.1.tar.gz
  • Upload date:
  • Size: 69.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for tqsdk-0.9.1.tar.gz
Algorithm Hash digest
SHA256 3c998c1f1d9d3abe50d462f57be32d7f4eda2f04219b0b0436bd9bbfd48f8bc7
MD5 37a09b6fb5e38cf5a93ed041638b5029
BLAKE2b-256 c31523b69d3d13338740ffdc6d57b1972336318e15806feb818643e971bd6429

See more details on using hashes here.

File details

Details for the file tqsdk-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: tqsdk-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 86.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for tqsdk-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 184f6523da7edc0e504d6f4e032d774e51cf73acabe97b4e4e9502ab9c5ae4f4
MD5 62b7934b7ac58fdf8656ab64bb7f3a9e
BLAKE2b-256 aa10ffd99549a68271242cdbe31be7eb6e070067b99d63419ed2b959abc854ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page