chstockdata 0.2.0__tar.gz → 0.4.2__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.
- chstockdata-0.4.2/MANIFEST.in +6 -0
- {chstockdata-0.2.0/src/chstockdata.egg-info → chstockdata-0.4.2}/PKG-INFO +72 -9
- {chstockdata-0.2.0 → chstockdata-0.4.2}/README.md +66 -5
- chstockdata-0.4.2/docs/audits/evidence/2026-10-10-v0.4.2-tdx-historical-execution/tdx_history_responses.jsonl +24 -0
- chstockdata-0.4.2/docs/audits/evidence/2026-10-10-v0.4.2-tdx-historical-execution/tdx_opening_page_final_responses.jsonl +4 -0
- chstockdata-0.4.2/docs/audits/evidence/2026-10-10-v0.4.2-tdx-historical-execution/tdx_opening_page_followup_responses.jsonl +7 -0
- chstockdata-0.4.2/docs/audits/evidence/2026-10-10-v0.4.2-tdx-historical-execution/tdx_opening_page_responses.jsonl +9 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/pyproject.toml +7 -5
- chstockdata-0.4.2/scripts/check_release_version.py +215 -0
- chstockdata-0.4.2/scripts/check_rh1_static.py +222 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/__init__.py +241 -179
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/_easy_tdx_bridge.py +293 -293
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/a_stock.py +8071 -7606
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/adjusted_bars.py +728 -725
- chstockdata-0.4.2/src/chstockdata/capabilities.py +221 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/config.py +36 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/corporate_actions.py +859 -422
- chstockdata-0.4.2/src/chstockdata/daily_bars.py +910 -0
- chstockdata-0.4.2/src/chstockdata/delisting.py +484 -0
- chstockdata-0.4.2/src/chstockdata/fetch_result.py +342 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/mcp_server.py +29 -12
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/northbound_data.py +585 -585
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/northbound_store.py +219 -219
- chstockdata-0.4.2/src/chstockdata/opening_evidence.py +533 -0
- chstockdata-0.4.2/src/chstockdata/opening_known_events.json +96 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/point_in_time.py +140 -140
- chstockdata-0.4.2/src/chstockdata/quote_chain.py +438 -0
- chstockdata-0.4.2/src/chstockdata/routing_observation.py +61 -0
- chstockdata-0.4.2/src/chstockdata/suspension.py +301 -0
- chstockdata-0.4.2/src/chstockdata/tradability.py +336 -0
- chstockdata-0.4.2/src/chstockdata/trading_calendar.py +843 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/vendor_errors.py +37 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/vipdoc_history.py +48 -13
- {chstockdata-0.2.0 → chstockdata-0.4.2/src/chstockdata.egg-info}/PKG-INFO +72 -9
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata.egg-info/SOURCES.txt +53 -1
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata.egg-info/requires.txt +5 -2
- chstockdata-0.4.2/tests/fixtures/block_trades/eastmoney-600519-2025-12-12-sanitized.json +32 -0
- chstockdata-0.4.2/tests/fixtures/market_breadth/real_2026-09-04_close.json +178 -0
- chstockdata-0.4.2/tests/fixtures/market_breadth/real_2026-09-07_intraday.json +217 -0
- chstockdata-0.4.2/tests/fixtures/opening/159509-20260911.pdf +0 -0
- chstockdata-0.4.2/tests/fixtures/opening/manifest.json +31 -0
- chstockdata-0.4.2/tests/fixtures/opening/sse_688432_interval.bin +1 -0
- chstockdata-0.4.2/tests/fixtures/opening/szse_159509_announcements_control.bin +1 -0
- chstockdata-0.4.2/tests/fixtures/opening/szse_159915_announcements.bin +1 -0
- chstockdata-0.4.2/tests/fixtures/vipdoc/price_scale_20221230.json +87 -0
- chstockdata-0.4.2/tests/test_astock_financial_yoy_alignment.py +315 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_fundamentals_fix.py +21 -4
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_kline_vipdoc_chain.py +14 -9
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_listing_status.py +73 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_quote_fallback.py +11 -2
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_silent_failure_sentinel.py +6 -2
- chstockdata-0.4.2/tests/test_cached_ohlcv_structured.py +516 -0
- chstockdata-0.4.2/tests/test_capability_isolation.py +105 -0
- chstockdata-0.4.2/tests/test_config_and_warmup_regression.py +119 -0
- chstockdata-0.4.2/tests/test_daily_bars_contract.py +680 -0
- chstockdata-0.4.2/tests/test_daily_bars_legacy_compat.py +339 -0
- chstockdata-0.4.2/tests/test_daily_bars_routing.py +591 -0
- chstockdata-0.4.2/tests/test_daily_bars_schema.py +301 -0
- chstockdata-0.4.2/tests/test_delisting_structured.py +318 -0
- chstockdata-0.4.2/tests/test_fetch_result_core.py +410 -0
- chstockdata-0.4.2/tests/test_fund_corporate_actions.py +156 -0
- chstockdata-0.4.2/tests/test_historical_opening_evidence.py +504 -0
- chstockdata-0.4.2/tests/test_live_capability_probes.py +218 -0
- chstockdata-0.4.2/tests/test_market_date.py +25 -0
- chstockdata-0.4.2/tests/test_mcp_server.py +13 -0
- chstockdata-0.4.2/tests/test_mootdx_capability_health.py +140 -0
- chstockdata-0.4.2/tests/test_mootdx_capability_isolation.py +328 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_mootdx_server_selection.py +2 -2
- chstockdata-0.4.2/tests/test_release_version.py +54 -0
- chstockdata-0.4.2/tests/test_rh1_git_line_endings.py +52 -0
- chstockdata-0.4.2/tests/test_routing_observation.py +68 -0
- chstockdata-0.4.2/tests/test_structured_semantics_phase11.py +417 -0
- chstockdata-0.4.2/tests/test_suspension_source_semantics.py +80 -0
- chstockdata-0.4.2/tests/test_suspension_structured.py +215 -0
- chstockdata-0.4.2/tests/test_tradability.py +744 -0
- chstockdata-0.4.2/tests/test_trading_calendar_structured.py +711 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_vipdoc_history.py +17 -1
- chstockdata-0.4.2/tests/test_vipdoc_price_scale.py +162 -0
- chstockdata-0.2.0/src/chstockdata/trading_calendar.py +0 -397
- {chstockdata-0.2.0 → chstockdata-0.4.2}/LICENSE +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/NOTICE +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/setup.cfg +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/block_trades.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/board_flow.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/chips.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/etf_options.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/hot_rank.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/investor_qa.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/limit_up.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/market_breadth.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/policy_news.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/policy_news_models.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/policy_news_registry.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/policy_news_sources.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/provenance.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/py.typed +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/refresh_vipdoc.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/source_context.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/tdx_bridge.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata/utils.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata.egg-info/dependency_links.txt +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata.egg-info/entry_points.txt +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/src/chstockdata.egg-info/top_level.txt +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_cls_v1.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_daily_lhb.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_earnings_forecast.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_eastmoney_fix.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_em_post.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_interface_fix.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_lhb_seat_dimension.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_macro_indicators.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_margin_valuation.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_pledge_buyback.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_push2_source_scan.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_research_reports.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_tdx_fallback.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_tencent_quote_fix.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_ticker_routing.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_astock_v0221_fix.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_board_flow.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_calendar_consumers.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_chip_distribution.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_data_layer_live_smoke.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_easy_tdx_bridge.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_etf_options.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_free_block_trades.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_free_market_breadth.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_free_northbound_history.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_hot_rank.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_investor_qa.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_limit_up.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_refresh_vipdoc_history.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_tdx_bridge_health.py +0 -0
- {chstockdata-0.2.0 → chstockdata-0.4.2}/tests/test_tdx_request_hygiene.py +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
recursive-include tests/fixtures *
|
|
2
|
+
include scripts/check_rh1_static.py scripts/check_release_version.py
|
|
3
|
+
include docs/audits/evidence/2026-10-10-v0.4.2-tdx-historical-execution/tdx_history_responses.jsonl
|
|
4
|
+
include docs/audits/evidence/2026-10-10-v0.4.2-tdx-historical-execution/tdx_opening_page_responses.jsonl
|
|
5
|
+
include docs/audits/evidence/2026-10-10-v0.4.2-tdx-historical-execution/tdx_opening_page_followup_responses.jsonl
|
|
6
|
+
include docs/audits/evidence/2026-10-10-v0.4.2-tdx-historical-execution/tdx_opening_page_final_responses.jsonl
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chstockdata
|
|
3
|
-
Version: 0.2
|
|
4
|
-
Summary: Free China A-share market data toolkit: direct HTTP/TCP vendors (Tencent, mootdx/TDX, Eastmoney, Sina, THS, CLS, SSE/SZSE), no API keys, no third-party data
|
|
3
|
+
Version: 0.4.2
|
|
4
|
+
Summary: Free China A-share market data toolkit: direct HTTP/TCP vendors (Tencent, mootdx/TDX, Eastmoney, Sina, THS, CLS, SSE/SZSE), no API keys, no mandatory third-party market-data SDK in the core path; optional mootdx/baostock integrations
|
|
5
5
|
Author: joycoding2000
|
|
6
6
|
License: Apache License
|
|
7
7
|
Version 2.0, January 2004
|
|
@@ -232,28 +232,41 @@ Requires-Dist: lxml>=4.9.0
|
|
|
232
232
|
Requires-Dist: stockstats>=0.6.5
|
|
233
233
|
Provides-Extra: mootdx
|
|
234
234
|
Requires-Dist: mootdx>=0.10.0; extra == "mootdx"
|
|
235
|
+
Provides-Extra: opening-pdf
|
|
236
|
+
Requires-Dist: pypdf>=6.0; extra == "opening-pdf"
|
|
235
237
|
Provides-Extra: baostock
|
|
236
238
|
Requires-Dist: baostock>=0.8.9; extra == "baostock"
|
|
237
239
|
Provides-Extra: mcp
|
|
238
|
-
Requires-Dist: mcp
|
|
240
|
+
Requires-Dist: mcp<2,>=1.0; extra == "mcp"
|
|
239
241
|
Provides-Extra: dev
|
|
240
242
|
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
241
|
-
Requires-Dist: ruff
|
|
243
|
+
Requires-Dist: ruff<0.17,>=0.16.6; extra == "dev"
|
|
242
244
|
Dynamic: license-file
|
|
243
245
|
|
|
244
246
|
# chstockdata
|
|
245
247
|
|
|
246
248
|
Free China A-share market data toolkit — direct HTTP/TCP access to public
|
|
247
|
-
quote vendors, **no API keys, no third-party data
|
|
248
|
-
design)
|
|
249
|
+
quote vendors, **no API keys, no mandatory third-party market-data SDK in
|
|
250
|
+
the core path** (akshare-free by design). Optional integrations are
|
|
251
|
+
available for specific capabilities: `[mootdx]` unlocks the TCP K-line
|
|
252
|
+
primary source, `[baostock]` historical turnover for CYQ chips.
|
|
253
|
+
Battle-tested in production by
|
|
249
254
|
[TradingAgents-astock](https://github.com/joycoding2000/TradingAgents-astock).
|
|
250
255
|
|
|
251
256
|
```bash
|
|
252
|
-
pip install chstockdata # core (
|
|
257
|
+
pip install chstockdata # core package (base dependencies)
|
|
253
258
|
pip install "chstockdata[mootdx]" # + mootdx TCP K-line source (optional)
|
|
254
259
|
pip install "chstockdata[baostock]" # + historical turnover for CYQ chips (optional)
|
|
260
|
+
pip install "chstockdata[mcp]" # + MCP server entry point (optional)
|
|
255
261
|
```
|
|
256
262
|
|
|
263
|
+
The optional profiles are supported independently. The MCP extra currently
|
|
264
|
+
stays on the MCP 1.x API because the MCP 2.x server API is not compatible with
|
|
265
|
+
this entry point. Within that supported range, `mootdx` pins `httpx==0.25.2`
|
|
266
|
+
while MCP 1.x requires `httpx>=0.27.1`; a clean resolver therefore rejects
|
|
267
|
+
`chstockdata[mootdx,mcp]`. Keep those two profiles in separate environments
|
|
268
|
+
until the upstream constraints converge.
|
|
269
|
+
|
|
257
270
|
```python
|
|
258
271
|
from chstockdata import get_stock_data, get_realtime_snapshot, resolve_ticker
|
|
259
272
|
|
|
@@ -262,7 +275,55 @@ df = get_stock_data("600519", 365) # daily OHLCV, vipdoc/mootdx/Sina chain
|
|
|
262
275
|
get_realtime_snapshot("600519") # realtime quote, Tencent -> mootdx -> Sina
|
|
263
276
|
```
|
|
264
277
|
|
|
265
|
-
|
|
278
|
+
## Structured API(v0.4.1 release candidate)
|
|
279
|
+
|
|
280
|
+
The structured surface is additive and returns `FetchResult` objects. The
|
|
281
|
+
quote route keeps its provider functions injectable; `quote_fetchers` below is
|
|
282
|
+
a mapping whose values accept the existing `fetcher(codes, fallback_from=...)`
|
|
283
|
+
shape, and `to_finite_number` is the caller's numeric coercion helper.
|
|
284
|
+
|
|
285
|
+
```python
|
|
286
|
+
from chstockdata import (
|
|
287
|
+
fetch_realtime_quotes,
|
|
288
|
+
fetch_daily_bars,
|
|
289
|
+
fetch_trading_calendar,
|
|
290
|
+
fetch_suspension_info,
|
|
291
|
+
fetch_delisting_status,
|
|
292
|
+
fetch_tradability,
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
quotes = fetch_realtime_quotes(
|
|
296
|
+
["600519"], quote_fetchers, quote_number=to_finite_number
|
|
297
|
+
)
|
|
298
|
+
bars = fetch_daily_bars("600519", "2026-01-01", "2026-09-22")
|
|
299
|
+
calendar = fetch_trading_calendar(today="2026-09-22")
|
|
300
|
+
suspension = fetch_suspension_info("600519", "2026-09-22")
|
|
301
|
+
delisting = fetch_delisting_status("600519")
|
|
302
|
+
tradability = fetch_tradability("600519", "2026-09-22")
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Consumer-facing status guide:
|
|
306
|
+
|
|
307
|
+
| Field | Meaning |
|
|
308
|
+
|---|---|
|
|
309
|
+
| `metadata.final_status` | Attempt-derived provider/routing conclusion. |
|
|
310
|
+
| `metadata.request_status` | Request-level result consumers should branch on. |
|
|
311
|
+
| `metadata.outcome_status` | Optional engine-declared request override; otherwise `None`. |
|
|
312
|
+
| `metadata.providers_used` | Providers that actually contributed the returned payload. |
|
|
313
|
+
| `metadata.limitations` | Coverage, staleness, partial-data, or validation caveats. |
|
|
314
|
+
|
|
315
|
+
Cache-only results intentionally have `attempts=[]` and
|
|
316
|
+
`final_status="skipped"`, while `request_status` may be
|
|
317
|
+
`"success"` or `"normal_empty"`. Do not mechanically treat
|
|
318
|
+
`succeeded=False` or `final_status="skipped"` as unusable cache data; use
|
|
319
|
+
`request_status` for the request decision. A `tradable=True` result only means
|
|
320
|
+
the currently covered calendar, delisting-date, and suspension facts support
|
|
321
|
+
that verdict; it does not promise complete IPO or listing-lifecycle
|
|
322
|
+
eligibility.
|
|
323
|
+
|
|
324
|
+
The public surface combines legacy callables, structured result types,
|
|
325
|
+
constants, and compatibility exports; `__all__` is not a count of functions.
|
|
326
|
+
It covers K-lines, realtime quotes, fundamentals / three financial
|
|
266
327
|
statements, valuation history, margin trading, dragon-tiger board (per-stock
|
|
267
328
|
seats and whole-market daily), lockup expiry, northbound flow, fund flow, board
|
|
268
329
|
fund flow, industry comparison, concept blocks, block trades, market breadth,
|
|
@@ -271,7 +332,9 @@ distribution, ETF option chains (T-quote + greeks + IV), investor Q&A (互动易
|
|
|
271
332
|
hot rank / popularity rank / concept hits, insider transactions, shareholder
|
|
272
333
|
pledge / buyback, corporate actions, earnings forecast, research reports, news
|
|
273
334
|
wires, policy news, macro indicators, trading calendar, delisting / suspension
|
|
274
|
-
info, and more. See `chstockdata/__init__.py` for the full export list.
|
|
335
|
+
info, and more. See `chstockdata/__init__.py` for the full export list. The
|
|
336
|
+
candidate package version is `0.4.1`; `0.3.0` is the prior consumer
|
|
337
|
+
compatibility baseline. This release candidate has not been published.
|
|
275
338
|
|
|
276
339
|
## Data sources
|
|
277
340
|
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
# chstockdata
|
|
2
2
|
|
|
3
3
|
Free China A-share market data toolkit — direct HTTP/TCP access to public
|
|
4
|
-
quote vendors, **no API keys, no third-party data
|
|
5
|
-
design)
|
|
4
|
+
quote vendors, **no API keys, no mandatory third-party market-data SDK in
|
|
5
|
+
the core path** (akshare-free by design). Optional integrations are
|
|
6
|
+
available for specific capabilities: `[mootdx]` unlocks the TCP K-line
|
|
7
|
+
primary source, `[baostock]` historical turnover for CYQ chips.
|
|
8
|
+
Battle-tested in production by
|
|
6
9
|
[TradingAgents-astock](https://github.com/joycoding2000/TradingAgents-astock).
|
|
7
10
|
|
|
8
11
|
```bash
|
|
9
|
-
pip install chstockdata # core (
|
|
12
|
+
pip install chstockdata # core package (base dependencies)
|
|
10
13
|
pip install "chstockdata[mootdx]" # + mootdx TCP K-line source (optional)
|
|
11
14
|
pip install "chstockdata[baostock]" # + historical turnover for CYQ chips (optional)
|
|
15
|
+
pip install "chstockdata[mcp]" # + MCP server entry point (optional)
|
|
12
16
|
```
|
|
13
17
|
|
|
18
|
+
The optional profiles are supported independently. The MCP extra currently
|
|
19
|
+
stays on the MCP 1.x API because the MCP 2.x server API is not compatible with
|
|
20
|
+
this entry point. Within that supported range, `mootdx` pins `httpx==0.25.2`
|
|
21
|
+
while MCP 1.x requires `httpx>=0.27.1`; a clean resolver therefore rejects
|
|
22
|
+
`chstockdata[mootdx,mcp]`. Keep those two profiles in separate environments
|
|
23
|
+
until the upstream constraints converge.
|
|
24
|
+
|
|
14
25
|
```python
|
|
15
26
|
from chstockdata import get_stock_data, get_realtime_snapshot, resolve_ticker
|
|
16
27
|
|
|
@@ -19,7 +30,55 @@ df = get_stock_data("600519", 365) # daily OHLCV, vipdoc/mootdx/Sina chain
|
|
|
19
30
|
get_realtime_snapshot("600519") # realtime quote, Tencent -> mootdx -> Sina
|
|
20
31
|
```
|
|
21
32
|
|
|
22
|
-
|
|
33
|
+
## Structured API(v0.4.1 release candidate)
|
|
34
|
+
|
|
35
|
+
The structured surface is additive and returns `FetchResult` objects. The
|
|
36
|
+
quote route keeps its provider functions injectable; `quote_fetchers` below is
|
|
37
|
+
a mapping whose values accept the existing `fetcher(codes, fallback_from=...)`
|
|
38
|
+
shape, and `to_finite_number` is the caller's numeric coercion helper.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from chstockdata import (
|
|
42
|
+
fetch_realtime_quotes,
|
|
43
|
+
fetch_daily_bars,
|
|
44
|
+
fetch_trading_calendar,
|
|
45
|
+
fetch_suspension_info,
|
|
46
|
+
fetch_delisting_status,
|
|
47
|
+
fetch_tradability,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
quotes = fetch_realtime_quotes(
|
|
51
|
+
["600519"], quote_fetchers, quote_number=to_finite_number
|
|
52
|
+
)
|
|
53
|
+
bars = fetch_daily_bars("600519", "2026-01-01", "2026-09-22")
|
|
54
|
+
calendar = fetch_trading_calendar(today="2026-09-22")
|
|
55
|
+
suspension = fetch_suspension_info("600519", "2026-09-22")
|
|
56
|
+
delisting = fetch_delisting_status("600519")
|
|
57
|
+
tradability = fetch_tradability("600519", "2026-09-22")
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Consumer-facing status guide:
|
|
61
|
+
|
|
62
|
+
| Field | Meaning |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `metadata.final_status` | Attempt-derived provider/routing conclusion. |
|
|
65
|
+
| `metadata.request_status` | Request-level result consumers should branch on. |
|
|
66
|
+
| `metadata.outcome_status` | Optional engine-declared request override; otherwise `None`. |
|
|
67
|
+
| `metadata.providers_used` | Providers that actually contributed the returned payload. |
|
|
68
|
+
| `metadata.limitations` | Coverage, staleness, partial-data, or validation caveats. |
|
|
69
|
+
|
|
70
|
+
Cache-only results intentionally have `attempts=[]` and
|
|
71
|
+
`final_status="skipped"`, while `request_status` may be
|
|
72
|
+
`"success"` or `"normal_empty"`. Do not mechanically treat
|
|
73
|
+
`succeeded=False` or `final_status="skipped"` as unusable cache data; use
|
|
74
|
+
`request_status` for the request decision. A `tradable=True` result only means
|
|
75
|
+
the currently covered calendar, delisting-date, and suspension facts support
|
|
76
|
+
that verdict; it does not promise complete IPO or listing-lifecycle
|
|
77
|
+
eligibility.
|
|
78
|
+
|
|
79
|
+
The public surface combines legacy callables, structured result types,
|
|
80
|
+
constants, and compatibility exports; `__all__` is not a count of functions.
|
|
81
|
+
It covers K-lines, realtime quotes, fundamentals / three financial
|
|
23
82
|
statements, valuation history, margin trading, dragon-tiger board (per-stock
|
|
24
83
|
seats and whole-market daily), lockup expiry, northbound flow, fund flow, board
|
|
25
84
|
fund flow, industry comparison, concept blocks, block trades, market breadth,
|
|
@@ -28,7 +87,9 @@ distribution, ETF option chains (T-quote + greeks + IV), investor Q&A (互动易
|
|
|
28
87
|
hot rank / popularity rank / concept hits, insider transactions, shareholder
|
|
29
88
|
pledge / buyback, corporate actions, earnings forecast, research reports, news
|
|
30
89
|
wires, policy news, macro indicators, trading calendar, delisting / suspension
|
|
31
|
-
info, and more. See `chstockdata/__init__.py` for the full export list.
|
|
90
|
+
info, and more. See `chstockdata/__init__.py` for the full export list. The
|
|
91
|
+
candidate package version is `0.4.1`; `0.3.0` is the prior consumer
|
|
92
|
+
compatibility baseline. This release candidate has not been published.
|
|
32
93
|
|
|
33
94
|
## Data sources
|
|
34
95
|
|