taktiko

Free A Share Real Time Data

数据分析v1.0.1
作者:taktiko更新于 2026-05-11free-a-share-real-time-data@clawhub_wangdinglu/free-a-share-real-time-data
数据洞察网页抓取#Stock Market

据 AlphaMoat 统计,截至 2026-09,Free A Share Real Time Data 累计下载 2,627 次、获 1 个星标,在全部 5,078 个 AI 技能中排名第 4,003 位,在「数据分析」分类(399 个)中排名第 302 位。

累计安装
218
累计下载
2,627
星标
1
全站排名
#4,003
全站前 79% · 「数据分析」前 76%
平台累计安装累计下载星标评论
ClawHub ↗682,4161-
SkillHub ↗2182,6271—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

该技能封装 mootdx/TDX 协议,可查询中国 A 股历史或实时 K 线、单只或批量实时报价,以及逐笔交易记录。调用前需考虑北京时间交易时段、交易日历和股票代码格式;文档明确指出该库不支持北京证券交易所股票,使用时应先过滤这些代码。它提供数据查询与调用示例,不构成投资建议。

资料发布于 2026-10-27

可以用来做什么

  • 获取 A 股 K 线与报价数据
  • 查看逐笔交易记录并处理代码格式限制

什么时候用

  • 需要通过 mootdx/TDX 查询 A 股行情数据时
  • 使用包含不同交易所代码的数据前需要过滤不支持的股票时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

用 mootdx 获取这只 A 股的实时报价
按文档说明查询历史 K 线并排除不支持的股票代码

月度数据趋势

累计下载2,627
1,0281,8872,7452026-03 · 累计下载 1,1462026-05 · 累计下载 1,5962026-06 · 累计下载 1,7922026-07 · 累计下载 2,0962026-08 · 累计下载 2,2772026-09 · 累计下载 2,62726-0326-09
星标1
0122026-03 · 星标 12026-05 · 星标 12026-06 · 星标 12026-07 · 星标 12026-08 · 星标 12026-09 · 星标 126-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-092,627—1
2026-082,277+8.6%1
2026-072,096+17.0%1
2026-061,792+12.3%1
2026-051,596—1
2026-031,146—1

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

8.1 KB · ClawHub v1.0.1
---
name: mootdx-china-stock-data
description: Fetch China A-share stock market data (bars, realtime quotes, tick-by-tick transactions) via mootdx/TDX protocol. Use when working with Chinese stock data, mootdx library, TDX quotes, intraday minute bars, transaction history, or real-time A-share market data.
---

# Mootdx China A-Share Stock Data Client

A wrapper around the `mootdx` library (TDX protocol) for fetching China A-share market data including K-line bars, real-time quotes, and tick-by-tick transaction records.

## Installation
展开全部(共 283 行)

```bash
pip install mootdx
```

> `mootdx` depends on `tdxpy` internally. Both are installed together.

### Verify & Demo

```bash
python scripts/setup_and_verify.py           # Install + verify + connectivity test
python scripts/setup_and_verify.py --check   # Verify only (skip install)
python scripts/setup_and_verify.py --demo    # Full API demo with real output
```

The `--demo` mode exercises every major API and prints real data — useful as a runnable reference for correct calling patterns.

## Critical: Time & Timezone Considerations

### Trading Hours (Beijing Time, UTC+8)

| Session | Time |
|---------|------|
| Morning | 09:30 - 11:30 (120 min) |
| Lunch break | 11:30 - 13:00 |
| Afternoon | 13:00 - 15:00 (120 min) |
| **Total** | **240 trading minutes/day** |

### Trading Time Bypass Patch

**Problem**: `mootdx` / `tdxpy` has a built-in `time_frame()` check that blocks API calls outside trading hours. On servers with non-Beijing timezone, this breaks even during valid trading hours.

**Solution**: Monkey-patch `tdxpy.hq.time_frame` to always return `True`:

```python
import tdxpy.hq
tdxpy.hq.time_frame = lambda: True
```

This patch is applied automatically during `MootdxClient.__init__()`. Without it, `transactions()` and `transaction()` calls will silently return empty results outside detected trading hours.

### Trading Calendar

When querying historical data, always check if a date is a trading day. Non-trading days (weekends, holidays) have no data. The client uses `TradingCalendarStrategy.is_trading_day(date_str)` for this — you must have a trading calendar service available.

### Date/Time Parameter Formats

| Parameter | Format | Example |
|-----------|--------|---------|
| `date` | `YYYYMMDD` | `"20250210"` |
| `time` | `HH:MM:SS` or `HH:MM` | `"10:30:00"` or `"10:30"` |

## Stock Code Format

mootdx uses **pure numeric codes** (TDX format). Convert from standard format:

| Standard Format | TDX Format | Market |
|----------------|------------|--------|
| `000001.SZ` | `000001` | Shenzhen |
| `600300.SH` | `600300` | Shanghai |
| `300750.SZ` | `300750` | Shenzhen (ChiNext) |
| `688001.SH` | `688001` | Shanghai (STAR) |

**Conversion**: Strip the `.SH` / `.SZ` / `.BJ` suffix.

> **Important**: mootdx does NOT support Beijing Stock Exchange (`.BJ`) stocks. Filter them out before calling.

## API Reference

### 1. Initialize Client

```python
from mootdx.quotes import Quotes
client = Quotes.factory(market='std')
```

### 2. `get_bars()` — K-Line / Candlestick Data

Fetch historical or real-time K-line bars.

```python
await client.get_bars(
    stock_code="000001.SZ",   # Standard format (auto-converted)
    frequency=7,               # K-line period (see table below)
    offset=240,                # Number of bars to fetch
    date="20250210",           # Optional: specific date (YYYYMMDD)
    time="10:30:00",           # Optional: specific time (HH:MM:SS)
    filter_by_time=True        # Filter to closest bar matching time
)
```

**Frequency codes:**

| Code | Period |
|------|--------|
| 7 | 1-minute bars |
| 8 | 1-minute bars (alternative) |
| 4 | Daily bars |
| 9 | Daily bars (alternative) |

**Return format** (list of dicts):

```python
{
    "stock_code": "000001.SZ",
    "datetime": "2025-02-10 10:30:00",
    "open": 12.50,
    "high": 12.65,
    "low": 12.45,
    "close": 12.60,
    "vol": 150000.0,
    "amount": 1890000.0
}
```

**Start position calculation**: For historical dates, the `start` parameter is calculated as the number of trading minutes (for 1-min bars) or trading days (for daily bars) between now and the target datetime. This accounts for:
- Whether today is a trading day
- Current trading session status (pre-market / in-session / post-market)
- Lunch break gap (11:30-13:00)

### 3. `get_realtime_quote()` — Single Stock Real-Time Quote

```python
await client.get_realtime_quote(stock_code="000001.SZ")
```

**Returns** (dict): Price, OHLC, volume, amount, and full Level-2 order book (5-level bid/ask):

```python
{
    "stock_code": "000001.SZ",
    "price": 12.60,
    "last_close": 12.50,
    "open": 12.45, "high": 12.65, "low": 12.40,
    "volume": 5000000, "amount": 63000000,
    "bid1": 12.59, "bid2": 12.58, ..., "bid5": 12.55,
    "ask1": 12.60, "ask2": 12.61, ..., "ask5": 12.65,
    "bid_vol1": 500, ..., "ask_vol5": 300,
    "pct_chg": 0.8
}
```

### 4. `get_realtime_quotes()` — Batch Real-Time Quotes

Native batch interface — much faster than looping `get_realtime_quote()`.

```python
await client.get_realtime_quotes(["000001.SZ", "600300.SH", "300750.SZ"])
```

**Returns** (list of dicts):

```python
{
    "stock_code": "000001.SZ",
    "trade_date": "2025-02-10",
    "open": 12.45, "high": 12.65, "low": 12.40, "close": 12.60,
    "pre_close": 12.50,
    "change": 0.15,
    "pct_chg": 1.2048,
    "vol": 5000000.0,
    "amount": 63000000.0,
    "is_realtime": true
}
```

> `pct_chg` is calculated from **today's open price**, not previous close.

### 5. `get_batch_bars()` — Batch K-Line Data

Parallel fetch K-line bars for multiple stocks with concurrency control.

```python
await client.get_batch_bars(
    stock_codes=["000001.SZ", "600300.SH"],
    date="20250210",
    time="10:30:00",
    max_concurrent=10
)
```

**Returns**: `Dict[str, List[Dict]]` — `{stock_code: [bar_data, ...]}`

### 6. `get_transactions_history()` — Historical Tick Data

Tick-by-tick transaction records for a specific historical date.

```python
await client.get_transactions_history(
    stock_code="000001.SZ",
    date="20250210",         # Required: YYYYMMDD
    start=0,
    offset=1000
)
```

**Returns** (list of dicts):

```python
{
    "stock_code": "000001.SZ",
    "time": "09:30:05",
    "price": 12.50,
    "vol": 100,
    "buyorsell": 0,          # 0=buy, 1=sell, 2=neutral
    "num": 5,                # Number of trades in this tick
    "volume": 100
}
```

### 7. `get_transactions_realtime()` — Real-Time Tick Data

Today's live tick-by-tick transaction stream.

```python
await client.get_transactions_realtime(
    stock_code="000001.SZ",
    start=0,
    offset=1000
)
```

Same return format as `get_transactions_history()`.

### 8. `get_transactions_with_fallback()` — Tick Data with Fallback

Tries real-time first, falls back to today's historical data if empty.

```python
await client.get_transactions_with_fallback(
    stock_code="000001.SZ",
    start=0, offset=1000,
    use_history_fallback=True
)
```

## Raw mootdx API (Low-Level)

If using `mootdx` directly without the wrapper:

```python
from mootdx.quotes import Quotes

client = Quotes.factory(market='std')

# K-line bars
df = client.bars(symbol="000001", frequency=7, start=0, offset=240)

# Real-time quotes (supports list of symbols for batch)
df = client.quotes(symbol="000001")
df = client.quotes(symbol=["000001", "600300"])

# Historical transactions
df = client.transactions(symbol="000001", start=0, offset=1000, date="20250210")

# Real-time transactions
df = client.transaction(symbol="000001", start=0, offset=1000)
```

> All raw APIs return **pandas DataFrames**.

## Common Pitfalls

1. **Empty results outside trading hours**: Apply the `time_frame` patch (see above)
2. **Beijing Exchange stocks**: `.BJ` codes are NOT supported — always filter them out
3. **Rate limiting**: Default rate limit is 0.005s between calls; adjust if connection drops
4. **Weekend/holiday queries**: Always validate against trading calendar before querying
5. **1-min bar offset calculation**: Must account for 240 trading minutes/day with lunch gap

## Additional Resources

- For detailed method signatures and time calculation logic, see [api-reference.md](api-reference.md)

「数据分析」分类下的热门技能

AdMapix数据分析

AdMapix 的取数层:把广告与应用相关的查询转成接口调用,只回原始 JSON。

↓ 36.6万★ 304fly0pants
Tavily Search数据分析

走 Tavily 检索公开网页,返回带链接与摘要的结构化结果。

↓ 12.2万★ 286Xiaoran Li
Data Analysis数据分析

把数据库、表格与导出的原始数据变成可决策结论的数据分析技能。

↓ 10.1万★ 244Iván
Stock Analysis数据分析

用 Yahoo Finance 数据做股票与加密货币分析、组合跟踪的技能。

↓ 7.5万★ 299udiedrichsen
Stock Watcher数据分析

管理本地自选股清单,并按代码汇总同花顺行情与近期表现的技能。

↓ 6.5万★ 122Robin797860
全国招标中标查询及分析【知了标讯】数据分析

全网招中标数据查询与分析助手。当用户涉及以下任何场景时,必须使用此SKILL:查询招标/中标公告、搜索标讯、查找临期/即将到期项目、商机预测、推荐潜在投标供应商、分析公司主营业务/历史中标、查询公司上下游合作客户与供应商、分析竞争对手/竞对企业、查询Top采购单位/Top中标单位/Top中标品牌、招中标数据统计分析(按月/季/年/省份/品牌等维度)、查询品牌型号历史中标单价/价格趋势、市场分析/行业分析/采购寻源/渠道拓展等采购与投标相关场景。即使用户没有提到「知了标讯」,只要涉及招投标、采购、中标、供应商、竞争对手等关键词,都应使用本SKILL。

↓ 5.6万★ 13user_98035bfb
Blogwatcher数据分析

用命令行监控博客与 RSS/Atom 源的更新。

↓ 5.4万★ 75Peter Steinberger
Model Usage数据分析

汇总 Codex 或 Claude 按模型计费的使用成本。

↓ 5.0万★ 114Peter Steinberger

taktiko 的其他技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。