Skip to main content

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, and index_realtime route through pytdx -> easyquotation_sina -> easyquotation_tencent.
  • minute_kline, daily_kline, and unified kline are pytdx-only.
  • pytdx servers are ordered by primary -> hot_backup -> backup, then by latency_ms.
  • Return models include source, source_level, is_fallback, fallback_from, and trace_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 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.

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.

Core Docs

Audit Trail

Each routed call receives a trace_id. Audit records include:

  • api_name
  • symbols
  • started_at, finished_at, duration_ms
  • selected_source, selected_source_level
  • attempts
  • fallback_chain
  • success
  • error_type, error_message
  • record_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aquote_router-0.2.0.tar.gz (38.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aquote_router-0.2.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file aquote_router-0.2.0.tar.gz.

File metadata

  • Download URL: aquote_router-0.2.0.tar.gz
  • Upload date:
  • Size: 38.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aquote_router-0.2.0.tar.gz
Algorithm Hash digest
SHA256 060bd10621ad8ee956604113b00aac4edd3efa2cd16f07bd79555c464f16beec
MD5 52bb66f9404ad9aa488688a5371a2c0b
BLAKE2b-256 20f6cfb78537fb375a380b478dc09aaf98d9cd630d8f344f4e9bffd531c5bb9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aquote_router-0.2.0.tar.gz:

Publisher: publish.yml on tabman2026/aquote-router

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aquote_router-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: aquote_router-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aquote_router-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6a4eab79ab444709c77caf7d90b45b1e0cb239b1701efe003cf405cfb40fffe
MD5 6423c175c6b9f1786bbf0cbea77d5f92
BLAKE2b-256 baaf90bde9b0c3c4675b8ba1a6edc373f76f972b035a37b7266bf85ea24031f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for aquote_router-0.2.0-py3-none-any.whl:

Publisher: publish.yml on tabman2026/aquote-router

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page