A-share quote source router with pytdx failover, easyquotation fallback and audit trail
Project description
aquote-router
aquote-router is a lightweight A-share quote source router for research tooling.
It routes provider calls, records source attempts, and returns normalized Python
dataclasses. It is infrastructure only: it does not provide investment advice,
order execution, account login, screening, timing signals, or performance claims.
Features
realtime_quotes,full_realtime_quotes, andindex_realtimeroute throughpytdx -> easyquotation_sina -> easyquotation_tencent.minute_kline,daily_kline, and unifiedklineare pytdx-only.- pytdx servers are ordered by
primary -> hot_backup -> backup, then bylatency_ms. probe-pytdxcan generate a local active pytdx server pool for diagnostics.- Return models include
source,source_level,is_fallback,fallback_from, andtrace_id. - JSONL and SQLite audit logs record attempts,
fallback_chain,selected_source, duration, record count, and final error details. - The default test suite is offline. Live smoke checks require explicit opt-in.
Install
python -X utf8 -m pip install aquote-router
Local development:
python -X utf8 -m pip install -e ".[dev,test]"
Quick Start
from aquote_router import QuoteRouter
router = QuoteRouter.from_config(
pytdx_servers_path="config/pytdx_servers.example.json",
source_policy_path="config/source_policy.example.yaml",
audit_jsonl_path="logs/aquote_router_audit.jsonl",
audit_sqlite_path="logs/aquote_router_audit.sqlite3",
)
records = router.realtime_quotes(["000001", "600000"])
for record in records:
print(record.to_dict())
K-line examples:
router.minute_kline("000001", period="15m", count=120)
router.daily_kline("000001", count=120)
router.kline("000001", period="1d", count=120)
Public API
router.realtime_quotes(["000001", "600000"])
router.full_realtime_quotes(["000001", "600000"])
router.index_realtime(["000001", "399001"])
router.minute_kline("000001", period="15m", count=120)
router.daily_kline("000001", count=120)
router.kline("000001", period="1d", count=120)
router.diagnose()
CLI
aquote-router realtime 000001 600000
aquote-router full 000001 600000
aquote-router full-realtime 000001 600000
aquote-router index 000001 399001
aquote-router minute 000001 --period 15m --count 120
aquote-router daily 000001 --count 120
aquote-router kline 000001 --period 15m --count 120
aquote-router kline 000001 --period 1d --count 120
aquote-router probe-pytdx --json --output config/pytdx_servers.active.local.json
aquote-router diagnose --json
Use --json for complete output, especially when table columns are too wide.
CLI failures return a non-zero exit code and a structured project error code.
When K-line calls time out, first refresh a local pytdx pool:
aquote-router probe-pytdx --json --output config/pytdx_servers.active.local.json
Then pass the active local pool explicitly:
aquote-router kline 000001 --period 15m --count 10 \
--pytdx-servers config/pytdx_servers.active.local.json --json
config/pytdx_servers.active.local.json is an observed local diagnostic result
and should not be committed. Free pytdx server availability changes by network,
region, and time; this project does not promise that every environment can
connect at every time.
Source Policy
Default realtime routing:
realtime_quotes: pytdx -> easyquotation_sina -> easyquotation_tencent
full_realtime_quotes: pytdx -> easyquotation_sina -> easyquotation_tencent
index_realtime: pytdx -> easyquotation_sina -> easyquotation_tencent
Default K-line routing:
minute_kline: pytdx only
daily_kline: pytdx only
kline: pytdx only
K-line APIs never fall back to easyquotation and never fabricate bars.
Realtime APIs may fall back to easyquotation_sina or easyquotation_tencent
after pytdx failures, but K-line APIs do not use easyquotation fallback.
Core Docs
- Quickstart
- API reference
- K-line guide
- Data sources
- Return fields
- CLI reference
- Troubleshooting
- Error codes
- Symbol rules
- Units
- Source policy
- Audit trail
- Time and trading day
- Upstream license and risk
- Roadmap
- Contributor adapter guide
Audit Trail
Each routed call receives a trace_id. Audit records include:
api_namesymbolsstarted_at,finished_at,duration_msselected_source,selected_source_levelattemptsfallback_chainsuccesserror_type,error_messagerecord_count
See docs/AUDIT_TRAIL.md.
Risk Notice
This package does not produce market data. It calls upstream public Python libraries and their public interfaces. Upstream data may be delayed, unavailable, incomplete, or structurally changed. Users are responsible for validating data quality and following the terms of each upstream project.
License
MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aquote_router-0.2.1.tar.gz.
File metadata
- Download URL: aquote_router-0.2.1.tar.gz
- Upload date:
- Size: 55.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c5447ae6bd5940526c8aec26034f38b382f162e2db53d536422c8fc58f667d3
|
|
| MD5 |
094c59e8eb964adad410bfde132fa24e
|
|
| BLAKE2b-256 |
e6bf870a4e805af435d8ae58d8714ad5a6ff49ccf600d4ebc2fed4552807f10d
|
Provenance
The following attestation bundles were made for aquote_router-0.2.1.tar.gz:
Publisher:
publish.yml on tabman2026/aquote-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aquote_router-0.2.1.tar.gz -
Subject digest:
3c5447ae6bd5940526c8aec26034f38b382f162e2db53d536422c8fc58f667d3 - Sigstore transparency entry: 1825632327
- Sigstore integration time:
-
Permalink:
tabman2026/aquote-router@1feb0d79937d169eddf08919e0352e1cd1125ea2 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/tabman2026
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1feb0d79937d169eddf08919e0352e1cd1125ea2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aquote_router-0.2.1-py3-none-any.whl.
File metadata
- Download URL: aquote_router-0.2.1-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e837d3f0d552702796f201fabe444ae46c3d15b5bb0fb9986f3948aee7f23ca3
|
|
| MD5 |
3425cbd6bd9dcb50531c727a3217d4c2
|
|
| BLAKE2b-256 |
71df11111f2da88ff6a8427045f218f230a97a53773d6aeb10e682a231f3d776
|
Provenance
The following attestation bundles were made for aquote_router-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on tabman2026/aquote-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aquote_router-0.2.1-py3-none-any.whl -
Subject digest:
e837d3f0d552702796f201fabe444ae46c3d15b5bb0fb9986f3948aee7f23ca3 - Sigstore transparency entry: 1825632363
- Sigstore integration time:
-
Permalink:
tabman2026/aquote-router@1feb0d79937d169eddf08919e0352e1cd1125ea2 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/tabman2026
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1feb0d79937d169eddf08919e0352e1cd1125ea2 -
Trigger Event:
push
-
Statement type: