{
  "schemaVersion": "1.0",
  "item": {
    "slug": "a-share-real-time-data",
    "name": "A股实时行情数据",
    "source": "tencent",
    "type": "skill",
    "category": "数据分析",
    "sourceUrl": "https://clawhub.ai/wangdinglu/a-share-real-time-data",
    "canonicalUrl": "https://clawhub.ai/wangdinglu/a-share-real-time-data",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/a-share-real-time-data",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=a-share-real-time-data",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "api-reference.md",
      "scripts/setup_and_verify.py"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-23T16:43:11.935Z",
      "expiresAt": "2026-04-30T16:43:11.935Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
        "contentDisposition": "attachment; filename=\"4claw-imageboard-1.0.1.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/a-share-real-time-data"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/a-share-real-time-data",
    "agentPageUrl": "https://openagent3.xyz/skills/a-share-real-time-data/agent",
    "manifestUrl": "https://openagent3.xyz/skills/a-share-real-time-data/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/a-share-real-time-data/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Mootdx China A-Share Stock Data Client",
        "body": "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."
      },
      {
        "title": "Installation",
        "body": "pip install mootdx\n\nmootdx depends on tdxpy internally. Both are installed together."
      },
      {
        "title": "Verify & Demo",
        "body": "python scripts/setup_and_verify.py           # Install + verify + connectivity test\npython scripts/setup_and_verify.py --check   # Verify only (skip install)\npython scripts/setup_and_verify.py --demo    # Full API demo with real output\n\nThe --demo mode exercises every major API and prints real data — useful as a runnable reference for correct calling patterns."
      },
      {
        "title": "Trading Hours (Beijing Time, UTC+8)",
        "body": "SessionTimeMorning09:30 - 11:30 (120 min)Lunch break11:30 - 13:00Afternoon13:00 - 15:00 (120 min)Total240 trading minutes/day"
      },
      {
        "title": "Trading Time Bypass Patch",
        "body": "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.\n\nSolution: Monkey-patch tdxpy.hq.time_frame to always return True:\n\nimport tdxpy.hq\ntdxpy.hq.time_frame = lambda: True\n\nThis patch is applied automatically during MootdxClient.__init__(). Without it, transactions() and transaction() calls will silently return empty results outside detected trading hours."
      },
      {
        "title": "Trading Calendar",
        "body": "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."
      },
      {
        "title": "Date/Time Parameter Formats",
        "body": "ParameterFormatExampledateYYYYMMDD\"20250210\"timeHH:MM:SS or HH:MM\"10:30:00\" or \"10:30\""
      },
      {
        "title": "Stock Code Format",
        "body": "mootdx uses pure numeric codes (TDX format). Convert from standard format:\n\nStandard FormatTDX FormatMarket000001.SZ000001Shenzhen600300.SH600300Shanghai300750.SZ300750Shenzhen (ChiNext)688001.SH688001Shanghai (STAR)\n\nConversion: Strip the .SH / .SZ / .BJ suffix.\n\nImportant: mootdx does NOT support Beijing Stock Exchange (.BJ) stocks. Filter them out before calling."
      },
      {
        "title": "1. Initialize Client",
        "body": "from mootdx.quotes import Quotes\nclient = Quotes.factory(market='std')"
      },
      {
        "title": "2. get_bars() — K-Line / Candlestick Data",
        "body": "Fetch historical or real-time K-line bars.\n\nawait client.get_bars(\n    stock_code=\"000001.SZ\",   # Standard format (auto-converted)\n    frequency=7,               # K-line period (see table below)\n    offset=240,                # Number of bars to fetch\n    date=\"20250210\",           # Optional: specific date (YYYYMMDD)\n    time=\"10:30:00\",           # Optional: specific time (HH:MM:SS)\n    filter_by_time=True        # Filter to closest bar matching time\n)\n\nFrequency codes:\n\nCodePeriod71-minute bars81-minute bars (alternative)4Daily bars9Daily bars (alternative)\n\nReturn format (list of dicts):\n\n{\n    \"stock_code\": \"000001.SZ\",\n    \"datetime\": \"2025-02-10 10:30:00\",\n    \"open\": 12.50,\n    \"high\": 12.65,\n    \"low\": 12.45,\n    \"close\": 12.60,\n    \"vol\": 150000.0,\n    \"amount\": 1890000.0\n}\n\nStart 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:\n\nWhether today is a trading day\nCurrent trading session status (pre-market / in-session / post-market)\nLunch break gap (11:30-13:00)"
      },
      {
        "title": "3. get_realtime_quote() — Single Stock Real-Time Quote",
        "body": "await client.get_realtime_quote(stock_code=\"000001.SZ\")\n\nReturns (dict): Price, OHLC, volume, amount, and full Level-2 order book (5-level bid/ask):\n\n{\n    \"stock_code\": \"000001.SZ\",\n    \"price\": 12.60,\n    \"last_close\": 12.50,\n    \"open\": 12.45, \"high\": 12.65, \"low\": 12.40,\n    \"volume\": 5000000, \"amount\": 63000000,\n    \"bid1\": 12.59, \"bid2\": 12.58, ..., \"bid5\": 12.55,\n    \"ask1\": 12.60, \"ask2\": 12.61, ..., \"ask5\": 12.65,\n    \"bid_vol1\": 500, ..., \"ask_vol5\": 300,\n    \"pct_chg\": 0.8\n}"
      },
      {
        "title": "4. get_realtime_quotes() — Batch Real-Time Quotes",
        "body": "Native batch interface — much faster than looping get_realtime_quote().\n\nawait client.get_realtime_quotes([\"000001.SZ\", \"600300.SH\", \"300750.SZ\"])\n\nReturns (list of dicts):\n\n{\n    \"stock_code\": \"000001.SZ\",\n    \"trade_date\": \"2025-02-10\",\n    \"open\": 12.45, \"high\": 12.65, \"low\": 12.40, \"close\": 12.60,\n    \"pre_close\": 12.50,\n    \"change\": 0.15,\n    \"pct_chg\": 1.2048,\n    \"vol\": 5000000.0,\n    \"amount\": 63000000.0,\n    \"is_realtime\": true\n}\n\npct_chg is calculated from today's open price, not previous close."
      },
      {
        "title": "5. get_batch_bars() — Batch K-Line Data",
        "body": "Parallel fetch K-line bars for multiple stocks with concurrency control.\n\nawait client.get_batch_bars(\n    stock_codes=[\"000001.SZ\", \"600300.SH\"],\n    date=\"20250210\",\n    time=\"10:30:00\",\n    max_concurrent=10\n)\n\nReturns: Dict[str, List[Dict]] — {stock_code: [bar_data, ...]}"
      },
      {
        "title": "6. get_transactions_history() — Historical Tick Data",
        "body": "Tick-by-tick transaction records for a specific historical date.\n\nawait client.get_transactions_history(\n    stock_code=\"000001.SZ\",\n    date=\"20250210\",         # Required: YYYYMMDD\n    start=0,\n    offset=1000\n)\n\nReturns (list of dicts):\n\n{\n    \"stock_code\": \"000001.SZ\",\n    \"time\": \"09:30:05\",\n    \"price\": 12.50,\n    \"vol\": 100,\n    \"buyorsell\": 0,          # 0=buy, 1=sell, 2=neutral\n    \"num\": 5,                # Number of trades in this tick\n    \"volume\": 100\n}"
      },
      {
        "title": "7. get_transactions_realtime() — Real-Time Tick Data",
        "body": "Today's live tick-by-tick transaction stream.\n\nawait client.get_transactions_realtime(\n    stock_code=\"000001.SZ\",\n    start=0,\n    offset=1000\n)\n\nSame return format as get_transactions_history()."
      },
      {
        "title": "8. get_transactions_with_fallback() — Tick Data with Fallback",
        "body": "Tries real-time first, falls back to today's historical data if empty.\n\nawait client.get_transactions_with_fallback(\n    stock_code=\"000001.SZ\",\n    start=0, offset=1000,\n    use_history_fallback=True\n)"
      },
      {
        "title": "Raw mootdx API (Low-Level)",
        "body": "If using mootdx directly without the wrapper:\n\nfrom mootdx.quotes import Quotes\n\nclient = Quotes.factory(market='std')\n\n# K-line bars\ndf = client.bars(symbol=\"000001\", frequency=7, start=0, offset=240)\n\n# Real-time quotes (supports list of symbols for batch)\ndf = client.quotes(symbol=\"000001\")\ndf = client.quotes(symbol=[\"000001\", \"600300\"])\n\n# Historical transactions\ndf = client.transactions(symbol=\"000001\", start=0, offset=1000, date=\"20250210\")\n\n# Real-time transactions\ndf = client.transaction(symbol=\"000001\", start=0, offset=1000)\n\nAll raw APIs return pandas DataFrames."
      },
      {
        "title": "Common Pitfalls",
        "body": "Empty results outside trading hours: Apply the time_frame patch (see above)\nBeijing Exchange stocks: .BJ codes are NOT supported — always filter them out\nRate limiting: Default rate limit is 0.005s between calls; adjust if connection drops\nWeekend/holiday queries: Always validate against trading calendar before querying\n1-min bar offset calculation: Must account for 240 trading minutes/day with lunch gap"
      },
      {
        "title": "Additional Resources",
        "body": "For detailed method signatures and time calculation logic, see api-reference.md"
      }
    ],
    "body": "Mootdx China A-Share Stock Data Client\n\nA 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.\n\nInstallation\npip install mootdx\n\n\nmootdx depends on tdxpy internally. Both are installed together.\n\nVerify & Demo\npython scripts/setup_and_verify.py           # Install + verify + connectivity test\npython scripts/setup_and_verify.py --check   # Verify only (skip install)\npython scripts/setup_and_verify.py --demo    # Full API demo with real output\n\n\nThe --demo mode exercises every major API and prints real data — useful as a runnable reference for correct calling patterns.\n\nCritical: Time & Timezone Considerations\nTrading Hours (Beijing Time, UTC+8)\nSession\tTime\nMorning\t09:30 - 11:30 (120 min)\nLunch break\t11:30 - 13:00\nAfternoon\t13:00 - 15:00 (120 min)\nTotal\t240 trading minutes/day\nTrading Time Bypass Patch\n\nProblem: 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.\n\nSolution: Monkey-patch tdxpy.hq.time_frame to always return True:\n\nimport tdxpy.hq\ntdxpy.hq.time_frame = lambda: True\n\n\nThis patch is applied automatically during MootdxClient.__init__(). Without it, transactions() and transaction() calls will silently return empty results outside detected trading hours.\n\nTrading Calendar\n\nWhen 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.\n\nDate/Time Parameter Formats\nParameter\tFormat\tExample\ndate\tYYYYMMDD\t\"20250210\"\ntime\tHH:MM:SS or HH:MM\t\"10:30:00\" or \"10:30\"\nStock Code Format\n\nmootdx uses pure numeric codes (TDX format). Convert from standard format:\n\nStandard Format\tTDX Format\tMarket\n000001.SZ\t000001\tShenzhen\n600300.SH\t600300\tShanghai\n300750.SZ\t300750\tShenzhen (ChiNext)\n688001.SH\t688001\tShanghai (STAR)\n\nConversion: Strip the .SH / .SZ / .BJ suffix.\n\nImportant: mootdx does NOT support Beijing Stock Exchange (.BJ) stocks. Filter them out before calling.\n\nAPI Reference\n1. Initialize Client\nfrom mootdx.quotes import Quotes\nclient = Quotes.factory(market='std')\n\n2. get_bars() — K-Line / Candlestick Data\n\nFetch historical or real-time K-line bars.\n\nawait client.get_bars(\n    stock_code=\"000001.SZ\",   # Standard format (auto-converted)\n    frequency=7,               # K-line period (see table below)\n    offset=240,                # Number of bars to fetch\n    date=\"20250210\",           # Optional: specific date (YYYYMMDD)\n    time=\"10:30:00\",           # Optional: specific time (HH:MM:SS)\n    filter_by_time=True        # Filter to closest bar matching time\n)\n\n\nFrequency codes:\n\nCode\tPeriod\n7\t1-minute bars\n8\t1-minute bars (alternative)\n4\tDaily bars\n9\tDaily bars (alternative)\n\nReturn format (list of dicts):\n\n{\n    \"stock_code\": \"000001.SZ\",\n    \"datetime\": \"2025-02-10 10:30:00\",\n    \"open\": 12.50,\n    \"high\": 12.65,\n    \"low\": 12.45,\n    \"close\": 12.60,\n    \"vol\": 150000.0,\n    \"amount\": 1890000.0\n}\n\n\nStart 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:\n\nWhether today is a trading day\nCurrent trading session status (pre-market / in-session / post-market)\nLunch break gap (11:30-13:00)\n3. get_realtime_quote() — Single Stock Real-Time Quote\nawait client.get_realtime_quote(stock_code=\"000001.SZ\")\n\n\nReturns (dict): Price, OHLC, volume, amount, and full Level-2 order book (5-level bid/ask):\n\n{\n    \"stock_code\": \"000001.SZ\",\n    \"price\": 12.60,\n    \"last_close\": 12.50,\n    \"open\": 12.45, \"high\": 12.65, \"low\": 12.40,\n    \"volume\": 5000000, \"amount\": 63000000,\n    \"bid1\": 12.59, \"bid2\": 12.58, ..., \"bid5\": 12.55,\n    \"ask1\": 12.60, \"ask2\": 12.61, ..., \"ask5\": 12.65,\n    \"bid_vol1\": 500, ..., \"ask_vol5\": 300,\n    \"pct_chg\": 0.8\n}\n\n4. get_realtime_quotes() — Batch Real-Time Quotes\n\nNative batch interface — much faster than looping get_realtime_quote().\n\nawait client.get_realtime_quotes([\"000001.SZ\", \"600300.SH\", \"300750.SZ\"])\n\n\nReturns (list of dicts):\n\n{\n    \"stock_code\": \"000001.SZ\",\n    \"trade_date\": \"2025-02-10\",\n    \"open\": 12.45, \"high\": 12.65, \"low\": 12.40, \"close\": 12.60,\n    \"pre_close\": 12.50,\n    \"change\": 0.15,\n    \"pct_chg\": 1.2048,\n    \"vol\": 5000000.0,\n    \"amount\": 63000000.0,\n    \"is_realtime\": true\n}\n\n\npct_chg is calculated from today's open price, not previous close.\n\n5. get_batch_bars() — Batch K-Line Data\n\nParallel fetch K-line bars for multiple stocks with concurrency control.\n\nawait client.get_batch_bars(\n    stock_codes=[\"000001.SZ\", \"600300.SH\"],\n    date=\"20250210\",\n    time=\"10:30:00\",\n    max_concurrent=10\n)\n\n\nReturns: Dict[str, List[Dict]] — {stock_code: [bar_data, ...]}\n\n6. get_transactions_history() — Historical Tick Data\n\nTick-by-tick transaction records for a specific historical date.\n\nawait client.get_transactions_history(\n    stock_code=\"000001.SZ\",\n    date=\"20250210\",         # Required: YYYYMMDD\n    start=0,\n    offset=1000\n)\n\n\nReturns (list of dicts):\n\n{\n    \"stock_code\": \"000001.SZ\",\n    \"time\": \"09:30:05\",\n    \"price\": 12.50,\n    \"vol\": 100,\n    \"buyorsell\": 0,          # 0=buy, 1=sell, 2=neutral\n    \"num\": 5,                # Number of trades in this tick\n    \"volume\": 100\n}\n\n7. get_transactions_realtime() — Real-Time Tick Data\n\nToday's live tick-by-tick transaction stream.\n\nawait client.get_transactions_realtime(\n    stock_code=\"000001.SZ\",\n    start=0,\n    offset=1000\n)\n\n\nSame return format as get_transactions_history().\n\n8. get_transactions_with_fallback() — Tick Data with Fallback\n\nTries real-time first, falls back to today's historical data if empty.\n\nawait client.get_transactions_with_fallback(\n    stock_code=\"000001.SZ\",\n    start=0, offset=1000,\n    use_history_fallback=True\n)\n\nRaw mootdx API (Low-Level)\n\nIf using mootdx directly without the wrapper:\n\nfrom mootdx.quotes import Quotes\n\nclient = Quotes.factory(market='std')\n\n# K-line bars\ndf = client.bars(symbol=\"000001\", frequency=7, start=0, offset=240)\n\n# Real-time quotes (supports list of symbols for batch)\ndf = client.quotes(symbol=\"000001\")\ndf = client.quotes(symbol=[\"000001\", \"600300\"])\n\n# Historical transactions\ndf = client.transactions(symbol=\"000001\", start=0, offset=1000, date=\"20250210\")\n\n# Real-time transactions\ndf = client.transaction(symbol=\"000001\", start=0, offset=1000)\n\n\nAll raw APIs return pandas DataFrames.\n\nCommon Pitfalls\nEmpty results outside trading hours: Apply the time_frame patch (see above)\nBeijing Exchange stocks: .BJ codes are NOT supported — always filter them out\nRate limiting: Default rate limit is 0.005s between calls; adjust if connection drops\nWeekend/holiday queries: Always validate against trading calendar before querying\n1-min bar offset calculation: Must account for 240 trading minutes/day with lunch gap\nAdditional Resources\nFor detailed method signatures and time calculation logic, see api-reference.md"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/wangdinglu/a-share-real-time-data",
    "publisherUrl": "https://clawhub.ai/wangdinglu/a-share-real-time-data",
    "owner": "wangdinglu",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/a-share-real-time-data",
    "downloadUrl": "https://openagent3.xyz/downloads/a-share-real-time-data",
    "agentUrl": "https://openagent3.xyz/skills/a-share-real-time-data/agent",
    "manifestUrl": "https://openagent3.xyz/skills/a-share-real-time-data/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/a-share-real-time-data/agent.md"
  }
}