Skip to main content

TianQin SDK2

Project description

TqSdk2 天勤量化交易策略程序开发包

TqSdk2 是一个由 信易科技 发起并贡献主要代码的, 采用 C++ 核心架构, 对外提供 python 和 C++ 接口的库.

依托 快期多年积累成熟的交易和行情服务器体系 和开源量化 python 库 TqSdk, TqSdk2 支持用户使用很少的代码量构建各种类型的量化交易策略程序, 并提供包含 历史数据-实时数据-开发调试-策略回测-模拟交易-实盘交易-运行监控-风险管理 的全套解决方案

  from tqsdk2 import TqApi, TqAuth, TqAccount, TargetPosTask

  api = TqApi(TqAccount("H海通期货", "4003242", "123456"), auth=TqAuth("信易账户", "账户密码"))      # 创建 TqApi 实例, 指定交易账户
  q_1910 = api.get_quote("SHFE.rb1910")                         # 订阅近月合约行情
  t_1910 = TargetPosTask(api, "SHFE.rb1910")                    # 创建近月合约调仓工具
  q_2001 = api.get_quote("SHFE.rb2001")                         # 订阅远月合约行情
  t_2001 = TargetPosTask(api, "SHFE.rb2001")                    # 创建远月合约调仓工具

  while True:
    api.wait_update()                                           # 等待数据更新
    spread = q_1910.last_price - q_2001.last_price        # 计算近月合约-远月合约价差
    print("当前价差:", spread)
    if spread > 250:
      print("价差过高: 空近月,多远月")                            
      t_1910.set_target_volume(-1)                              # 要求把1910合约调整为空头1手
      t_2001.set_target_volume(1)                               # 要求把2001合约调整为多头1手
    elif spread < 200:
      print("价差回复: 清空持仓")                               # 要求把 1910 和 2001合约都调整为不持仓
      t_1910.set_target_volume(0)
      t_2001.set_target_volume(0)

要快速了解如何使用TqSdk2 , 可以访问我们的 十分钟快速入门指南.

Features

TqSdk2 提供的功能可以支持从简单到复杂的各类策略程序.

  • 提供当前所有可交易合约从上市开始的 全部Tick数据和K线数据
  • 支持数十家期货公司的 实盘交易
  • 支持通过直连模式接入期货公司进行交易
  • 支持直连直连模式接入期货公司 CTP 柜台
  • 支持 模拟交易
  • 提供近百个 技术指标函数及源码
  • 用户无须建立和维护数据库, 行情和交易数据全在 内存数据库 , 无访问延迟
  • 优化支持 pandasnumpy
  • 无强制框架结构, 支持任意复杂度的策略, 在一个交易策略程序中使用多个品种的K线/实时行情并交易多个品种

Installation

TqSdk2 支持 Windows 和 Ubuntu 20.04 环境下 Python 3.6.4 及以上版本。

Windows

TqSdk2 核心代码依赖 C++ 运行库, 若您的环境中缺少该库, 可以到微软官网下载安装对应版本即可( vc_redist 下载地址).

推荐使用 pip 进行安装

$ pip install tqsdk2

Linux

TqSdk2 采用发布包遵循 PEP600 标准, 支持 Linux 发行版如下:

安装如下:

$ sudo apt update
$ sudo apt install -y build-essential
$ sudo apt install -y python3 python3-pip
$ sudo pip install pip --upgrade
$ sudo pip install tqsdk2

注: 国内用户使用 pip 进行 Python 包安装下载时, 默认采用的是国外镜像源, 下载速度可能较慢. 推荐切换至清华源 后再进行 TqSdk2 的下载安装.

Documentation

在线阅读HTML版本文档: https://doc.shinnytech.com/tqsdk2/latest

在线问答社区: https://www.shinnytech.com/qa

知乎账户【天勤量化】:https://www.zhihu.com/org/tian-qin-liang-hua/activities

用户交流QQ群: 619870862 (目前只允许给我们点过STAR的同学加入, 加群时请提供github用户名)

License

TqSdk2 在 Apache License 2.0 协议下提供, 使用者可在遵循此协议的前提下自由使用本软件.

About us

信易科技 是专业的期货软件供应商和交易所授权行情服务商. 旗下的快期系列产品已为市场服务超过10年.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

tqsdk2-1.9.5-cp39-cp39-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.9Windows x86-64

tqsdk2-1.9.5-cp39-cp39-manylinux_2_31_x86_64.whl (18.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.31+ x86-64

tqsdk2-1.9.5-cp38-cp38-win_amd64.whl (18.2 MB view details)

Uploaded CPython 3.8Windows x86-64

tqsdk2-1.9.5-cp38-cp38-manylinux_2_31_x86_64.whl (18.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.31+ x86-64

tqsdk2-1.9.5-cp37-cp37m-win_amd64.whl (18.2 MB view details)

Uploaded CPython 3.7mWindows x86-64

tqsdk2-1.9.5-cp37-cp37m-manylinux_2_31_x86_64.whl (18.8 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.31+ x86-64

tqsdk2-1.9.5-cp37-cp37m-manylinux_2_28_x86_64.whl (18.6 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.28+ x86-64

File details

Details for the file tqsdk2-1.9.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: tqsdk2-1.9.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 18.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tqsdk2-1.9.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 76e6111b883fe372bb3564957392ecf2dbd4e7f7a654d98b7abc85fae2f0dbb0
MD5 4614a329284672569460b991488280b3
BLAKE2b-256 744eb431bb978ce7a8239fd651b3c1dc24007a68bfd478206bb74d0122c5b207

See more details on using hashes here.

File details

Details for the file tqsdk2-1.9.5-cp39-cp39-manylinux_2_31_x86_64.whl.

File metadata

  • Download URL: tqsdk2-1.9.5-cp39-cp39-manylinux_2_31_x86_64.whl
  • Upload date:
  • Size: 18.8 MB
  • Tags: CPython 3.9, manylinux: glibc 2.31+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tqsdk2-1.9.5-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 79e082d7839c6809af55a8ccfe045568173cbed050b5100c12786aa8a72a8403
MD5 65ffa093e5c8da0329c412e0df2f28f1
BLAKE2b-256 c5f9f4d2a4fa8ebc3084df32eb61652035570d18338087c2f756bc4e759382e4

See more details on using hashes here.

File details

Details for the file tqsdk2-1.9.5-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: tqsdk2-1.9.5-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 18.2 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tqsdk2-1.9.5-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e0e43aa5fb8015f53cc4573e72103d8bd33c9a78eb266cc59c8b6fdf4a327374
MD5 afbedd3e8c48f74a46726617d6b77383
BLAKE2b-256 f04c0804039c5420efe411477a2d28da0eee20845bd30789b59562cc9584ce84

See more details on using hashes here.

File details

Details for the file tqsdk2-1.9.5-cp38-cp38-manylinux_2_31_x86_64.whl.

File metadata

  • Download URL: tqsdk2-1.9.5-cp38-cp38-manylinux_2_31_x86_64.whl
  • Upload date:
  • Size: 18.8 MB
  • Tags: CPython 3.8, manylinux: glibc 2.31+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tqsdk2-1.9.5-cp38-cp38-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 e7df34a4af9bb6fa87f8e8da1a6724d148ac522a0690f87ee578a7c6ca828007
MD5 6837f09f7f5916d0395227b0a919f2d0
BLAKE2b-256 ddc99ecba0245ccf150d80648911c874b3c3f71a5134d530694ec3761df67907

See more details on using hashes here.

File details

Details for the file tqsdk2-1.9.5-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: tqsdk2-1.9.5-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 18.2 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tqsdk2-1.9.5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 8b2beb10cb2a284546cf40481cf0148bcadfc321bed9a4f85e31509f6e00130f
MD5 771b4c07862543ae078873e1bda96e4d
BLAKE2b-256 2cce05f643aea46ec1b970638dd7ff31c54e403cabc6fd2606ecd483e38fcfb2

See more details on using hashes here.

File details

Details for the file tqsdk2-1.9.5-cp37-cp37m-manylinux_2_31_x86_64.whl.

File metadata

  • Download URL: tqsdk2-1.9.5-cp37-cp37m-manylinux_2_31_x86_64.whl
  • Upload date:
  • Size: 18.8 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.31+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tqsdk2-1.9.5-cp37-cp37m-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 27ac65073cf8273eba1b2f59d05359839ae9fbd5cc700e2507e4617c6142ff3a
MD5 64363b85de0b7413e16b23ba94d69760
BLAKE2b-256 c5d6aeb7e876df3ad877211abe2fc824832d479a15e16cf4143f29f9bc5aadab

See more details on using hashes here.

File details

Details for the file tqsdk2-1.9.5-cp37-cp37m-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: tqsdk2-1.9.5-cp37-cp37m-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 18.6 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for tqsdk2-1.9.5-cp37-cp37m-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76e5cc99594b9cac9ebba97bcd3fbb203a7a980d00ef5e69732176986bfd8c10
MD5 510d5ea72c937c611406766c01e36959
BLAKE2b-256 97a73facf20a4524c8ab077a410700a942167cf4b1c39ee55e1fb84136923a86

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