claudeers.
// Uncategorized / Others

tqsdk-python

天勤量化开发包, 期货量化, 实时行情/历史数据/实盘交易

// Uncategorized / Others[ api ][ claude ]#claude#diff#futures#program-trading#python#quant#tqsdk#uncategorized◷ Apache-2.0$open-sourceupdated about 1 month ago
Actively maintained
100/100
last commit 24 days ago
last release 24 days ago
releases 104
open issues 7
// star history

Install with your AI

Paste into Claude Code, Cursor, or any agent — it reads the repo and wires the tool into your project.

Install and set up tqsdk-python (release-binary project) into my current project.
Found on https://claudeers.com/tqsdk-python
Repo: https://github.com/shinnytech/tqsdk-python
Homepage/docs: https://doc.shinnytech.com/tqsdk/latest
Detected install method: release-binary → inspect the README
Category: uncategorized. Platforms: api.
Read the repo's README for exact setup and env vars, then install it and wire it into my project.

Claudeers Health Verdict:
active; community-verified: false. Confirm the source before running anything.
// or install directly (release-binary)

Grab the latest release asset from GitHub.

# download a build from https://github.com/shinnytech/tqsdk-python/releases
// or clone
git clone https://github.com/shinnytech/tqsdk-python

// compatibility

Platformsapi
Operating systems—
AI compatibilityclaude
LicenseApache-2.0
Pricingopen-source
LanguagePython

Get your FREE $2.50 API credits to access TickAtlas financial data ↗

tqsdk-python

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

TqSdk 是一个由信易科技发起并贡献主要代码的开源 Python 库。 TqSdk 支持用户使用极少的代码量构建各种类型的量化交易策略程序, 并提供包含期货、期权、股票的 历史数据-实时数据-开发调试-策略回测-模拟交易-实盘交易-运行监控-风险管理 全套解决方案。

快速开始

from tqsdk import TqApi, TqAuth, TqAccount, TargetPosTask

api = TqApi(TqAccount("H海通期货", "4003242", "123456"), auth=TqAuth("快期账户", "账户密码"))      # 创建 TqApi 实例, 指定交易账户
q_2610 = api.get_quote("SHFE.rb2610")                         # 订阅近月合约行情
t_2610 = TargetPosTask(api, "SHFE.rb2610")                    # 创建近月合约调仓工具
q_2701 = api.get_quote("SHFE.rb2701")                         # 订阅远月合约行情
t_2701 = TargetPosTask(api, "SHFE.rb2701")                    # 创建远月合约调仓工具

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

要快速了解如何使用TqSdk,请访问我们的 十分钟快速入门指南。

系统架构

系统架构图
  • 行情网关负责提供实时行情和历史数据
  • 交易中继网关负责连接到期货公司交易系统
  • 这两个网关统一以Diff协议对下方提供服务
  • TqSdk按照Diff协议连接到行情网关和交易中继网关,实现行情和交易功能

主要功能特点

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

  • 公司级数据运维,提供当前所有可交易合约从上市开始的全部Tick数据和K线数据

  • 多账户支持,支持使用多个实盘账户、模拟账户同时交易

  • 支持市场上90%的期货公司实盘交易

  • 支持股票、期权、期货交易

  • 支持CTP直连交易,以及众期、融航、杰宜斯等资管柜台,易达、ctpmini 等高速柜台

  • 支持模拟交易

  • 支持Tick级和K线级回测,支持复杂策略回测

  • 提供近百个技术指标函数及源码

  • 用户无须建立和维护数据库,行情和交易数据全在内存数据库,无访问延迟

  • 优化支持pandas和numpy库,方便数据分析

  • 灵活的策略编写方式,无强制框架结构,支持任意复杂度的策略,在一个交易策略程序中使用多个品种的K线/实时行情并交易多个品种

  • 配合天勤AI助手,提供函数解释、策略编写指导、错误分析等支持

配合 AI / Agent 使用 TqSdk

如果你想让自己的 AI、Agent 或 OpenClaw 更好地理解和使用 TqSdk,可以把下面这段内容直接复制给它:

请先下载并解压 TqSdk 技能包:https://doc.shinnytech.com/tqsdk/latest/ai_editor/skills/tqsdk-trading-and-data.zip,然后先阅读其中的 SKILL.md,并按里面的说明再回答任何 TqSdk 问题或编写任何 TqSdk 代码。

相关文档与资源:

安装方法

TqSdk 仅支持 Python 3.9 及更高版本。要安装 TqSdk,可使用 pip:

pip install tqsdk

文档与社区支持

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

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

天勤AI助手:https://www.shinnytech.com/products/tqsdk - 解释函数,编写demo策略,分析报错原因,它都可以做到!

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

关于我们

信易科技 是专业的期货软件供应商和交易所授权行情服务商。旗下的快期系列产品已为市场服务超过10年。TqSdk 是公司开源计划的一部分。

// faq

What is tqsdk-python?

天勤量化开发包, 期货量化, 实时行情/历史数据/实盘交易. It is open-source on GitHub.

Is tqsdk-python free to use?

tqsdk-python is open-source under the Apache-2.0 license, so it is free to use.

What category does tqsdk-python belong to?

tqsdk-python is listed under uncategorized in the Claudeers registry of Claude-compatible tools.

16 views
★ 5,146 stars
unclaimed
updated about 1 month ago

// embed badge

tqsdk-python on Claudeers
[![Claudeers](https://claudeers.com/api/badge/tqsdk-python.svg)](https://claudeers.com/tqsdk-python)

// retro hit counter

tqsdk-python hit counter
[![Hits](https://claudeers.com/api/counter/tqsdk-python.svg)](https://claudeers.com/tqsdk-python)

// reviews

// guestbook

0/500

// related in Uncategorized / Others

🔓

Reverse engineer anything with agents, from app behavior down to native binaries.

// uncategorizedmorluto/⟨TypeScript⟩★ 423,040◷ MIT[ claude ]
🔓

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

// uncategorizedn8n-io/⟨TypeScript⟩★ 209,482◷ NOASSERTION[ claude ]
🔓

The agent engineering platform.

// uncategorizedlangchain-ai/⟨Python⟩★ 148,973◷ MIT[ claude ]
🔓

100+ AI Agent & RAG apps you can actually run — clone, customize, ship.

// uncategorizedShubhamsaboo/⟨Python⟩★ 144,747◷ Apache-2.0[ claude ]

// built by

→ see how tqsdk-python connects across the ecosystem