界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
数据与研究 · SKILL.md

market-data

market-data

【数据与研究】Fetches and processes real-time and historical stock market data from TDX protocol servers. Provides K-line data at multiple intervals, real-time quotes, and market overviews. Trigger when the user requests stock prices, market data, or financial instrument data.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: market-data description: Fetches and processes real-time and historical stock market data from TDX protocol servers. Provides K-line data at multiple intervals, real-time quotes, and market overviews. Trigger when the user requests stock prices, market data, or financial instrument data. metadata: hermes: tags: [market-data, tdx, stock, kline, quotes] category: trading requires_toolsets: [terminal]

Market Data

Fetches stock market data from TDX (通达信) protocol servers.

Real Code Reference

  • tradinglearn/pytdx2/client/quotationClient.py — QuotationClient with get_KLine_data(), get_security_quotes(), etc.
  • tradinglearn/pytdx2/client/baseStockClient.py — BaseStockClient socket layer with auto-retry
  • tradinglearn/pytdx2/const.py — MARKET, CATEGORY, PERIOD enums, 43+ server hosts

Capabilities

  • Real-time quotes: get_security_quotes() / get_security_quotes_details() (with 5-level depth)
  • K-line (OHLCV) data: get_KLine_data(market, code, period, start, count) — 1min to yearly
  • Market categories: Shanghai A, Shenzhen A, Growth Enterprise, Beijing A; futures, options, HK stocks
  • Market overview: get_top_stock_board(category) — top gainers/losers/amplitude, get_index_info()

Typical Workflow

from pytdx2.client.quotationClient import QuotationClient
from pytdx2.const import MARKET, PERIOD

client = QuotationClient()
client.connect().login()
# Daily K-line for 平安银行
klines = client.get_KLine_data(MARKET.SZ, "000001", PERIOD.DAY, start=0, count=800)
# Real-time quotes for a batch
quotes = client.get_security_quotes(["000001", "000002"])
client.disconnect()

Notes

  • K-line prices divided by 1000; quote prices divided by 100
  • Always call client.disconnect() — sockets leak otherwise
  • data_fetcher.py wraps this with retry logic and DataFrame normalization
我的收藏