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.0.tar.gz (10.8 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.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tendquant-1.1.0.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

Hashes for tendquant-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7657bb4f3c562cd533c10ad005a2f2b5b00cda951e7df04ffb5c2055b00f5efd
MD5 d2e170a77f399729f926d2be7624f94b
BLAKE2b-256 d9799e97a24aea0d7e73d433a5bf4c40dfc014869ab8479929b85f5904a6f1f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tendquant-1.1.0-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

Hashes for tendquant-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b403ce16fe45bbb63480f3e5e7ebf9fdce8ea2660f05f605d3336ce21ce81a1
MD5 807e7cb94b9038f89575af14b09bc9df
BLAKE2b-256 11880946173544aafc2a33346c66ffb005b8460a18eac00556d46a60d2eeab62

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