Skip to main content

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


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.3.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

tendquant-1.1.3-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file tendquant-1.1.3.tar.gz.

File metadata

  • Download URL: tendquant-1.1.3.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.6

File hashes

Hashes for tendquant-1.1.3.tar.gz
Algorithm Hash digest
SHA256 c72cfb9c7cb08dc786f5cf45c489bf0f0f7a7ea1b7e1a6530215e1b1b44f13e6
MD5 6625c84bc49c74e2e76491771575fd22
BLAKE2b-256 7589dfe192e6b211fdec96392e485d09283b063e1bbb94b08fd5c5ee132690e9

See more details on using hashes here.

File details

Details for the file tendquant-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: tendquant-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.6

File hashes

Hashes for tendquant-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 49a2ea1bdf6f1f637dda6e8fd8e7e577c8c03e6cdb05f883b17c2455dc34b13f
MD5 a56cd1bb8794d206cad1e684e4c6f1fd
BLAKE2b-256 7abdd628dbc43bc87dc915d117c31def25b44cd2ca8a1e6cc8783cb75abbc1e7

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