TickHub-US (US/HK market data engine for AI agents): MCP server, th-us CLI and typed DataEnvelope
US / HK market data engine for AI agents Quotes · K-lines · Fundamentals · Options & Flow · Short Data · SEC Filings & 13F · Global Rates · Energy
41 MCP tools · 34 domains · 20 sources · hard compliance gate
Why TickHub-US · Architecture · Compliance · Quick Start · Endpoints · Data Sources · Configuration · FAQ
TickHub-US does one thing: it turns US / HK market data scattered across 20 sources into structured tools a model can call directly.
Every number must come from a tool call, and must carry its source and compliance tier. Quotes, K-lines, financial statements, options chains and unusual flow, short data, SEC filings and 13F, policy rates, energy — the service fetches, normalizes and caches them, then returns a single DataEnvelope instead of asking the model to remember numbers or stitch URLs itself.
It is a deployable standalone service, not a prompt. Three things come with that: process isolation (a real process exposing MCP stdio / Streamable HTTP plus a th-us CLI), compliance interception (a commercial call against a disallowed tier raises ComplianceError and does not walk the fallback chain) and cache degradation (Redis when available, in-process LRU when not, with an explicit warning).
This project distributes code, not market data. Data is fetched by the user under each source's own terms. For commercial use, rely only on tier-S sources.
One sentence: direct API calls give you freedom, aggregation libraries give you breadth, and TickHub-US gives you "a model can retrieve sourced, compliance-tagged data without writing code".
TickHub-US · MCP Server + CLI · v1.0.0 │ ├── Access MCP stdio / Streamable HTTP (41 tools) + th-us CLI (10 command groups) │ ↳ commercial_use is mandatory at the entry point; missing → ComplianceError │ ├── Orchestration │ Fallback chain (config/sources.yaml) → try each source → record all attempts │ Compliance gate (config/compliance.yaml) → tier decision → denial is final │ Cache (Redis, auto-degrades to in-process LRU) → per-domain TTL │ ├── Domains quotes / K-lines / indicators / fund flow / short / volatility / Taiwan │ fundamentals / statements / key metrics / analysts / institutional holders │ options chain / unusual flow / CBOE quotes │ SEC filings / daily feed / full-text / XBRL / insiders / 13F │ macro / rates / FX / energy │ └── Adapters 20 providers, each registering a compliance_source SEC EDGAR · Treasury · CFTC · Fed Board · NY Fed · BIS · ECB · EIA · EIA spot TWSE · TPEx · FINRA · CBOE · Eastmoney · Sina · Tencent · Polygon · Yahoo · Nasdaq · local Design trade-off: source priority is written in YAML, not code — one line changes the fallback order. Compliance works the same way: the code only knows compliance_source. When a source changes its terms, that is a config change, not a release.
Source terms differ a lot, and "official" does not mean "free to use". These grades come from reading each source's actual terms; the full text is in config/compliance.yaml.
A working HKEX shareholding layer was removed. Shipping scraping code that violates a source's terms would defeat the point of grading sources in the first place.
Why keep tier-D Yahoo and Nasdaq? The difference is whether a substitute exists: Yahoo is the only source for HK K-lines and for markets beyond the US and HK, and Nasdaq is the only key-free earnings calendar. So the code stays and the terms are quoted in full; whether to use them is the user's call under those terms.
The gate really fires, and it is not a documentation convention:
Distribution name tickhub-us · Python package tickhub_us · CLI th-us. Requires Python ≥ 3.11.
# 1. Install (once the PyPI release is live: pip install tickhub-us) git clone https://github.com/QuotaFuse-ai/TickHub-US.git pip install -e TickHub-US # development pip install -e "TickHub-US[dev]" # 2. Declare your SEC contact (EDGAR requires a real name + email; missing → E_CONFIG) export SEC_CONTACT="Zhang San zhangsan@example.com" # 3. Try one call th-us quote get AAPL th-us quote get AAPL --output json # stdout is JSON only, logs go to stderr A real response, captured 2026-10-26 (fields elided):
{ "schema_version": "1.0", "domain": "quote_us", "symbol": "AAPL", "payload": { "symbol": "AAPL", "price": 347.725, "prev_close": 348.22, "change_pct": -0.14, "high_52w": 348.36, "low_52w": 242.89, "pe": 41.89, "eps": 8.3, "currency": "USD" }, "source": "sina", "compliance_tier": "C", "freshness": "realtime", "fetched_at": "2026-10-26T08:35:47Z", "cache_hit": false, "trace_id": "54dc2aebd9904304", "warnings": ["新浪财经 属 Tier C:商用需事先书面许可,当前为非商用调用。"], "attempts": [ { "provider": "polygon", "status": "disabled" }, { "provider": "sina", "status": "ok", "tier": "C" } ] } Look at compliance_tier and warnings: this row came from Sina, a tier-C source, so the same call with commercial_use=true is rejected outright. attempts shows Polygon skipped for lack of a key and Sina answering.
Four distribution channels, one code base — PyPI wheel / sdist, GitHub Release assets, GHCR container image, and source install. The first two become available once the release workflow has run; see docs/PUBLISHING.md.
# PyPI (after v1.0.0 is published) pip install tickhub-us th-us quote get AAPL # Container (stdio, launched by the MCP client) docker run --rm -i -e SEC_CONTACT="Zhang San zhangsan@example.com" \ ghcr.io/quotafuse-ai/tickhub-us # Container (HTTP, published to loopback only) # Binding a non-loopback address inside the container requires a bearer token # and a Host allowlist, so the two env vars below are not optional. docker run --rm -p 127.0.0.1:8001:8001 \ -e MCP_HTTP_TOKEN=change-me \ -e MCP_HTTP_ALLOWED_HOSTS=127.0.0.1:8001 \ ghcr.io/quotafuse-ai/tickhub-us \ mcp http --host 0.0.0.0 --port 8001 pip install places config/sources.yaml and config/compliance.yaml under /share/tickhub-us/config, so the CLI works from any directory. Source installs find the repo's config/ automatically; TICKHUB_US_CONFIG_DIR overrides both.
# stdio (preferred for local agents) th-us mcp stdio # Streamable HTTP th-us mcp http --host 127.0.0.1 --port 8001 # Both at once th-us start-all MCP client configuration (Claude Desktop style):
{ "mcpServers": { "tickhub-us": { "command": "th-us", "args": ["mcp", "stdio"], "env": { "SEC_CONTACT": "Zhang San zhangsan@example.com" } } } } Commercial calls Every data call requires an explicit commercial_use (an MCP tool argument, or --commercial-use on the CLI). That is the only mechanism that puts compliance at the call site — an agent cannot violate a source's terms without saying so.
# Whitelist specific tier-B sources (a non-empty whitelist is authoritative) export TICKHUB_US_ALLOW_TIER_B_SOURCES=finra,eia_spot # Or allow all tier-B sources (coarse switch) export TICKHUB_US_ALLOW_TIER_B_COMMERCIAL=true # Polygon commercial use: the key alone is not enough, confirm the subscription export POLYGON_API_KEY=... export TICKHUB_US_POLYGON_COMMERCIAL_BASIS=true Endpoints Price — Sina / Tencent / Eastmoney real-time quotes (US + HK) · Sina K-lines (US back to 1984) · Yahoo K-lines (HK and markets beyond US/HK) · MA / EMA / MACD / RSI / KDJ / BOLL computed locally.
Value — Eastmoney three statements + key indicators (including HK) · Yahoo quoteSummary structured statements / analyst estimates / institutional holders · SEC XBRL companyfacts.
Flow & positioning ⭐ — FINRA market-wide daily short volume and short interest (with days to cover and rankings) · CBOE options chains (IV + full Greeks) and unusual-flow detection · CBOE volatility indices (VIX since 1990) and the VIX term structure · Eastmoney daily fund flow.
Filings & events ⭐ — EDGAR submissions · daily index event stream (same-day Form 4 / 8-K / 13F) · full-text search back to 2001 · Form 4 insider trades line by line · 13F institutional holdings · XBRL frames market-wide cross-section (a free screener).
Macro / rates ⭐ — Treasury yield curve · CFTC COT · earnings calendar · Treasury auctions and federal debt · BIS central-bank policy rates · ECB FX / rates / yield curve · NY Fed SOFR / EFFR · Fed Board H.10 / H.6.
Taiwan / energy ⭐ — TWSE + TPEx official open APIs (quotes / P/E / monthly revenue / margin) · EIA weekly crude and natural gas inventories plus spot prices.
Tools — stock search · full-market list · per-symbol and keyword news · ticker ↔ CIK.
Say these to your AI assistant to trigger the tools (the CLI equivalent is in parentheses):
Tiers: S = government and central-bank data, commercial + redistribution OK (some require attribution) · B = published but terms-restricted, verify before commercial use and do not redistribute · C = needs prior approval or personal research only · D = terms prohibit automated access without permission; personal study and research only, at your own risk. Quoted basis: Compliance tiers.
All requests go through core/http.py: per-host rate limiting (SEC 8 req/s, CFTC / FINRA / CBOE 4 req/s, Nasdaq 2 req/s, default 5 req/s), exponential-backoff retries, an 8 MB response cap, and cross-host redirects allowed only to hosts registered in config/sources.yaml.
Everything is environment variables. A .env file in the current directory (or its parent) is loaded automatically on first use. th-us config show prints the effective settings with secrets redacted.
commercial_use is not an environment variable — it is a per-call parameter, deliberately, so that no deployment-wide setting can flip a whole process into commercial mode by accident.
config/sources.yaml defines one chain per domain. A failure (throttle / no data / compliance denial / upstream 5xx) is recorded in DataEnvelope.attempts and the next source is tried:
quote_us: polygon → sina → tencent → eastmoney # TTL 30s, realtime fundamental: eastmoney → yahoo → sec_edgar # TTL 12h, eod rates: bis → ecb → ny_fed → federal_reserve → treasury options_flow: cboe → yahoo # TTL 60s, realtime Cache TTLs are per domain: quotes 30 s, options 60 s, news 5 min, statements and filings 12 h, CIK mapping 24 h. When Redis is unavailable the cache degrades to an in-process LRU and says so in the log — cache degradation never changes which data source is used. Cache keys include the commercial_use flag, so a commercial result is never served to a non-commercial call.
Every response uses the same envelope, so an agent can consume source / freshness / compliance_tier / attempts directly:
Technical indicators additionally carry underlying, which records the source and tier of the K-lines they were computed from: the indicator itself is tier-S local computation, but its trustworthiness depends on its input (DEC-009).
41 tools in total; the full list is in docs/specs/tickhub-us.md §3.2. The three signatures fixed by the product spec:
(The th_us_ prefix is omitted above. The 41 tools map one-to-one to spec §3.2; see DEC-011.)
By default the server listens on loopback only (127.0.0.1 / localhost / [::1]) with DNS-rebinding protection always on. The Host / Origin allowlists are passed explicitly by create_app(); in the loopback case only loopback hosts are allowed.
Listening externally is an explicit action — missing one requirement fails startup with E_CONFIG:
With MCP_HTTP_TOKEN set, every request except GET /healthz (kept anonymous for container probes) must carry Authorization: Bearer . The check uses a constant-time comparison; failures return 401 with WWW-Authenticate: Bearer realm="tickhub-us". /healthz returns only {"status": "ok"} — no version, no tool count (SEC-12).
MCP_HTTP_HOST=0.0.0.0 \ MCP_HTTP_TOKEN="$(openssl rand -hex 32)" \ MCP_HTTP_ALLOWED_HOSTS=tickhub.internal:8001 \ th-us mcp http Testing and CI Suite Cases Covers Offline 238 Contracts, compliance interception, fallback-chain matrix, secret redaction, input and network hardening, MCP HTTP security, indicator tier inheritance, regression tests for live defects Live smoke 13 US / HK quotes · SEC filings and 13F · options flow · VIX history and term structure · EIA spot and inventories · BIS policy rates · Yahoo fundamentals; skipped by default # Full offline run (no network, no Redis needed) pytest -m "not live" # Live smoke (needs SEC_CONTACT; Eastmoney endpoints can be skipped outside mainland China) SEC_CONTACT="you@example.com" TICKHUB_US_LIVE=1 pytest tests/contract/test_live_smoke.py -m live TICKHUB_US_LIVE_SKIP_REGIONAL=1 ... # skip the two cases that depend on Eastmoney push2 CI (.github/workflows/ci.yml):
Two manual release workflows, neither triggered by a push:
Operating steps and the one-time PyPI setup are in docs/PUBLISHING.md. If egress needs a proxy, set HTTPS_PROXY / HTTP_PROXY (the standard variables requests reads); keep proxy credentials in the environment only — never in config/ and never committed.
config/ sources.yaml (chains / rate limits / redirect allowlist), compliance.yaml (tiers) src/tickhub_us/ core/ settings, errors, HTTP, logging, symbols, DataEnvelope cache/ tiered TTL + Redis / in-process LRU fallback compliance/ tier registry and interceptor providers/ 20 source adapters + local indicator computation market/ quotes, K-lines, indicators, fund flow, short, volatility, Taiwan fundamental/ statements, key metrics, analyst estimates, institutional holders options/ options chain, Greeks, 0DTE, unusual flow filings/ SEC submissions / XBRL / daily index / full-text / Form 4 / 13F mcp/ MCP server (stdio / HTTP) cli/ th-us command tree tests/ contract/ interface contracts + live smoke + defect regressions compliance/ compliance interception tests docs/ specs, decision records, task outputs, PUBLISHING.md SKILL.md compact agent-facing SOP Dockerfile image (non-root, stdio by default) .github/workflows/ ci.yml (gate) + publish.yml (PyPI / Release) + docker.yml (GHCR) FAQ Does it need an API key? No, by default. Only Polygon is an optional source (POLYGON_API_KEY); SEC EDGAR needs a real SEC_CONTACT, which is an identity declaration, not a secret.
Will it silently switch sources when data is missing? It will walk the fallback chain, but it will not degrade around a compliance denial — if every source on the chain is denied, it raises ComplianceError and lists each denial in attempts (DEC-005).
Are HK options available? No. The options layer is US only; HK options would require HKEX's paid proprietary feed.
Can it look up stocks outside the US and HK? K-lines and Yahoo fundamentals, yes: Japan .T, Taiwan .TW, Korea .KS, India .NS, London .L, Germany .DE and more. Note that Yahoo is a tier-D source. Taiwan also has the official TWSE / TPEx APIs (tier S, latest trading day only).
How fresh are global rates and FX? ECB and NY Fed update every business day; Fed H.10 is published each Monday for the prior week; BIS lags by a few days to about three weeks depending on the country. Every value carries a date — check the central bank itself when you need today's exact number.
How often does short interest update? FINRA publishes it twice a month, for settlement dates on the 15th and at month-end (moved earlier for holidays), about 8 business days after settlement. The daily dataset is a different one — daily short volume, which counts that day's short-sale trades, not open short positions.
Can a server in mainland China reach Yahoo / SEC? They are overseas services and may be flaky on a direct connection. Use a proxy, or lean on the Eastmoney / Sina / Tencent sources. The CI live job runs on GitHub-hosted runners, which is why the Eastmoney cases are skipped there.
Can I use it without an MCP client? Yes. The th-us CLI covers every endpoint, and --output json feeds any script directly.
Can I install it from PyPI? Is there a Docker image? The code side is ready: publish.yml produces sdist / wheel / GitHub Release assets and docker.yml produces ghcr.io/quotafuse-ai/tickhub-us. The first upload needs the repository owner to finish the one-time PyPI setup (a couple of minutes), after which the workflow is a single manual dispatch. Until then, install from source — see Quick start and docs/PUBLISHING.md.
v1.0.0 (2026-10-26) — first stable release, feature-complete against the spec (DEC-011) and re-verified end to end against live sources:
This project provides data-access tooling only. It is not investment advice. Markets carry risk. Data licensing follows each source's terms — see config/compliance.yaml.
Apache License 2.0. Author: QuotaFuse · https://github.com/QuotaFuse-ai
Feature spec: docs/specs/tickhub-us.md · architecture decisions: docs/decisions/ · agent SOP: SKILL.md
All 2 files in this release have provenance metadata.
us-stocks hk-stocks mcp mcp-server market-data sec-edgar options ai-agent
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
All 2 files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




