Skip to main content

tendQuant

个人量化开发必备,快速获取A股全市场5000+股票和场内ETF的实时行情数据,基于 MQTT 协议提供实时、稳定、高效的行情数据推送服务,免费获取常见 A股 指数的实时行情数据。

官网链接:https://tendquant.cn

项目地址:https://github.com/top2189/tendQuant

功能特性

  • MQTTv5支持:默认使用MQTTv5协议
  • WebSocket支持:支持通过WebSocket协议连接
  • 简单API:简洁的订阅/取消订阅接口
  • 错误处理:详细的错误信息和处理机制

安装方法

pip install -U tendquant

使用示例

基本用法

from tendquant import Client

# 创建客户端实例
client = Client(
    username="a2dZMmrflhY4MwRN",
    password="6WUc6unvD4G3VVPx4K6t2Nl5mVq4fjtu",
)

# 连接到broker
client.connect()

# 订阅主题
client.subscribe("lv1/tradeList/000001")
client.subscribe("lv1/tradeList/600000")

# 取消订阅
client.unsubscribe("lv1/tradeList/000001")

# 断开连接
client.disconnect()

自定义消息处理器

from tendquant import Client
import json

def custom_on_message(client, userdata, msg):
    topic = msg.topic
    payload = msg.payload.decode('utf-8')
    data = json.loads(payload)
    print(f"收到消息: {topic} -> {data}")

# 创建客户端
client = Client(
    username="a2dZMmrflhY4MwRN",
    password="6WUc6unvD4G3VVPx4K6t2Nl5mVq4fjtu",
)

# 设置自定义消息处理器
client.client.on_message = custom_on_message

# 连接
client.connect()

CLI工具

Cli工具使用

# 订阅所有股票的五档盘口数据,“#” 表示订阅所有股票代码
tendquant -u a2dZMmrflhY4MwRN -p 6WUc6unvD4G3VVPx4K6t2Nl5mVq4fjtu -s lv1/orderBook/#

许可证

MIT License

贡献

欢迎贡献代码!请提交Pull Request。

Metadata

Release files for tendQuant 1.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tendQuant 1.1.8
File Size Uploaded
tendquant-1.1.8.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tendQuant 1.1.8
File Interpreter ABI Platform
tendquant-1.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 22.8 kB

Release files / tendquant-1.1.8.tar.gz

Download URL tendquant-1.1.8.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c3fcb6e1142aea1976541c31f2a005db53ea8bb19d1a18fcfc369ea6b98fd395
BLAKE2b-256 checksum
How to use checksums
01621cd6076cd9a4038a82669a66aea2aa4cb3af4d8e6b178eb7cba5e744946d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.6

Release files / tendquant-1.1.8-py3-none-any.whl

Download URL tendquant-1.1.8-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4179cb0554b7260b8dc4afc5d65a1c732e33adcddeaa5afbbef9003503377bc3
BLAKE2b-256 checksum
How to use checksums
c72d9be66b959dca52ec5e11796676213a52085f472722429700452038248997
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

1.1.8 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page