據 AlphaMoat 統計,截至 2026-09,Free A Share Real Time Data 累計下載 2,627 次、獲 1 個星標,在全部 5,078 個 AI 技能中排名第 4,003 位,在「資料分析」分類(399 個)中排名第 302 位。
| 平台 | 累計安裝 | 累計下載 | 星標 | 評論 |
|---|---|---|---|---|
| ClawHub ↗ | 68 | 2416 | 1 | - |
| SkillHub ↗ | 218 | 2627 | 1 | — |
各平台的計數口徑不同,統計時間不一致。
該技能封裝 mootdx/TDX 協議,可查詢中國 A 股歷史或即時 K 線、單隻或批次即時報價,以及逐筆交易記錄。呼叫前需考慮北京時間交易時段、交易日曆和股票程式碼格式;文件明確指出該庫不支援北京證券交易所股票,使用時應先過濾這些程式碼。它提供資料查詢與呼叫示例,不構成投資建議。
資料釋出於 2026-10-27
以下是根據技能文件生成的示例,不代表實際執行結果。
2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。
| 月份 | 累計下載 | 環比 | 星標 |
|---|---|---|---|
| 2026-09 | 2627 | — | 1 |
| 2026-08 | 2277 | +8.6% | 1 |
| 2026-07 | 2096 | +17.0% | 1 |
| 2026-06 | 1792 | +12.3% | 1 |
| 2026-05 | 1596 | — | 1 |
| 2026-03 | 1146 | — | 1 |
以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。
--- 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
```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 的取數層:把廣告與應用相關的查詢轉成介面呼叫,只回原始 JSON。
透過 Tavily 搜尋公開網頁,並回傳含連結與摘要的結構化結果。
把資料庫、表格與匯出的原始資料變成可決策結論的資料分析技能。
用 Yahoo Finance 資料做股票與加密貨幣分析、組合跟蹤的技能。
管理本地自選股清單,並按代碼彙總同花順行情與近期表現的技能。
全網招中標資料查詢與分析助手。當用戶涉及以下任何場景時,必須使用此SKILL:查詢招標/中標公告、搜尋標訊、查詢臨期/即將到期專案、商機預測、推薦潛在投標供應商、分析公司主營業務/歷史中標、查詢公司上下游合作客戶與供應商、分析競爭對手/競對企業、查詢Top採購單位/Top中標單位/Top中標品牌、招中標資料統計分析(按月/季/年/省份/品牌等維度)、查詢品牌型號歷史中標單價/價格趨勢、市場分析/行業分析/採購尋源/渠道拓展等採購與投標相關場景。即使使用者沒有提到「知了標訊」,只要涉及招投標、採購、中標、供應商、競爭對手等關鍵詞,都應使用本SKILL。
用命令列監控部落格與 RSS/Atom 源的更新。
彙總 Codex 或 Claude 按模型計費的使用成本。
資料月份:2026-09 · 下載/星標/安裝數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。