pyqauto 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. pyqauto-0.3.0/CHANGELOG.md +52 -0
  2. pyqauto-0.3.0/CODE_OF_CONDUCT.md +7 -0
  3. pyqauto-0.3.0/CONTRIBUTING.md +30 -0
  4. pyqauto-0.3.0/LICENSE +21 -0
  5. pyqauto-0.3.0/MANIFEST.in +25 -0
  6. pyqauto-0.3.0/PKG-INFO +299 -0
  7. pyqauto-0.3.0/README.md +263 -0
  8. pyqauto-0.3.0/README.zh-CN.md +225 -0
  9. pyqauto-0.3.0/SECURITY.md +7 -0
  10. pyqauto-0.3.0/config/pytdx_servers.example.json +23 -0
  11. pyqauto-0.3.0/config/source_policy.example.yaml +51 -0
  12. pyqauto-0.3.0/docs/API_REFERENCE.md +125 -0
  13. pyqauto-0.3.0/docs/AUDIT_TRAIL.md +28 -0
  14. pyqauto-0.3.0/docs/CLI_REFERENCE.md +76 -0
  15. pyqauto-0.3.0/docs/COMPETITOR_NOTES.md +10 -0
  16. pyqauto-0.3.0/docs/CONTRIBUTOR_ADAPTER_GUIDE.md +18 -0
  17. pyqauto-0.3.0/docs/DATA_SOURCES.md +58 -0
  18. pyqauto-0.3.0/docs/ERROR_CODES.md +26 -0
  19. pyqauto-0.3.0/docs/FAQ.md +21 -0
  20. pyqauto-0.3.0/docs/GITHUB_ABOUT_SETUP.md +32 -0
  21. pyqauto-0.3.0/docs/ISSUE_GUIDE.md +152 -0
  22. pyqauto-0.3.0/docs/KLINE_GUIDE.md +94 -0
  23. pyqauto-0.3.0/docs/LIVE_CHECK.md +104 -0
  24. pyqauto-0.3.0/docs/MAINTAINER_CHECKLIST.md +78 -0
  25. pyqauto-0.3.0/docs/MIGRATION_FROM_AQUOTE_ROUTER.md +70 -0
  26. pyqauto-0.3.0/docs/NEW_USER_START_HERE.md +112 -0
  27. pyqauto-0.3.0/docs/QUICKSTART.md +37 -0
  28. pyqauto-0.3.0/docs/RELEASE_CHECKLIST.md +35 -0
  29. pyqauto-0.3.0/docs/RELEASE_STATUS.md +19 -0
  30. pyqauto-0.3.0/docs/RETURN_FIELDS.md +53 -0
  31. pyqauto-0.3.0/docs/ROADMAP.md +26 -0
  32. pyqauto-0.3.0/docs/SOURCE_POLICY.md +80 -0
  33. pyqauto-0.3.0/docs/SYMBOL_RULES.md +16 -0
  34. pyqauto-0.3.0/docs/TIME_AND_TRADING_DAY.md +17 -0
  35. pyqauto-0.3.0/docs/TROUBLESHOOTING.md +68 -0
  36. pyqauto-0.3.0/docs/UNITS.md +33 -0
  37. pyqauto-0.3.0/docs/UPSTREAM_LICENSE_AND_RISK.md +18 -0
  38. pyqauto-0.3.0/docs/zh-CN/README.md +21 -0
  39. pyqauto-0.3.0/examples/audit_demo.py +22 -0
  40. pyqauto-0.3.0/examples/daily_kline_demo.py +18 -0
  41. pyqauto-0.3.0/examples/diagnose_demo.py +19 -0
  42. pyqauto-0.3.0/examples/full_realtime_quotes_demo.py +18 -0
  43. pyqauto-0.3.0/examples/index_realtime_demo.py +18 -0
  44. pyqauto-0.3.0/examples/kline_unified_demo.py +19 -0
  45. pyqauto-0.3.0/examples/minute_kline_15m_demo.py +18 -0
  46. pyqauto-0.3.0/examples/minute_kline_pytdx_only_demo.py +18 -0
  47. pyqauto-0.3.0/examples/realtime_quotes_demo.py +18 -0
  48. pyqauto-0.3.0/pyproject.toml +70 -0
  49. pyqauto-0.3.0/pyqauto/__init__.py +133 -0
  50. pyqauto-0.3.0/pyqauto/adapters/__init__.py +11 -0
  51. pyqauto-0.3.0/pyqauto/adapters/base.py +139 -0
  52. pyqauto-0.3.0/pyqauto/adapters/easyquotation_sina_adapter.py +100 -0
  53. pyqauto-0.3.0/pyqauto/adapters/easyquotation_tencent_adapter.py +10 -0
  54. pyqauto-0.3.0/pyqauto/adapters/pytdx_adapter.py +222 -0
  55. pyqauto-0.3.0/pyqauto/audit.py +164 -0
  56. pyqauto-0.3.0/pyqauto/cli.py +331 -0
  57. pyqauto-0.3.0/pyqauto/config/__init__.py +1 -0
  58. pyqauto-0.3.0/pyqauto/config/pytdx_servers.example.json +23 -0
  59. pyqauto-0.3.0/pyqauto/config/source_policy.example.yaml +51 -0
  60. pyqauto-0.3.0/pyqauto/diagnostics.py +209 -0
  61. pyqauto-0.3.0/pyqauto/exceptions.py +87 -0
  62. pyqauto-0.3.0/pyqauto/models.py +127 -0
  63. pyqauto-0.3.0/pyqauto/policy.py +324 -0
  64. pyqauto-0.3.0/pyqauto/pytdx_probe.py +688 -0
  65. pyqauto-0.3.0/pyqauto/router.py +407 -0
  66. pyqauto-0.3.0/pyqauto.egg-info/PKG-INFO +299 -0
  67. pyqauto-0.3.0/pyqauto.egg-info/SOURCES.txt +109 -0
  68. pyqauto-0.3.0/pyqauto.egg-info/dependency_links.txt +1 -0
  69. pyqauto-0.3.0/pyqauto.egg-info/entry_points.txt +2 -0
  70. pyqauto-0.3.0/pyqauto.egg-info/requires.txt +14 -0
  71. pyqauto-0.3.0/pyqauto.egg-info/top_level.txt +1 -0
  72. pyqauto-0.3.0/scripts/check_release.py +125 -0
  73. pyqauto-0.3.0/scripts/live_check.py +900 -0
  74. pyqauto-0.3.0/scripts/pytdx_server_probe.py +42 -0
  75. pyqauto-0.3.0/scripts/smoke_test.py +48 -0
  76. pyqauto-0.3.0/scripts/windows_acceptance.bat +17 -0
  77. pyqauto-0.3.0/setup.cfg +4 -0
  78. pyqauto-0.3.0/tests/conftest.py +8 -0
  79. pyqauto-0.3.0/tests/test_api_doc_code_consistency.py +61 -0
  80. pyqauto-0.3.0/tests/test_audit_jsonl.py +71 -0
  81. pyqauto-0.3.0/tests/test_audit_sqlite.py +74 -0
  82. pyqauto-0.3.0/tests/test_audit_trail_mentions_fallback_chain.py +12 -0
  83. pyqauto-0.3.0/tests/test_chinese_docs.py +88 -0
  84. pyqauto-0.3.0/tests/test_cli_kline.py +33 -0
  85. pyqauto-0.3.0/tests/test_cli_probe_pytdx.py +36 -0
  86. pyqauto-0.3.0/tests/test_daily_kline_policy.py +28 -0
  87. pyqauto-0.3.0/tests/test_data_sources_doc_exists.py +9 -0
  88. pyqauto-0.3.0/tests/test_data_sources_doc_mentions_sources.py +14 -0
  89. pyqauto-0.3.0/tests/test_diagnose_cli.py +63 -0
  90. pyqauto-0.3.0/tests/test_error_codes_doc.py +29 -0
  91. pyqauto-0.3.0/tests/test_examples_exist.py +24 -0
  92. pyqauto-0.3.0/tests/test_gitignore_local_active_pool.py +18 -0
  93. pyqauto-0.3.0/tests/test_issue_templates.py +61 -0
  94. pyqauto-0.3.0/tests/test_kline_unified_api.py +34 -0
  95. pyqauto-0.3.0/tests/test_live_check_docs.py +73 -0
  96. pyqauto-0.3.0/tests/test_manifest_excludes_local_logs.py +15 -0
  97. pyqauto-0.3.0/tests/test_minute_kline_periods.py +37 -0
  98. pyqauto-0.3.0/tests/test_models.py +60 -0
  99. pyqauto-0.3.0/tests/test_no_private_leak.py +49 -0
  100. pyqauto-0.3.0/tests/test_policy.py +87 -0
  101. pyqauto-0.3.0/tests/test_public_onboarding_docs.py +48 -0
  102. pyqauto-0.3.0/tests/test_pytdx_server_probe.py +204 -0
  103. pyqauto-0.3.0/tests/test_readme_links_data_sources.py +26 -0
  104. pyqauto-0.3.0/tests/test_return_fields_mentions_source.py +13 -0
  105. pyqauto-0.3.0/tests/test_roadmap_no_trading_terms.py +31 -0
  106. pyqauto-0.3.0/tests/test_router_fallback.py +243 -0
  107. pyqauto-0.3.0/tests/test_simple_api.py +97 -0
  108. pyqauto-0.3.0/tests/test_symbol_rules_doc.py +16 -0
  109. pyqauto-0.3.0/tests/test_troubleshooting_doc.py +47 -0
  110. pyqauto-0.3.0/tests/test_units_doc.py +18 -0
  111. pyqauto-0.3.0/tests/test_upstream_risk_doc.py +17 -0
@@ -0,0 +1,52 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 - 2026-06-18
4
+
5
+ - Renamed the PyPI package, Python import package, CLI command, and GitHub
6
+ repository to `pyqauto`.
7
+ - Replaced the former `aquote-router` package name and `aquote_router` import
8
+ path with `pyqauto`.
9
+ - Kept the public quote, K-line, source policy, diagnostics, and audit behavior
10
+ unchanged.
11
+ - Added migration documentation for users moving from the old package name.
12
+ - Kept the release path on GitHub Actions Trusted Publishing only; no local
13
+ twine upload or password-based PyPI publishing is used.
14
+
15
+ ## 0.2.2 - 2026-06-17
16
+
17
+ - Bundled default source policy and pytdx server config as package data.
18
+ - Added the short `aquote` import alias and simple module-level functions such as
19
+ `quote`, `quotes`, `kline`, and `daily`.
20
+ - Allowed `QuoteRouter.from_config()` to run without user-supplied config paths.
21
+ - Preserved compatibility for legacy `config/source_policy.example.yaml` and
22
+ `config/pytdx_servers.example.json` example paths when local files are absent.
23
+ - Updated public examples and quickstart docs to avoid requiring copied config files.
24
+
25
+ ## 0.2.1 - 2026-06-15
26
+
27
+ - Added and documented pytdx server probe diagnostics.
28
+ - Added `pyqauto probe-pytdx`.
29
+ - Strengthened K-line timeout troubleshooting docs.
30
+ - Strengthened live check docs for active local pytdx pools.
31
+ - Clarified that active local server pools are not committed to Git.
32
+ - Kept the project boundary unchanged and added no investment advice workflow.
33
+
34
+ ## 0.2.0 - 2026-06-15
35
+
36
+ - Added `daily_kline`.
37
+ - Added unified `kline`.
38
+ - Documented all supported minute K-line periods including `15m`.
39
+ - Added `DATA_SOURCES`, `API_REFERENCE`, `KLINE_GUIDE`, `RETURN_FIELDS`, and `CLI_REFERENCE`.
40
+ - Added troubleshooting, error code, symbol, time, unit, upstream risk, roadmap and adapter contributor docs.
41
+ - Added stable error codes and enhanced `pyqauto diagnose --json`.
42
+ - Added issue templates for bug reports, data source failures, adapter requests and documentation issues.
43
+ - Added offline tests for open-source maintenance and diagnostics workflows.
44
+
45
+ ## 0.1.0 - 2026-06-14
46
+
47
+ - Initial open-source release.
48
+ - Added pytdx server pool routing with primary, hot backup and backup roles.
49
+ - Added easyquotation Sina and Tencent fallback for realtime APIs.
50
+ - Added pytdx-only minute kline routing.
51
+ - Added source policy, normalized quote model, JSONL audit and SQLite audit.
52
+ - Added CLI, examples, tests, GitHub Actions and release checklist.
@@ -0,0 +1,7 @@
1
+ # Code of Conduct
2
+
3
+ We follow the Contributor Covenant spirit: be respectful, constructive and focused on improving the project.
4
+
5
+ Harassment, discrimination, spam and abusive behavior are not acceptable in project spaces.
6
+
7
+ Maintainers may edit, hide or remove content that is hostile, off-topic or unsafe for public collaboration.
@@ -0,0 +1,30 @@
1
+ # Contributing
2
+
3
+ Thank you for helping improve pyqauto.
4
+
5
+ ## Development
6
+
7
+ ```bash
8
+ python -X utf8 -m pip install -e ".[dev,test]"
9
+ python -X utf8 -m pytest -q
10
+ python -X utf8 scripts/check_release.py
11
+ ```
12
+
13
+ ## Rules
14
+
15
+ - Keep Python source files UTF-8.
16
+ - Use explicit `encoding="utf-8"` for text reads and writes.
17
+ - Default tests must not connect to live quote sources.
18
+ - Live smoke tests must require `ENABLE_LIVE_SMOKE_TEST=1`.
19
+ - Add adapter tests before adding a real data source.
20
+ - Preserve normalized fields and audit schema compatibility.
21
+ - Do not commit private configuration, credentials or local absolute paths.
22
+
23
+ ## Pull Requests
24
+
25
+ Every pull request should include:
26
+
27
+ - What changed.
28
+ - Which tests ran.
29
+ - Whether source policy or audit schema changed.
30
+ - Any user-visible compatibility notes.
pyqauto-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aquote-router contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,25 @@
1
+ include README.md
2
+ include README.zh-CN.md
3
+ include LICENSE
4
+ include CHANGELOG.md
5
+ include CONTRIBUTING.md
6
+ include SECURITY.md
7
+ include CODE_OF_CONDUCT.md
8
+ include pyproject.toml
9
+ recursive-include config *.json *.yaml
10
+ recursive-include pyqauto/config *.json *.yaml
11
+ recursive-include docs *.md
12
+ recursive-include examples *.py
13
+ recursive-include scripts *.py *.bat
14
+ recursive-include tests *.py
15
+ prune logs
16
+ exclude config/pytdx_servers.active.local.json
17
+ exclude config/pytdx_servers.local.json
18
+ exclude LIVE_CHECK_REPORT.md
19
+ exclude LIVE_CHECK_SUMMARY.json
20
+ exclude LIVE_CHECK_LOG.txt
21
+ exclude PYTDX_SERVER_POOL_REFRESH_REPORT.md
22
+ exclude PYTDX_SERVER_POOL_REFRESH_SUMMARY.json
23
+ exclude PYTDX_SERVER_POOL_REFRESH_LOG.txt
24
+ global-exclude *.jsonl
25
+ global-exclude *.sqlite3
pyqauto-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,299 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyqauto
3
+ Version: 0.3.0
4
+ Summary: A-share quote source router with pytdx failover, easyquotation fallback and audit trail
5
+ Author: pyqauto contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/tabman2026/pyqauto
8
+ Project-URL: Repository, https://github.com/tabman2026/pyqauto
9
+ Project-URL: Documentation, https://github.com/tabman2026/pyqauto/tree/main/docs
10
+ Project-URL: Issues, https://github.com/tabman2026/pyqauto/issues
11
+ Project-URL: Changelog, https://github.com/tabman2026/pyqauto/blob/main/CHANGELOG.md
12
+ Keywords: a-share,stock-market,quote-router,market-data,pytdx,easyquotation
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: click>=8.1
25
+ Requires-Dist: easyquotation>=0.7
26
+ Requires-Dist: pytdx>=1.72
27
+ Requires-Dist: PyYAML>=6.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: build>=1.2; extra == "dev"
30
+ Requires-Dist: ruff>=0.5; extra == "dev"
31
+ Provides-Extra: test
32
+ Requires-Dist: pytest>=8.0; extra == "test"
33
+ Requires-Dist: pytest-cov>=5.0; extra == "test"
34
+ Provides-Extra: docs
35
+ Dynamic: license-file
36
+
37
+ # pyqauto
38
+
39
+ pyqauto 是一个面向 A 股行情获取的 Python 行情源自动选择工具,支持 pytdx 主备切换、easyquotation fallback、实时行情、分钟K线、日K、统一 kline 接口、source policy 和 JSONL / SQLite 审计追踪。
40
+
41
+ Python A-share quote auto-selector with pytdx failover, easyquotation fallback, K-line APIs and audit trail.
42
+
43
+ ```bash
44
+ python -X utf8 -m pip install pyqauto -i https://pypi.org/simple
45
+ ```
46
+
47
+ ```python
48
+ from pyqauto import QuoteRouter
49
+ ```
50
+
51
+ ```bash
52
+ pyqauto realtime 000001 600000
53
+ pyqauto kline 000001 --period 15m --count 10
54
+ pyqauto probe-pytdx --json
55
+ ```
56
+
57
+ 本项目不提供投资建议,不生成候选股池,不生成买卖点,不接入真实交易,不保证公开免费行情源 100% 准确、实时、完整、可用。
58
+
59
+ [![PyPI version](https://img.shields.io/pypi/v/pyqauto.svg)](https://pypi.org/project/pyqauto/)
60
+ [![Python versions](https://img.shields.io/pypi/pyversions/pyqauto.svg)](https://pypi.org/project/pyqauto/)
61
+ [![CI](https://github.com/tabman2026/pyqauto/actions/workflows/ci.yml/badge.svg)](https://github.com/tabman2026/pyqauto/actions/workflows/ci.yml)
62
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
63
+ [![GitHub Release](https://img.shields.io/github/v/release/tabman2026/pyqauto?display_name=tag)](https://github.com/tabman2026/pyqauto/releases)
64
+
65
+ It is designed for research scripts that need A股行情, A股实时行情, A股K线,
66
+ 分钟K线, 15分钟K线, 日K, source policy, 数据源 fallback, 行情审计, `trace_id`,
67
+ JSONL, and SQLite audit records in one small Python package. Realtime routing
68
+ uses pytdx first, then easyquotation Sina and Tencent fallback according to
69
+ policy.
70
+
71
+ Boundary: this project is data access infrastructure only. It does not provide investment advice,
72
+ account login, order execution, screening, timing signals, or performance claims.
73
+
74
+ ## 中文文档
75
+
76
+ - 中文快速开始:[README.zh-CN.md](README.zh-CN.md)
77
+ - 新手从这里开始:[docs/NEW_USER_START_HERE.md](docs/NEW_USER_START_HERE.md)
78
+ - K线使用指南:[docs/KLINE_GUIDE.md](docs/KLINE_GUIDE.md)
79
+ - 数据源说明:[docs/DATA_SOURCES.md](docs/DATA_SOURCES.md)
80
+ - 常见问题排查:[docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)
81
+
82
+ English start here: [docs/NEW_USER_START_HERE.md](docs/NEW_USER_START_HERE.md)
83
+
84
+ Data source policy: [docs/DATA_SOURCES.md](docs/DATA_SOURCES.md)
85
+
86
+ Issue guide: [docs/ISSUE_GUIDE.md](docs/ISSUE_GUIDE.md)
87
+
88
+ Examples: [realtime](examples/realtime_quotes_demo.py),
89
+ [15m K-line](examples/minute_kline_15m_demo.py), and
90
+ [daily K-line](examples/daily_kline_demo.py)
91
+
92
+ ## Install
93
+
94
+ ```bash
95
+ python -X utf8 -m pip install pyqauto
96
+ ```
97
+
98
+ ## Minimal Realtime Quote
99
+
100
+ ```python
101
+ import pyqauto as aq
102
+
103
+ record = aq.quote("000001")
104
+ print(record.to_dict())
105
+ ```
106
+
107
+ Default source policy and pytdx server config are bundled in the package.
108
+ Import and call functions directly. No local config files are required.
109
+
110
+ ## Minimal 15m K-line
111
+
112
+ ```python
113
+ bars = aq.kline("000001", period="15m", count=120)
114
+ print(bars[0].to_dict())
115
+ ```
116
+
117
+ ## K-line Timeout Check
118
+
119
+ K-line APIs are pytdx-only. If a K-line call times out, first probe the pytdx
120
+ server pool for the current network:
121
+
122
+ ```bash
123
+ pyqauto probe-pytdx --json --output config/pytdx_servers.active.local.json
124
+ ```
125
+
126
+ Then pass the active local pool explicitly:
127
+
128
+ ```bash
129
+ pyqauto kline 000001 --period 15m --count 10 \
130
+ --pytdx-servers config/pytdx_servers.active.local.json --json
131
+ ```
132
+
133
+ `config/pytdx_servers.active.local.json` is a local diagnostic result and should
134
+ not be committed.
135
+
136
+ ## Features
137
+
138
+ - `realtime_quotes`, `full_realtime_quotes`, and `index_realtime` route through
139
+ `pytdx -> easyquotation_sina -> easyquotation_tencent`.
140
+ - `minute_kline`, `daily_kline`, and unified `kline` are pytdx-only.
141
+ - pytdx servers are ordered by `primary -> hot_backup -> backup`, then by
142
+ `latency_ms`.
143
+ - `probe-pytdx` can generate a local active pytdx server pool for diagnostics.
144
+ - Return models include `source`, `source_level`, `is_fallback`,
145
+ `fallback_from`, and `trace_id`.
146
+ - JSONL and SQLite audit logs record attempts, `fallback_chain`,
147
+ `selected_source`, duration, record count, and final error details.
148
+ - The default test suite is offline. Live smoke checks require explicit opt-in.
149
+
150
+ Local development:
151
+
152
+ ```bash
153
+ python -X utf8 -m pip install -e ".[dev,test]"
154
+ ```
155
+
156
+ ## Quick Start
157
+
158
+ ```python
159
+ import pyqauto as aq
160
+
161
+ aq.configure(
162
+ audit_jsonl_path="logs/pyqauto_audit.jsonl",
163
+ audit_sqlite_path="logs/pyqauto_audit.sqlite3",
164
+ )
165
+
166
+ records = aq.quotes(["000001", "600000"])
167
+ for record in records:
168
+ print(record.to_dict())
169
+ ```
170
+
171
+ K-line examples:
172
+
173
+ ```python
174
+ aq.minute("000001", period="15m", count=120)
175
+ aq.daily("000001", count=120)
176
+ aq.kline("000001", period="1d", count=120)
177
+ ```
178
+
179
+ ## Public API
180
+
181
+ ```python
182
+ aq.quote("000001")
183
+ aq.quotes(["000001", "600000"])
184
+ aq.full_quotes(["000001", "600000"])
185
+ aq.index(["000001", "399001"])
186
+ aq.minute("000001", period="15m", count=120)
187
+ aq.daily("000001", count=120)
188
+ aq.kline("000001", period="1d", count=120)
189
+ aq.diagnose()
190
+ ```
191
+
192
+ For advanced use, `from pyqauto import QuoteRouter` remains available.
193
+
194
+ ## CLI
195
+
196
+ ```bash
197
+ pyqauto realtime 000001 600000
198
+ pyqauto full 000001 600000
199
+ pyqauto full-realtime 000001 600000
200
+ pyqauto index 000001 399001
201
+ pyqauto minute 000001 --period 15m --count 120
202
+ pyqauto daily 000001 --count 120
203
+ pyqauto kline 000001 --period 15m --count 120
204
+ pyqauto kline 000001 --period 1d --count 120
205
+ pyqauto probe-pytdx --json --output config/pytdx_servers.active.local.json
206
+ pyqauto diagnose --json
207
+ ```
208
+
209
+ Use `--json` for complete output, especially when table columns are too wide.
210
+ CLI failures return a non-zero exit code and a structured project error code.
211
+
212
+ When K-line calls time out, first refresh a local pytdx pool:
213
+
214
+ ```bash
215
+ pyqauto probe-pytdx --json --output config/pytdx_servers.active.local.json
216
+ ```
217
+
218
+ Then pass the active local pool explicitly:
219
+
220
+ ```bash
221
+ pyqauto kline 000001 --period 15m --count 10 \
222
+ --pytdx-servers config/pytdx_servers.active.local.json --json
223
+ ```
224
+
225
+ `config/pytdx_servers.active.local.json` is an observed local diagnostic result
226
+ and should not be committed. Free pytdx server availability changes by network,
227
+ region, and time; this project does not promise that every environment can
228
+ connect at every time.
229
+
230
+ ## Source Policy
231
+
232
+ Default realtime routing:
233
+
234
+ ```text
235
+ realtime_quotes: pytdx -> easyquotation_sina -> easyquotation_tencent
236
+ full_realtime_quotes: pytdx -> easyquotation_sina -> easyquotation_tencent
237
+ index_realtime: pytdx -> easyquotation_sina -> easyquotation_tencent
238
+ ```
239
+
240
+ Default K-line routing:
241
+
242
+ ```text
243
+ minute_kline: pytdx only
244
+ daily_kline: pytdx only
245
+ kline: pytdx only
246
+ ```
247
+
248
+ K-line APIs never fall back to easyquotation and never fabricate bars.
249
+ Realtime APIs may fall back to `easyquotation_sina` or `easyquotation_tencent`
250
+ after pytdx failures, but K-line APIs do not use easyquotation fallback.
251
+
252
+ ## Core Docs
253
+
254
+ - [Quickstart](docs/QUICKSTART.md)
255
+ - [Start here](docs/NEW_USER_START_HERE.md)
256
+ - [API reference](docs/API_REFERENCE.md)
257
+ - [K-line guide](docs/KLINE_GUIDE.md)
258
+ - [Data sources](docs/DATA_SOURCES.md)
259
+ - [Issue guide](docs/ISSUE_GUIDE.md)
260
+ - [Return fields](docs/RETURN_FIELDS.md)
261
+ - [CLI reference](docs/CLI_REFERENCE.md)
262
+ - [Troubleshooting](docs/TROUBLESHOOTING.md)
263
+ - [Error codes](docs/ERROR_CODES.md)
264
+ - [Symbol rules](docs/SYMBOL_RULES.md)
265
+ - [Units](docs/UNITS.md)
266
+ - [Source policy](docs/SOURCE_POLICY.md)
267
+ - [Audit trail](docs/AUDIT_TRAIL.md)
268
+ - [Time and trading day](docs/TIME_AND_TRADING_DAY.md)
269
+ - [Upstream license and risk](docs/UPSTREAM_LICENSE_AND_RISK.md)
270
+ - [Roadmap](docs/ROADMAP.md)
271
+ - [Contributor adapter guide](docs/CONTRIBUTOR_ADAPTER_GUIDE.md)
272
+ - [Maintainer checklist](docs/MAINTAINER_CHECKLIST.md)
273
+
274
+ ## Audit Trail
275
+
276
+ Each routed call receives a `trace_id`. Audit records include:
277
+
278
+ - `api_name`
279
+ - `symbols`
280
+ - `started_at`, `finished_at`, `duration_ms`
281
+ - `selected_source`, `selected_source_level`
282
+ - `attempts`
283
+ - `fallback_chain`
284
+ - `success`
285
+ - `error_type`, `error_message`
286
+ - `record_count`
287
+
288
+ See [docs/AUDIT_TRAIL.md](docs/AUDIT_TRAIL.md).
289
+
290
+ ## Risk Notice
291
+
292
+ This package does not produce market data. It calls upstream public Python
293
+ libraries and their public interfaces. Upstream data may be delayed,
294
+ unavailable, incomplete, or structurally changed. Users are responsible for
295
+ validating data quality and following the terms of each upstream project.
296
+
297
+ ## License
298
+
299
+ MIT License. See [LICENSE](LICENSE).
@@ -0,0 +1,263 @@
1
+ # pyqauto
2
+
3
+ pyqauto 是一个面向 A 股行情获取的 Python 行情源自动选择工具,支持 pytdx 主备切换、easyquotation fallback、实时行情、分钟K线、日K、统一 kline 接口、source policy 和 JSONL / SQLite 审计追踪。
4
+
5
+ Python A-share quote auto-selector with pytdx failover, easyquotation fallback, K-line APIs and audit trail.
6
+
7
+ ```bash
8
+ python -X utf8 -m pip install pyqauto -i https://pypi.org/simple
9
+ ```
10
+
11
+ ```python
12
+ from pyqauto import QuoteRouter
13
+ ```
14
+
15
+ ```bash
16
+ pyqauto realtime 000001 600000
17
+ pyqauto kline 000001 --period 15m --count 10
18
+ pyqauto probe-pytdx --json
19
+ ```
20
+
21
+ 本项目不提供投资建议,不生成候选股池,不生成买卖点,不接入真实交易,不保证公开免费行情源 100% 准确、实时、完整、可用。
22
+
23
+ [![PyPI version](https://img.shields.io/pypi/v/pyqauto.svg)](https://pypi.org/project/pyqauto/)
24
+ [![Python versions](https://img.shields.io/pypi/pyversions/pyqauto.svg)](https://pypi.org/project/pyqauto/)
25
+ [![CI](https://github.com/tabman2026/pyqauto/actions/workflows/ci.yml/badge.svg)](https://github.com/tabman2026/pyqauto/actions/workflows/ci.yml)
26
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
27
+ [![GitHub Release](https://img.shields.io/github/v/release/tabman2026/pyqauto?display_name=tag)](https://github.com/tabman2026/pyqauto/releases)
28
+
29
+ It is designed for research scripts that need A股行情, A股实时行情, A股K线,
30
+ 分钟K线, 15分钟K线, 日K, source policy, 数据源 fallback, 行情审计, `trace_id`,
31
+ JSONL, and SQLite audit records in one small Python package. Realtime routing
32
+ uses pytdx first, then easyquotation Sina and Tencent fallback according to
33
+ policy.
34
+
35
+ Boundary: this project is data access infrastructure only. It does not provide investment advice,
36
+ account login, order execution, screening, timing signals, or performance claims.
37
+
38
+ ## 中文文档
39
+
40
+ - 中文快速开始:[README.zh-CN.md](README.zh-CN.md)
41
+ - 新手从这里开始:[docs/NEW_USER_START_HERE.md](docs/NEW_USER_START_HERE.md)
42
+ - K线使用指南:[docs/KLINE_GUIDE.md](docs/KLINE_GUIDE.md)
43
+ - 数据源说明:[docs/DATA_SOURCES.md](docs/DATA_SOURCES.md)
44
+ - 常见问题排查:[docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md)
45
+
46
+ English start here: [docs/NEW_USER_START_HERE.md](docs/NEW_USER_START_HERE.md)
47
+
48
+ Data source policy: [docs/DATA_SOURCES.md](docs/DATA_SOURCES.md)
49
+
50
+ Issue guide: [docs/ISSUE_GUIDE.md](docs/ISSUE_GUIDE.md)
51
+
52
+ Examples: [realtime](examples/realtime_quotes_demo.py),
53
+ [15m K-line](examples/minute_kline_15m_demo.py), and
54
+ [daily K-line](examples/daily_kline_demo.py)
55
+
56
+ ## Install
57
+
58
+ ```bash
59
+ python -X utf8 -m pip install pyqauto
60
+ ```
61
+
62
+ ## Minimal Realtime Quote
63
+
64
+ ```python
65
+ import pyqauto as aq
66
+
67
+ record = aq.quote("000001")
68
+ print(record.to_dict())
69
+ ```
70
+
71
+ Default source policy and pytdx server config are bundled in the package.
72
+ Import and call functions directly. No local config files are required.
73
+
74
+ ## Minimal 15m K-line
75
+
76
+ ```python
77
+ bars = aq.kline("000001", period="15m", count=120)
78
+ print(bars[0].to_dict())
79
+ ```
80
+
81
+ ## K-line Timeout Check
82
+
83
+ K-line APIs are pytdx-only. If a K-line call times out, first probe the pytdx
84
+ server pool for the current network:
85
+
86
+ ```bash
87
+ pyqauto probe-pytdx --json --output config/pytdx_servers.active.local.json
88
+ ```
89
+
90
+ Then pass the active local pool explicitly:
91
+
92
+ ```bash
93
+ pyqauto kline 000001 --period 15m --count 10 \
94
+ --pytdx-servers config/pytdx_servers.active.local.json --json
95
+ ```
96
+
97
+ `config/pytdx_servers.active.local.json` is a local diagnostic result and should
98
+ not be committed.
99
+
100
+ ## Features
101
+
102
+ - `realtime_quotes`, `full_realtime_quotes`, and `index_realtime` route through
103
+ `pytdx -> easyquotation_sina -> easyquotation_tencent`.
104
+ - `minute_kline`, `daily_kline`, and unified `kline` are pytdx-only.
105
+ - pytdx servers are ordered by `primary -> hot_backup -> backup`, then by
106
+ `latency_ms`.
107
+ - `probe-pytdx` can generate a local active pytdx server pool for diagnostics.
108
+ - Return models include `source`, `source_level`, `is_fallback`,
109
+ `fallback_from`, and `trace_id`.
110
+ - JSONL and SQLite audit logs record attempts, `fallback_chain`,
111
+ `selected_source`, duration, record count, and final error details.
112
+ - The default test suite is offline. Live smoke checks require explicit opt-in.
113
+
114
+ Local development:
115
+
116
+ ```bash
117
+ python -X utf8 -m pip install -e ".[dev,test]"
118
+ ```
119
+
120
+ ## Quick Start
121
+
122
+ ```python
123
+ import pyqauto as aq
124
+
125
+ aq.configure(
126
+ audit_jsonl_path="logs/pyqauto_audit.jsonl",
127
+ audit_sqlite_path="logs/pyqauto_audit.sqlite3",
128
+ )
129
+
130
+ records = aq.quotes(["000001", "600000"])
131
+ for record in records:
132
+ print(record.to_dict())
133
+ ```
134
+
135
+ K-line examples:
136
+
137
+ ```python
138
+ aq.minute("000001", period="15m", count=120)
139
+ aq.daily("000001", count=120)
140
+ aq.kline("000001", period="1d", count=120)
141
+ ```
142
+
143
+ ## Public API
144
+
145
+ ```python
146
+ aq.quote("000001")
147
+ aq.quotes(["000001", "600000"])
148
+ aq.full_quotes(["000001", "600000"])
149
+ aq.index(["000001", "399001"])
150
+ aq.minute("000001", period="15m", count=120)
151
+ aq.daily("000001", count=120)
152
+ aq.kline("000001", period="1d", count=120)
153
+ aq.diagnose()
154
+ ```
155
+
156
+ For advanced use, `from pyqauto import QuoteRouter` remains available.
157
+
158
+ ## CLI
159
+
160
+ ```bash
161
+ pyqauto realtime 000001 600000
162
+ pyqauto full 000001 600000
163
+ pyqauto full-realtime 000001 600000
164
+ pyqauto index 000001 399001
165
+ pyqauto minute 000001 --period 15m --count 120
166
+ pyqauto daily 000001 --count 120
167
+ pyqauto kline 000001 --period 15m --count 120
168
+ pyqauto kline 000001 --period 1d --count 120
169
+ pyqauto probe-pytdx --json --output config/pytdx_servers.active.local.json
170
+ pyqauto diagnose --json
171
+ ```
172
+
173
+ Use `--json` for complete output, especially when table columns are too wide.
174
+ CLI failures return a non-zero exit code and a structured project error code.
175
+
176
+ When K-line calls time out, first refresh a local pytdx pool:
177
+
178
+ ```bash
179
+ pyqauto probe-pytdx --json --output config/pytdx_servers.active.local.json
180
+ ```
181
+
182
+ Then pass the active local pool explicitly:
183
+
184
+ ```bash
185
+ pyqauto kline 000001 --period 15m --count 10 \
186
+ --pytdx-servers config/pytdx_servers.active.local.json --json
187
+ ```
188
+
189
+ `config/pytdx_servers.active.local.json` is an observed local diagnostic result
190
+ and should not be committed. Free pytdx server availability changes by network,
191
+ region, and time; this project does not promise that every environment can
192
+ connect at every time.
193
+
194
+ ## Source Policy
195
+
196
+ Default realtime routing:
197
+
198
+ ```text
199
+ realtime_quotes: pytdx -> easyquotation_sina -> easyquotation_tencent
200
+ full_realtime_quotes: pytdx -> easyquotation_sina -> easyquotation_tencent
201
+ index_realtime: pytdx -> easyquotation_sina -> easyquotation_tencent
202
+ ```
203
+
204
+ Default K-line routing:
205
+
206
+ ```text
207
+ minute_kline: pytdx only
208
+ daily_kline: pytdx only
209
+ kline: pytdx only
210
+ ```
211
+
212
+ K-line APIs never fall back to easyquotation and never fabricate bars.
213
+ Realtime APIs may fall back to `easyquotation_sina` or `easyquotation_tencent`
214
+ after pytdx failures, but K-line APIs do not use easyquotation fallback.
215
+
216
+ ## Core Docs
217
+
218
+ - [Quickstart](docs/QUICKSTART.md)
219
+ - [Start here](docs/NEW_USER_START_HERE.md)
220
+ - [API reference](docs/API_REFERENCE.md)
221
+ - [K-line guide](docs/KLINE_GUIDE.md)
222
+ - [Data sources](docs/DATA_SOURCES.md)
223
+ - [Issue guide](docs/ISSUE_GUIDE.md)
224
+ - [Return fields](docs/RETURN_FIELDS.md)
225
+ - [CLI reference](docs/CLI_REFERENCE.md)
226
+ - [Troubleshooting](docs/TROUBLESHOOTING.md)
227
+ - [Error codes](docs/ERROR_CODES.md)
228
+ - [Symbol rules](docs/SYMBOL_RULES.md)
229
+ - [Units](docs/UNITS.md)
230
+ - [Source policy](docs/SOURCE_POLICY.md)
231
+ - [Audit trail](docs/AUDIT_TRAIL.md)
232
+ - [Time and trading day](docs/TIME_AND_TRADING_DAY.md)
233
+ - [Upstream license and risk](docs/UPSTREAM_LICENSE_AND_RISK.md)
234
+ - [Roadmap](docs/ROADMAP.md)
235
+ - [Contributor adapter guide](docs/CONTRIBUTOR_ADAPTER_GUIDE.md)
236
+ - [Maintainer checklist](docs/MAINTAINER_CHECKLIST.md)
237
+
238
+ ## Audit Trail
239
+
240
+ Each routed call receives a `trace_id`. Audit records include:
241
+
242
+ - `api_name`
243
+ - `symbols`
244
+ - `started_at`, `finished_at`, `duration_ms`
245
+ - `selected_source`, `selected_source_level`
246
+ - `attempts`
247
+ - `fallback_chain`
248
+ - `success`
249
+ - `error_type`, `error_message`
250
+ - `record_count`
251
+
252
+ See [docs/AUDIT_TRAIL.md](docs/AUDIT_TRAIL.md).
253
+
254
+ ## Risk Notice
255
+
256
+ This package does not produce market data. It calls upstream public Python
257
+ libraries and their public interfaces. Upstream data may be delayed,
258
+ unavailable, incomplete, or structurally changed. Users are responsible for
259
+ validating data quality and following the terms of each upstream project.
260
+
261
+ ## License
262
+
263
+ MIT License. See [LICENSE](LICENSE).