A MQTT client library for tendQuant
Project description
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。
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
tendquant-1.1.7.tar.gz
(10.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
tendquant-1.1.7-py3-none-any.whl
(11.5 kB
view details)
File details
Details for the file tendquant-1.1.7.tar.gz.
File metadata
- Download URL: tendquant-1.1.7.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf25e91959c2260238f19124dce02ddc09e16fe7939b9ed00ec8d3433f15bd77
|
|
| MD5 |
69e231d222778ef8559bacacc50a2d83
|
|
| BLAKE2b-256 |
9ee4ffabd7ea88e7458c7d3adff2dc6461db00a0cc8d6bcc5fafe9def2207c15
|
File details
Details for the file tendquant-1.1.7-py3-none-any.whl.
File metadata
- Download URL: tendquant-1.1.7-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad06c957316fced032895d65cdc1c2821ebe75e63eb31739680a2c40716e1c62
|
|
| MD5 |
37166971405b1b0857a6755c42168336
|
|
| BLAKE2b-256 |
2d71e6be6c0f38c98cef23375913bffbcbf36e21018ba885ca10b51bd7f27d3f
|