axdata 0.1.0__py3-none-any.whl
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.
- axdata/__init__.py +16 -0
- axdata/cache.py +19 -0
- axdata/client.py +1223 -0
- axdata-0.1.0.dist-info/METADATA +238 -0
- axdata-0.1.0.dist-info/RECORD +427 -0
- axdata-0.1.0.dist-info/WHEEL +5 -0
- axdata-0.1.0.dist-info/entry_points.txt +8 -0
- axdata-0.1.0.dist-info/licenses/LICENSE +162 -0
- axdata-0.1.0.dist-info/top_level.txt +6 -0
- axdata_core/__init__.py +221 -0
- axdata_core/_tdx_wire/__init__.py +35 -0
- axdata_core/_tdx_wire/_shim.py +140 -0
- axdata_core/_tdx_wire/api/__init__.py +51 -0
- axdata_core/_tdx_wire/api/auction.py +24 -0
- axdata_core/_tdx_wire/api/bars.py +24 -0
- axdata_core/_tdx_wire/api/base.py +26 -0
- axdata_core/_tdx_wire/api/codes.py +25 -0
- axdata_core/_tdx_wire/api/corporate.py +24 -0
- axdata_core/_tdx_wire/api/finance.py +24 -0
- axdata_core/_tdx_wire/api/intraday.py +24 -0
- axdata_core/_tdx_wire/api/quotes.py +26 -0
- axdata_core/_tdx_wire/api/resources.py +25 -0
- axdata_core/_tdx_wire/api/session.py +24 -0
- axdata_core/_tdx_wire/api/trades.py +24 -0
- axdata_core/_tdx_wire/client.py +33 -0
- axdata_core/_tdx_wire/exceptions.py +27 -0
- axdata_core/_tdx_wire/hosts.py +106 -0
- axdata_core/_tdx_wire/models/__init__.py +93 -0
- axdata_core/_tdx_wire/models/auction.py +26 -0
- axdata_core/_tdx_wire/models/corporate.py +27 -0
- axdata_core/_tdx_wire/models/finance.py +26 -0
- axdata_core/_tdx_wire/models/intraday.py +31 -0
- axdata_core/_tdx_wire/models/kline.py +27 -0
- axdata_core/_tdx_wire/models/quote.py +32 -0
- axdata_core/_tdx_wire/models/resource.py +24 -0
- axdata_core/_tdx_wire/models/security.py +24 -0
- axdata_core/_tdx_wire/models/session.py +27 -0
- axdata_core/_tdx_wire/models/subchart.py +25 -0
- axdata_core/_tdx_wire/models/trade.py +28 -0
- axdata_core/_tdx_wire/protocol/__init__.py +49 -0
- axdata_core/_tdx_wire/protocol/commands/__init__.py +43 -0
- axdata_core/_tdx_wire/protocol/commands/auction.py +110 -0
- axdata_core/_tdx_wire/protocol/commands/codec.py +43 -0
- axdata_core/_tdx_wire/protocol/commands/corporate.py +98 -0
- axdata_core/_tdx_wire/protocol/commands/finance.py +96 -0
- axdata_core/_tdx_wire/protocol/commands/intraday.py +122 -0
- axdata_core/_tdx_wire/protocol/commands/klines.py +102 -0
- axdata_core/_tdx_wire/protocol/commands/lookup.py +36 -0
- axdata_core/_tdx_wire/protocol/commands/price_limits.py +89 -0
- axdata_core/_tdx_wire/protocol/commands/quotes.py +102 -0
- axdata_core/_tdx_wire/protocol/commands/registry.py +36 -0
- axdata_core/_tdx_wire/protocol/commands/resources.py +99 -0
- axdata_core/_tdx_wire/protocol/commands/security.py +103 -0
- axdata_core/_tdx_wire/protocol/commands/session.py +82 -0
- axdata_core/_tdx_wire/protocol/commands/subchart.py +97 -0
- axdata_core/_tdx_wire/protocol/commands/trades.py +107 -0
- axdata_core/_tdx_wire/protocol/constants.py +124 -0
- axdata_core/_tdx_wire/protocol/frame.py +68 -0
- axdata_core/_tdx_wire/protocol/unit.py +85 -0
- axdata_core/_tdx_wire/py.typed +1 -0
- axdata_core/_tdx_wire/transport/__init__.py +34 -0
- axdata_core/_tdx_wire/transport/base.py +25 -0
- axdata_core/_tdx_wire/transport/memory.py +24 -0
- axdata_core/_tdx_wire/transport/pool.py +32 -0
- axdata_core/_tdx_wire/transport/socket.py +39 -0
- axdata_core/adapters/__init__.py +0 -0
- axdata_core/adapters/cls/__init__.py +17 -0
- axdata_core/adapters/cls/provider_bridge.py +23 -0
- axdata_core/adapters/cls/request.py +632 -0
- axdata_core/adapters/cls/source_adapter_registry.py +31 -0
- axdata_core/adapters/cninfo/__init__.py +17 -0
- axdata_core/adapters/cninfo/provider_bridge.py +25 -0
- axdata_core/adapters/cninfo/request.py +2425 -0
- axdata_core/adapters/cninfo/source_adapter_registry.py +42 -0
- axdata_core/adapters/eastmoney/__init__.py +17 -0
- axdata_core/adapters/eastmoney/provider_bridge.py +25 -0
- axdata_core/adapters/eastmoney/request.py +1128 -0
- axdata_core/adapters/eastmoney/source_adapter_registry.py +42 -0
- axdata_core/adapters/exchange/__init__.py +17 -0
- axdata_core/adapters/exchange/provider_bridge.py +25 -0
- axdata_core/adapters/exchange/request.py +1214 -0
- axdata_core/adapters/exchange/source_adapter_registry.py +42 -0
- axdata_core/adapters/kph/__init__.py +17 -0
- axdata_core/adapters/kph/provider_bridge.py +23 -0
- axdata_core/adapters/kph/request.py +509 -0
- axdata_core/adapters/kph/source_adapter_registry.py +31 -0
- axdata_core/adapters/sina/__init__.py +17 -0
- axdata_core/adapters/sina/provider_bridge.py +25 -0
- axdata_core/adapters/sina/request.py +5155 -0
- axdata_core/adapters/sina/source_adapter_registry.py +42 -0
- axdata_core/adapters/tdx/__init__.py +32 -0
- axdata_core/adapters/tdx/adjustment.py +50 -0
- axdata_core/adapters/tdx/adjustment_fetch.py +51 -0
- axdata_core/adapters/tdx/auction_fetch.py +51 -0
- axdata_core/adapters/tdx/client_factory.py +110 -0
- axdata_core/adapters/tdx/code_fetch.py +62 -0
- axdata_core/adapters/tdx/codes.py +54 -0
- axdata_core/adapters/tdx/derived_rows.py +69 -0
- axdata_core/adapters/tdx/downloader.py +193 -0
- axdata_core/adapters/tdx/downloader_interface_sets.py +50 -0
- axdata_core/adapters/tdx/downloader_profiles.py +43 -0
- axdata_core/adapters/tdx/downloader_registry.py +115 -0
- axdata_core/adapters/tdx/execution_utils.py +55 -0
- axdata_core/adapters/tdx/f10_executor.py +57 -0
- axdata_core/adapters/tdx/f10_normalize.py +61 -0
- axdata_core/adapters/tdx/f10_params.py +57 -0
- axdata_core/adapters/tdx/f10_postprocess.py +67 -0
- axdata_core/adapters/tdx/f10_render.py +48 -0
- axdata_core/adapters/tdx/f10_request.py +62 -0
- axdata_core/adapters/tdx/finance_fetch.py +61 -0
- axdata_core/adapters/tdx/finance_maps.py +54 -0
- axdata_core/adapters/tdx/finance_normalize.py +57 -0
- axdata_core/adapters/tdx/host_config.py +115 -0
- axdata_core/adapters/tdx/interface_sets.py +50 -0
- axdata_core/adapters/tdx/intraday_fetch.py +68 -0
- axdata_core/adapters/tdx/kline_helpers.py +58 -0
- axdata_core/adapters/tdx/limit_ladder_fetch.py +60 -0
- axdata_core/adapters/tdx/limit_ladder_topics.py +53 -0
- axdata_core/adapters/tdx/normalize_utils.py +75 -0
- axdata_core/adapters/tdx/options.py +61 -0
- axdata_core/adapters/tdx/price_limit_calendar.py +49 -0
- axdata_core/adapters/tdx/price_limit_fetch.py +53 -0
- axdata_core/adapters/tdx/price_limit_history.py +50 -0
- axdata_core/adapters/tdx/price_limits.py +58 -0
- axdata_core/adapters/tdx/provider_bridge.py +68 -0
- axdata_core/adapters/tdx/quote_fetch.py +61 -0
- axdata_core/adapters/tdx/quote_identity.py +49 -0
- axdata_core/adapters/tdx/rank_fetch.py +55 -0
- axdata_core/adapters/tdx/rank_params.py +52 -0
- axdata_core/adapters/tdx/realtime_refresh.py +45 -0
- axdata_core/adapters/tdx/request.py +11 -0
- axdata_core/adapters/tdx/request_adapter_runtime.py +41 -0
- axdata_core/adapters/tdx/request_client.py +51 -0
- axdata_core/adapters/tdx/request_compat.py +89 -0
- axdata_core/adapters/tdx/request_dispatch.py +50 -0
- axdata_core/adapters/tdx/request_filters.py +60 -0
- axdata_core/adapters/tdx/request_host_config.py +110 -0
- axdata_core/adapters/tdx/request_limits.py +59 -0
- axdata_core/adapters/tdx/request_methods.py +41 -0
- axdata_core/adapters/tdx/request_params.py +62 -0
- axdata_core/adapters/tdx/request_seams.py +41 -0
- axdata_core/adapters/tdx/resources/__init__.py +0 -0
- axdata_core/adapters/tdx/resources/finance_maps/__init__.py +0 -0
- axdata_core/adapters/tdx/resources/finance_maps/incon.dat +3702 -0
- axdata_core/adapters/tdx/resources/finance_maps/tdxhy.cfg +5620 -0
- axdata_core/adapters/tdx/resources/finance_maps/tdxzs.cfg +605 -0
- axdata_core/adapters/tdx/security_codes.py +54 -0
- axdata_core/adapters/tdx/series_history.py +57 -0
- axdata_core/adapters/tdx/server_cache.py +58 -0
- axdata_core/adapters/tdx/snapshot_normalize.py +56 -0
- axdata_core/adapters/tdx/source_adapter_registry.py +69 -0
- axdata_core/adapters/tdx/source_execution.py +44 -0
- axdata_core/adapters/tdx/source_execution_registry.py +70 -0
- axdata_core/adapters/tdx/stats_cache.py +184 -0
- axdata_core/adapters/tdx/stats_models.py +159 -0
- axdata_core/adapters/tdx/stats_resource.py +304 -0
- axdata_core/adapters/tdx/status_fetch.py +55 -0
- axdata_core/adapters/tdx/time_series_normalize.py +67 -0
- axdata_core/adapters/tdx/tqlex.py +50 -0
- axdata_core/adapters/tdx/wire_requests.py +60 -0
- axdata_core/adapters/tdx_ext/__init__.py +66 -0
- axdata_core/adapters/tdx_ext/client.py +688 -0
- axdata_core/adapters/tdx_ext/exceptions.py +51 -0
- axdata_core/adapters/tdx_ext/host_config.py +40 -0
- axdata_core/adapters/tdx_ext/interface_sets.py +65 -0
- axdata_core/adapters/tdx_ext/local_cache.py +649 -0
- axdata_core/adapters/tdx_ext/models.py +96 -0
- axdata_core/adapters/tdx_ext/options.py +36 -0
- axdata_core/adapters/tdx_ext/pool.py +153 -0
- axdata_core/adapters/tdx_ext/provider_bridge.py +35 -0
- axdata_core/adapters/tdx_ext/request.py +498 -0
- axdata_core/adapters/tdx_ext/request_execution.py +118 -0
- axdata_core/adapters/tdx_ext/request_instruments.py +221 -0
- axdata_core/adapters/tdx_ext/request_normalize.py +356 -0
- axdata_core/adapters/tdx_ext/request_params.py +157 -0
- axdata_core/adapters/tdx_ext/request_series.py +98 -0
- axdata_core/adapters/tdx_ext/server_cache.py +13 -0
- axdata_core/adapters/tdx_ext/servers.py +35 -0
- axdata_core/adapters/tdx_ext/source_adapter_registry.py +42 -0
- axdata_core/adapters/tdx_ext/source_execution.py +19 -0
- axdata_core/adapters/tdx_ext/source_execution_registry.py +43 -0
- axdata_core/adapters/tencent/__init__.py +17 -0
- axdata_core/adapters/tencent/provider_bridge.py +25 -0
- axdata_core/adapters/tencent/request.py +729 -0
- axdata_core/adapters/tencent/source_adapter_registry.py +42 -0
- axdata_core/axp.py +1843 -0
- axdata_core/builtin_providers.py +586 -0
- axdata_core/builtin_source_declarations.py +156 -0
- axdata_core/cli.py +1818 -0
- axdata_core/collector_registry.py +227 -0
- axdata_core/collector_runner.py +1016 -0
- axdata_core/collector_scheduler.py +3155 -0
- axdata_core/collector_templates.py +339 -0
- axdata_core/data_browser.py +1696 -0
- axdata_core/diagnostics.py +734 -0
- axdata_core/downloader_engine.py +1480 -0
- axdata_core/downloader_registry.py +62 -0
- axdata_core/downloaders.py +1619 -0
- axdata_core/legacy_provider_adapter.py +68 -0
- axdata_core/paths.py +51 -0
- axdata_core/plugin_config.py +272 -0
- axdata_core/plugin_status.py +419 -0
- axdata_core/plugins.py +1363 -0
- axdata_core/provider_catalog.py +462 -0
- axdata_core/provider_registry.py +833 -0
- axdata_core/quality.py +86 -0
- axdata_core/query.py +242 -0
- axdata_core/resources/__init__.py +2 -0
- axdata_core/resources/tdx_extended_servers.json +22 -0
- axdata_core/resources/tdx_quote_servers.json +49 -0
- axdata_core/sample_collectors.py +42 -0
- axdata_core/schema.py +385 -0
- axdata_core/source_adapter_factory.py +95 -0
- axdata_core/source_adapter_options.py +18 -0
- axdata_core/source_errors.py +43 -0
- axdata_core/source_execution_options.py +37 -0
- axdata_core/source_execution_registry.py +27 -0
- axdata_core/source_projection.py +21 -0
- axdata_core/source_request.py +441 -0
- axdata_core/source_session.py +355 -0
- axdata_core/sources/__init__.py +40 -0
- axdata_core/sources/base.py +112 -0
- axdata_core/sources/catalog.py +60 -0
- axdata_core/sources/cls/__init__.py +5 -0
- axdata_core/sources/cls/catalog.py +231 -0
- axdata_core/sources/cninfo/__init__.py +5 -0
- axdata_core/sources/cninfo/catalog.py +1994 -0
- axdata_core/sources/display_docs.py +139 -0
- axdata_core/sources/eastmoney/__init__.py +5 -0
- axdata_core/sources/eastmoney/catalog.py +509 -0
- axdata_core/sources/exchange/__init__.py +5 -0
- axdata_core/sources/exchange/catalog.py +361 -0
- axdata_core/sources/kph/__init__.py +5 -0
- axdata_core/sources/kph/catalog.py +255 -0
- axdata_core/sources/sina/__init__.py +5 -0
- axdata_core/sources/sina/catalog.py +2951 -0
- axdata_core/sources/tdx/__init__.py +5 -0
- axdata_core/sources/tdx/catalog.py +4546 -0
- axdata_core/sources/tdx_ext/__init__.py +5 -0
- axdata_core/sources/tdx_ext/catalog.py +1518 -0
- axdata_core/sources/tencent/__init__.py +5 -0
- axdata_core/sources/tencent/catalog.py +370 -0
- axdata_core/storage.py +186 -0
- axdata_core/tdx_f10_catalog.py +52 -0
- axdata_core/tdx_f10_models.py +50 -0
- axdata_core/tdx_f10_names.py +47 -0
- axdata_core/tdx_f10_specs.py +56 -0
- axdata_core/tdx_plugin_required.py +43 -0
- axdata_core/tdx_server_config.py +65 -0
- axdata_core/trade_calendar_cache.py +397 -0
- axdata_source_cninfo/__init__.py +15 -0
- axdata_source_cninfo/adapter.py +31 -0
- axdata_source_cninfo/axdata-provider.json +384 -0
- axdata_source_cninfo/catalog.py +209 -0
- axdata_source_cninfo/metadata.py +8 -0
- axdata_source_cninfo/provider.py +41 -0
- axdata_source_tdx/__init__.py +15 -0
- axdata_source_tdx/_tdx_wire/__init__.py +26 -0
- axdata_source_tdx/_tdx_wire/_binary.py +218 -0
- axdata_source_tdx/_tdx_wire/_code_utils.py +42 -0
- axdata_source_tdx/_tdx_wire/_command_codec.py +186 -0
- axdata_source_tdx/_tdx_wire/_command_codes.py +74 -0
- axdata_source_tdx/_tdx_wire/_command_defaults.py +15 -0
- axdata_source_tdx/_tdx_wire/_command_dispatch.py +96 -0
- axdata_source_tdx/_tdx_wire/_command_layouts.py +96 -0
- axdata_source_tdx/_tdx_wire/_command_lookup.py +25 -0
- axdata_source_tdx/_tdx_wire/_command_metadata.py +32 -0
- axdata_source_tdx/_tdx_wire/_command_registry.py +61 -0
- axdata_source_tdx/_tdx_wire/_connection_defaults.py +13 -0
- axdata_source_tdx/_tdx_wire/_host_defaults.py +51 -0
- axdata_source_tdx/_tdx_wire/_host_probe.py +81 -0
- axdata_source_tdx/_tdx_wire/_host_resource.py +70 -0
- axdata_source_tdx/_tdx_wire/_host_utils.py +31 -0
- axdata_source_tdx/_tdx_wire/_market.py +66 -0
- axdata_source_tdx/_tdx_wire/_request_defaults.py +11 -0
- axdata_source_tdx/_tdx_wire/_security_classification.py +61 -0
- axdata_source_tdx/_tdx_wire/_time_utils.py +7 -0
- axdata_source_tdx/_tdx_wire/api/__init__.py +45 -0
- axdata_source_tdx/_tdx_wire/api/auction.py +25 -0
- axdata_source_tdx/_tdx_wire/api/bars.py +31 -0
- axdata_source_tdx/_tdx_wire/api/base.py +39 -0
- axdata_source_tdx/_tdx_wire/api/codes.py +25 -0
- axdata_source_tdx/_tdx_wire/api/corporate.py +11 -0
- axdata_source_tdx/_tdx_wire/api/finance.py +10 -0
- axdata_source_tdx/_tdx_wire/api/intraday.py +38 -0
- axdata_source_tdx/_tdx_wire/api/quotes.py +78 -0
- axdata_source_tdx/_tdx_wire/api/resources.py +34 -0
- axdata_source_tdx/_tdx_wire/api/session.py +16 -0
- axdata_source_tdx/_tdx_wire/api/trades.py +34 -0
- axdata_source_tdx/_tdx_wire/client.py +470 -0
- axdata_source_tdx/_tdx_wire/exceptions.py +25 -0
- axdata_source_tdx/_tdx_wire/hosts.py +27 -0
- axdata_source_tdx/_tdx_wire/models/__init__.py +87 -0
- axdata_source_tdx/_tdx_wire/models/auction.py +58 -0
- axdata_source_tdx/_tdx_wire/models/corporate.py +59 -0
- axdata_source_tdx/_tdx_wire/models/finance.py +80 -0
- axdata_source_tdx/_tdx_wire/models/intraday.py +112 -0
- axdata_source_tdx/_tdx_wire/models/kline.py +58 -0
- axdata_source_tdx/_tdx_wire/models/quote.py +262 -0
- axdata_source_tdx/_tdx_wire/models/resource.py +18 -0
- axdata_source_tdx/_tdx_wire/models/security.py +28 -0
- axdata_source_tdx/_tdx_wire/models/session.py +30 -0
- axdata_source_tdx/_tdx_wire/models/subchart.py +39 -0
- axdata_source_tdx/_tdx_wire/models/trade.py +46 -0
- axdata_source_tdx/_tdx_wire/protocol/__init__.py +43 -0
- axdata_source_tdx/_tdx_wire/protocol/_frame_constants.py +5 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/__init__.py +37 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/auction.py +165 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/codec.py +37 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/corporate.py +163 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/finance.py +180 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/intraday.py +382 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/klines.py +396 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/lookup.py +31 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/price_limits.py +110 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/quotes.py +804 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/registry.py +30 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/resources.py +107 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/security.py +163 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/session.py +129 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/subchart.py +182 -0
- axdata_source_tdx/_tdx_wire/protocol/commands/trades.py +275 -0
- axdata_source_tdx/_tdx_wire/protocol/constants.py +70 -0
- axdata_source_tdx/_tdx_wire/protocol/frame.py +141 -0
- axdata_source_tdx/_tdx_wire/protocol/unit.py +98 -0
- axdata_source_tdx/_tdx_wire/py.typed +1 -0
- axdata_source_tdx/_tdx_wire/transport/__init__.py +28 -0
- axdata_source_tdx/_tdx_wire/transport/base.py +21 -0
- axdata_source_tdx/_tdx_wire/transport/memory.py +42 -0
- axdata_source_tdx/_tdx_wire/transport/pool.py +148 -0
- axdata_source_tdx/_tdx_wire/transport/socket.py +373 -0
- axdata_source_tdx/adapter.py +31 -0
- axdata_source_tdx/adjustment.py +163 -0
- axdata_source_tdx/adjustment_fetch.py +148 -0
- axdata_source_tdx/auction_fetch.py +162 -0
- axdata_source_tdx/axdata-provider.json +23680 -0
- axdata_source_tdx/catalog.py +39 -0
- axdata_source_tdx/client_factory.py +61 -0
- axdata_source_tdx/code_fetch.py +579 -0
- axdata_source_tdx/codes.py +69 -0
- axdata_source_tdx/collectors.py +525 -0
- axdata_source_tdx/derived_rows.py +500 -0
- axdata_source_tdx/downloader.py +139 -0
- axdata_source_tdx/downloader_interface_sets.py +29 -0
- axdata_source_tdx/downloader_profiles.py +731 -0
- axdata_source_tdx/downloader_registry.py +85 -0
- axdata_source_tdx/execution_utils.py +141 -0
- axdata_source_tdx/f10_executor.py +414 -0
- axdata_source_tdx/f10_normalize.py +169 -0
- axdata_source_tdx/f10_params.py +221 -0
- axdata_source_tdx/f10_postprocess.py +405 -0
- axdata_source_tdx/f10_render.py +29 -0
- axdata_source_tdx/f10_request.py +365 -0
- axdata_source_tdx/finance_fetch.py +514 -0
- axdata_source_tdx/finance_maps.py +377 -0
- axdata_source_tdx/finance_normalize.py +273 -0
- axdata_source_tdx/host_config.py +51 -0
- axdata_source_tdx/interface_sets.py +180 -0
- axdata_source_tdx/intraday_fetch.py +600 -0
- axdata_source_tdx/kline_helpers.py +333 -0
- axdata_source_tdx/limit_ladder_fetch.py +614 -0
- axdata_source_tdx/limit_ladder_topics.py +280 -0
- axdata_source_tdx/metadata.py +8 -0
- axdata_source_tdx/normalize_utils.py +264 -0
- axdata_source_tdx/options.py +195 -0
- axdata_source_tdx/price_limit_calendar.py +106 -0
- axdata_source_tdx/price_limit_fetch.py +264 -0
- axdata_source_tdx/price_limit_history.py +100 -0
- axdata_source_tdx/price_limits.py +142 -0
- axdata_source_tdx/provider.py +44 -0
- axdata_source_tdx/provider_bridge.py +43 -0
- axdata_source_tdx/quote_fetch.py +485 -0
- axdata_source_tdx/quote_identity.py +50 -0
- axdata_source_tdx/rank_fetch.py +316 -0
- axdata_source_tdx/rank_params.py +181 -0
- axdata_source_tdx/realtime_refresh.py +51 -0
- axdata_source_tdx/request_adapter.py +533 -0
- axdata_source_tdx/request_adapter_runtime.py +302 -0
- axdata_source_tdx/request_client.py +98 -0
- axdata_source_tdx/request_compat.py +432 -0
- axdata_source_tdx/request_dispatch.py +138 -0
- axdata_source_tdx/request_entrypoints.py +146 -0
- axdata_source_tdx/request_filters.py +154 -0
- axdata_source_tdx/request_host_config.py +103 -0
- axdata_source_tdx/request_limits.py +15 -0
- axdata_source_tdx/request_methods.py +1910 -0
- axdata_source_tdx/request_params.py +225 -0
- axdata_source_tdx/request_seams.py +534 -0
- axdata_source_tdx/resources/__init__.py +0 -0
- axdata_source_tdx/resources/finance_maps/__init__.py +1 -0
- axdata_source_tdx/resources/finance_maps/incon.dat +3702 -0
- axdata_source_tdx/resources/finance_maps/tdxhy.cfg +5620 -0
- axdata_source_tdx/resources/finance_maps/tdxzs.cfg +605 -0
- axdata_source_tdx/resources/tdx_extended_servers.json +22 -0
- axdata_source_tdx/resources/tdx_quote_servers.json +49 -0
- axdata_source_tdx/security_codes.py +127 -0
- axdata_source_tdx/series_history.py +348 -0
- axdata_source_tdx/server_cache.py +21 -0
- axdata_source_tdx/snapshot_normalize.py +232 -0
- axdata_source_tdx/source_adapter_registry.py +42 -0
- axdata_source_tdx/source_execution.py +22 -0
- axdata_source_tdx/source_execution_registry.py +43 -0
- axdata_source_tdx/stats_cache.py +150 -0
- axdata_source_tdx/stats_models.py +161 -0
- axdata_source_tdx/stats_resource.py +242 -0
- axdata_source_tdx/status_fetch.py +209 -0
- axdata_source_tdx/tdx_f10_catalog.py +957 -0
- axdata_source_tdx/tdx_f10_models.py +47 -0
- axdata_source_tdx/tdx_f10_names.py +48 -0
- axdata_source_tdx/tdx_f10_specs.py +1142 -0
- axdata_source_tdx/tdx_server_config.py +389 -0
- axdata_source_tdx/time_series_normalize.py +370 -0
- axdata_source_tdx/tqlex.py +138 -0
- axdata_source_tdx/wire.py +32 -0
- axdata_source_tdx/wire_requests.py +190 -0
- axdata_source_tdx_ext/__init__.py +15 -0
- axdata_source_tdx_ext/adapter.py +31 -0
- axdata_source_tdx_ext/axdata-provider.json +9424 -0
- axdata_source_tdx_ext/catalog.py +33 -0
- axdata_source_tdx_ext/metadata.py +8 -0
- axdata_source_tdx_ext/provider.py +44 -0
- axdata_source_tencent/__init__.py +15 -0
- axdata_source_tencent/adapter.py +31 -0
- axdata_source_tencent/axdata-provider.json +291 -0
- axdata_source_tencent/catalog.py +190 -0
- axdata_source_tencent/metadata.py +8 -0
- axdata_source_tencent/provider.py +41 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": 1,
|
|
3
|
+
"kind": "quote",
|
|
4
|
+
"servers": [
|
|
5
|
+
{"name": "普通行情1", "host": "116.205.183.150", "port": 7709, "enabled": true, "priority": 1},
|
|
6
|
+
{"name": "普通行情2", "host": "116.205.171.132", "port": 7709, "enabled": true, "priority": 2},
|
|
7
|
+
{"name": "普通行情3", "host": "111.230.186.52", "port": 7709, "enabled": true, "priority": 3},
|
|
8
|
+
{"name": "普通行情4", "host": "129.204.230.128", "port": 7709, "enabled": true, "priority": 4},
|
|
9
|
+
{"name": "普通行情5", "host": "116.205.163.254", "port": 7709, "enabled": true, "priority": 5},
|
|
10
|
+
{"name": "普通行情6", "host": "110.41.2.72", "port": 7709, "enabled": true, "priority": 6},
|
|
11
|
+
{"name": "普通行情7", "host": "159.75.29.111", "port": 7709, "enabled": true, "priority": 7},
|
|
12
|
+
{"name": "普通行情8", "host": "43.139.95.83", "port": 7709, "enabled": true, "priority": 8},
|
|
13
|
+
{"name": "普通行情9", "host": "175.178.128.227", "port": 7709, "enabled": true, "priority": 9},
|
|
14
|
+
{"name": "普通行情10", "host": "110.41.147.114", "port": 7709, "enabled": true, "priority": 10},
|
|
15
|
+
{"name": "普通行情11", "host": "124.71.9.153", "port": 7709, "enabled": true, "priority": 11},
|
|
16
|
+
{"name": "普通行情12", "host": "81.71.32.47", "port": 7709, "enabled": true, "priority": 12},
|
|
17
|
+
{"name": "普通行情13", "host": "43.139.18.171", "port": 7709, "enabled": true, "priority": 13},
|
|
18
|
+
{"name": "普通行情14", "host": "119.97.185.59", "port": 7709, "enabled": true, "priority": 14},
|
|
19
|
+
{"name": "普通行情15", "host": "123.60.70.228", "port": 7709, "enabled": true, "priority": 15},
|
|
20
|
+
{"name": "普通行情16", "host": "123.60.73.44", "port": 7709, "enabled": true, "priority": 16},
|
|
21
|
+
{"name": "普通行情17", "host": "124.70.199.56", "port": 7709, "enabled": true, "priority": 17},
|
|
22
|
+
{"name": "普通行情18", "host": "175.178.112.197", "port": 7709, "enabled": true, "priority": 18},
|
|
23
|
+
{"name": "普通行情19", "host": "101.33.225.16", "port": 7709, "enabled": true, "priority": 19},
|
|
24
|
+
{"name": "普通行情20", "host": "124.71.187.122", "port": 7709, "enabled": true, "priority": 20},
|
|
25
|
+
{"name": "普通行情21", "host": "124.71.187.72", "port": 7709, "enabled": true, "priority": 21},
|
|
26
|
+
{"name": "普通行情22", "host": "111.229.247.189", "port": 7709, "enabled": true, "priority": 22},
|
|
27
|
+
{"name": "普通行情23", "host": "121.36.225.169", "port": 7709, "enabled": true, "priority": 23},
|
|
28
|
+
{"name": "普通行情24", "host": "150.158.160.2", "port": 7709, "enabled": true, "priority": 24},
|
|
29
|
+
{"name": "普通行情25", "host": "123.60.164.122", "port": 7709, "enabled": true, "priority": 25},
|
|
30
|
+
{"name": "普通行情26", "host": "49.232.15.141", "port": 7709, "enabled": true, "priority": 26},
|
|
31
|
+
{"name": "普通行情27", "host": "122.51.120.217", "port": 7709, "enabled": true, "priority": 27},
|
|
32
|
+
{"name": "普通行情28", "host": "111.231.113.208", "port": 7709, "enabled": true, "priority": 28},
|
|
33
|
+
{"name": "普通行情29", "host": "124.223.163.242", "port": 7709, "enabled": true, "priority": 29},
|
|
34
|
+
{"name": "普通行情30", "host": "62.234.50.143", "port": 7709, "enabled": true, "priority": 30},
|
|
35
|
+
{"name": "普通行情31", "host": "101.35.121.35", "port": 7709, "enabled": true, "priority": 31},
|
|
36
|
+
{"name": "普通行情32", "host": "101.42.240.54", "port": 7709, "enabled": true, "priority": 32},
|
|
37
|
+
{"name": "普通行情33", "host": "101.43.159.194", "port": 7709, "enabled": true, "priority": 33},
|
|
38
|
+
{"name": "普通行情34", "host": "81.70.151.186", "port": 7709, "enabled": true, "priority": 34},
|
|
39
|
+
{"name": "普通行情35", "host": "82.156.174.84", "port": 7709, "enabled": true, "priority": 35},
|
|
40
|
+
{"name": "普通行情36", "host": "123.60.84.66", "port": 7709, "enabled": true, "priority": 36},
|
|
41
|
+
{"name": "普通行情37", "host": "120.53.8.251", "port": 7709, "enabled": true, "priority": 37},
|
|
42
|
+
{"name": "普通行情38", "host": "124.70.133.119", "port": 7709, "enabled": true, "priority": 38},
|
|
43
|
+
{"name": "普通行情39", "host": "118.25.98.114", "port": 7709, "enabled": true, "priority": 39},
|
|
44
|
+
{"name": "普通行情40", "host": "122.51.232.182", "port": 7709, "enabled": true, "priority": 40},
|
|
45
|
+
{"name": "普通行情41", "host": "101.42.164.241", "port": 7709, "enabled": true, "priority": 41},
|
|
46
|
+
{"name": "普通行情42", "host": "152.136.191.169", "port": 7709, "enabled": true, "priority": 42},
|
|
47
|
+
{"name": "普通行情43", "host": "82.156.214.79", "port": 7709, "enabled": true, "priority": 43}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""TDX security code-list classification and row normalization."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from .codes import MARKET_TO_EXCHANGE, tdx_code_to_instrument_id
|
|
9
|
+
from .normalize_utils import get_value
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
ASSET_TYPE_MAP = {
|
|
13
|
+
"a_share": "stock",
|
|
14
|
+
"b_share": "stock",
|
|
15
|
+
"etf": "etf",
|
|
16
|
+
"fund": "fund",
|
|
17
|
+
"index": "index",
|
|
18
|
+
"cdr": "cdr",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
BOARD_MAP = {
|
|
22
|
+
"sse_main_board": "主板",
|
|
23
|
+
"sse_star_market": "科创板",
|
|
24
|
+
"sse_cdr": "CDR",
|
|
25
|
+
"szse_main_board": "主板",
|
|
26
|
+
"szse_chinext": "创业板",
|
|
27
|
+
"bse_listed_stock": "北交所",
|
|
28
|
+
"none": None,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
SCOPE_TO_BOARDS = {
|
|
32
|
+
"all": None,
|
|
33
|
+
"全部": None,
|
|
34
|
+
"*": None,
|
|
35
|
+
"main": {"sse_main_board", "szse_main_board"},
|
|
36
|
+
"主板": {"sse_main_board", "szse_main_board"},
|
|
37
|
+
"star": {"sse_star_market"},
|
|
38
|
+
"科创板": {"sse_star_market"},
|
|
39
|
+
"cdr": {"sse_cdr"},
|
|
40
|
+
"CDR": {"sse_cdr"},
|
|
41
|
+
"chinext": {"szse_chinext"},
|
|
42
|
+
"创业板": {"szse_chinext"},
|
|
43
|
+
"bse": {"bse_listed_stock"},
|
|
44
|
+
"北交所": {"bse_listed_stock"},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def normalize_security(item: Any) -> dict[str, Any]:
|
|
49
|
+
category = get_value(item, "category")
|
|
50
|
+
board = get_value(item, "board")
|
|
51
|
+
tdx_code = str(get_value(item, "full_code") or "").lower()
|
|
52
|
+
instrument_id = tdx_code_to_instrument_id(tdx_code)
|
|
53
|
+
symbol = str(get_value(item, "code") or instrument_id.split(".", 1)[0])
|
|
54
|
+
market = str(get_value(item, "exchange") or "").lower()
|
|
55
|
+
asset_type = ASSET_TYPE_MAP.get(str(category), str(category or "unknown"))
|
|
56
|
+
return {
|
|
57
|
+
"instrument_id": instrument_id,
|
|
58
|
+
"symbol": symbol,
|
|
59
|
+
"tdx_code": tdx_code,
|
|
60
|
+
"exchange": MARKET_TO_EXCHANGE.get(market, market.upper()),
|
|
61
|
+
"name": get_value(item, "name"),
|
|
62
|
+
"asset_type": asset_type,
|
|
63
|
+
"tdx_category": category,
|
|
64
|
+
"tdx_category_reason": get_value(item, "category_reason"),
|
|
65
|
+
"listing_status": "listed",
|
|
66
|
+
"list_date": None,
|
|
67
|
+
"market": BOARD_MAP.get(str(board), board),
|
|
68
|
+
"market_code": board,
|
|
69
|
+
"tdx_market_reason": get_value(item, "board_reason"),
|
|
70
|
+
"tdx_decimal": get_value(item, "decimal"),
|
|
71
|
+
"tdx_multiple": get_value(item, "multiple"),
|
|
72
|
+
"tdx_previous_close_price": get_value(item, "previous_close_price"),
|
|
73
|
+
"tdx_volume_ratio_base": get_value(item, "volume_ratio_base"),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def board_from_tdx_code(tdx_code: Any) -> str | None:
|
|
78
|
+
text = str(tdx_code or "").strip().lower()
|
|
79
|
+
if len(text) != 8:
|
|
80
|
+
return None
|
|
81
|
+
market = text[:2]
|
|
82
|
+
symbol = text[2:]
|
|
83
|
+
if market == "bj":
|
|
84
|
+
return "bse_listed_stock"
|
|
85
|
+
if market == "sh":
|
|
86
|
+
if symbol.startswith("688"):
|
|
87
|
+
return "sse_star_market"
|
|
88
|
+
if symbol.startswith("689"):
|
|
89
|
+
return "sse_cdr"
|
|
90
|
+
if symbol.startswith(("600", "601", "603", "605")):
|
|
91
|
+
return "sse_main_board"
|
|
92
|
+
if market == "sz":
|
|
93
|
+
if symbol.startswith(("300", "301")):
|
|
94
|
+
return "szse_chinext"
|
|
95
|
+
if symbol.startswith(("000", "001", "002", "003", "004")):
|
|
96
|
+
return "szse_main_board"
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def index_type_from_tdx_code(tdx_code: str) -> str:
|
|
101
|
+
code = str(tdx_code or "").lower()
|
|
102
|
+
if code.startswith(("sh000", "sz399", "bj899")):
|
|
103
|
+
return "official_index"
|
|
104
|
+
if code.startswith(("sh880", "sh881", "sh999")):
|
|
105
|
+
return "tdx_block_index"
|
|
106
|
+
return "index"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def etf_type_from_tdx_code(tdx_code: str) -> str | None:
|
|
110
|
+
code = str(tdx_code or "").lower()
|
|
111
|
+
if code.startswith(("sh51", "sh56", "sh58")):
|
|
112
|
+
return "sse_etf"
|
|
113
|
+
if code.startswith("sz15"):
|
|
114
|
+
return "szse_etf"
|
|
115
|
+
return None
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def normalize_index_code_row(row: Mapping[str, Any], index_type: str) -> dict[str, Any]:
|
|
119
|
+
return {
|
|
120
|
+
"instrument_id": row.get("instrument_id"),
|
|
121
|
+
"symbol": row.get("symbol"),
|
|
122
|
+
"tdx_code": row.get("tdx_code"),
|
|
123
|
+
"exchange": row.get("exchange"),
|
|
124
|
+
"name": row.get("name"),
|
|
125
|
+
"index_type": index_type,
|
|
126
|
+
"previous_close": row.get("tdx_previous_close_price"),
|
|
127
|
+
}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"""Historical K-line and trade pagination helpers for TDX requests."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
7
|
+
from dataclasses import dataclass, is_dataclass, replace
|
|
8
|
+
from types import SimpleNamespace
|
|
9
|
+
from typing import Any, Callable
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True)
|
|
13
|
+
class KlineParallelOptions:
|
|
14
|
+
hosts: list[str]
|
|
15
|
+
pool_size: int
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True)
|
|
19
|
+
class KlineRequestResult:
|
|
20
|
+
index: int
|
|
21
|
+
rows: list[dict[str, Any]]
|
|
22
|
+
series: Any
|
|
23
|
+
page_count: int
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class KlineHostResult:
|
|
28
|
+
results: list[KlineRequestResult]
|
|
29
|
+
meta: dict[str, Any]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True)
|
|
33
|
+
class KlineParallelResult:
|
|
34
|
+
results: list[KlineRequestResult]
|
|
35
|
+
host_metas: list[dict[str, Any]]
|
|
36
|
+
host_count: int
|
|
37
|
+
pool_size_per_host: int
|
|
38
|
+
concurrency_capacity: int
|
|
39
|
+
concurrency_limit: int
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def kline_parallel_options(
|
|
43
|
+
options: Any,
|
|
44
|
+
*,
|
|
45
|
+
has_connection_options: Callable[[Any], bool],
|
|
46
|
+
option_hosts: Callable[..., list[str] | None],
|
|
47
|
+
option_connections_per_server: Callable[[Any], int],
|
|
48
|
+
configured_hosts: Callable[[], list[str]],
|
|
49
|
+
configured_hosts_from_options: Callable[..., list[str]],
|
|
50
|
+
env_int: Callable[..., int],
|
|
51
|
+
default_host_count: int,
|
|
52
|
+
default_pool_size: int,
|
|
53
|
+
) -> KlineParallelOptions:
|
|
54
|
+
if has_connection_options(options):
|
|
55
|
+
hosts = option_hosts(
|
|
56
|
+
options,
|
|
57
|
+
configured_hosts=configured_hosts_from_options,
|
|
58
|
+
) or configured_hosts()
|
|
59
|
+
pool_size = option_connections_per_server(options)
|
|
60
|
+
else:
|
|
61
|
+
host_count = env_int("AXDATA_TDX_KLINE_HOST_COUNT", default_host_count, minimum=1)
|
|
62
|
+
pool_size = env_int("AXDATA_TDX_KLINE_POOL_SIZE", default_pool_size, minimum=1)
|
|
63
|
+
hosts = list(configured_hosts()[:host_count])
|
|
64
|
+
return KlineParallelOptions(hosts=list(hosts), pool_size=pool_size)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def request_trade_series_history(
|
|
68
|
+
client: Any,
|
|
69
|
+
tdx_code: str,
|
|
70
|
+
*,
|
|
71
|
+
trade_date: str | None,
|
|
72
|
+
page_size: int,
|
|
73
|
+
max_start: int,
|
|
74
|
+
price_decimal: Callable[[Any, str], int],
|
|
75
|
+
today_trades: Callable[..., Any],
|
|
76
|
+
historical_trades: Callable[..., Any],
|
|
77
|
+
trade_records: Callable[[Any], Sequence[Any]],
|
|
78
|
+
normalize_trade_row: Callable[..., dict[str, Any]],
|
|
79
|
+
) -> tuple[list[dict[str, Any]], int]:
|
|
80
|
+
current_start = 0
|
|
81
|
+
page_count = 0
|
|
82
|
+
rows: list[dict[str, Any]] = []
|
|
83
|
+
decimal = price_decimal(client, tdx_code)
|
|
84
|
+
|
|
85
|
+
while current_start <= max_start:
|
|
86
|
+
if trade_date is None:
|
|
87
|
+
series = today_trades(
|
|
88
|
+
client,
|
|
89
|
+
tdx_code,
|
|
90
|
+
start=current_start,
|
|
91
|
+
count=page_size,
|
|
92
|
+
)
|
|
93
|
+
else:
|
|
94
|
+
series = historical_trades(
|
|
95
|
+
client,
|
|
96
|
+
tdx_code,
|
|
97
|
+
trade_date=trade_date,
|
|
98
|
+
start=current_start,
|
|
99
|
+
count=page_size,
|
|
100
|
+
)
|
|
101
|
+
page_count += 1
|
|
102
|
+
records = trade_records(series)
|
|
103
|
+
if not records:
|
|
104
|
+
break
|
|
105
|
+
|
|
106
|
+
rows.extend(normalize_trade_row(series, record, decimal=decimal) for record in records)
|
|
107
|
+
if len(records) < page_size:
|
|
108
|
+
break
|
|
109
|
+
current_start += len(records)
|
|
110
|
+
|
|
111
|
+
return rows, page_count
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def request_kline_series_history(
|
|
115
|
+
client: Any,
|
|
116
|
+
tdx_code: str,
|
|
117
|
+
*,
|
|
118
|
+
period: str,
|
|
119
|
+
page_size: int,
|
|
120
|
+
adjust: str,
|
|
121
|
+
anchor_date: Any,
|
|
122
|
+
kind: str = "stock",
|
|
123
|
+
max_count: int,
|
|
124
|
+
tdx_kline: Callable[..., Any],
|
|
125
|
+
kline_bars: Callable[[Any], Sequence[Any]],
|
|
126
|
+
get_value: Callable[[Any, str, Any], Any],
|
|
127
|
+
) -> tuple[Any, int]:
|
|
128
|
+
current_start = 0
|
|
129
|
+
page_count = 0
|
|
130
|
+
first_series: Any | None = None
|
|
131
|
+
bars_by_time: dict[Any, Any] = {}
|
|
132
|
+
|
|
133
|
+
while current_start <= max_count:
|
|
134
|
+
series = tdx_kline(
|
|
135
|
+
client,
|
|
136
|
+
tdx_code,
|
|
137
|
+
period=period,
|
|
138
|
+
start=current_start,
|
|
139
|
+
count=page_size,
|
|
140
|
+
adjust=adjust,
|
|
141
|
+
anchor_date=anchor_date,
|
|
142
|
+
kind=kind,
|
|
143
|
+
)
|
|
144
|
+
if first_series is None:
|
|
145
|
+
first_series = series
|
|
146
|
+
page_count += 1
|
|
147
|
+
bars = kline_bars(series)
|
|
148
|
+
if not bars:
|
|
149
|
+
break
|
|
150
|
+
|
|
151
|
+
new_bar_count = 0
|
|
152
|
+
for bar in bars:
|
|
153
|
+
key = get_value(bar, "time", None)
|
|
154
|
+
if key in bars_by_time:
|
|
155
|
+
continue
|
|
156
|
+
bars_by_time[key] = bar
|
|
157
|
+
new_bar_count += 1
|
|
158
|
+
|
|
159
|
+
if len(bars) < page_size or new_bar_count == 0:
|
|
160
|
+
break
|
|
161
|
+
current_start += len(bars)
|
|
162
|
+
|
|
163
|
+
assert first_series is not None
|
|
164
|
+
bars = tuple(sorted(bars_by_time.values(), key=lambda item: get_value(item, "time", None)))
|
|
165
|
+
if is_dataclass(first_series):
|
|
166
|
+
return replace(first_series, bars=bars), page_count
|
|
167
|
+
series_dict = {
|
|
168
|
+
key: value
|
|
169
|
+
for key, value in vars(first_series).items()
|
|
170
|
+
if not key.startswith("_")
|
|
171
|
+
}
|
|
172
|
+
series_dict["bars"] = bars
|
|
173
|
+
return SimpleNamespace(**series_dict), page_count
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def request_kline_code_history(
|
|
177
|
+
client: Any,
|
|
178
|
+
index: int,
|
|
179
|
+
tdx_code: str,
|
|
180
|
+
*,
|
|
181
|
+
period: str,
|
|
182
|
+
page_size: int,
|
|
183
|
+
adjust: str,
|
|
184
|
+
anchor_date: Any,
|
|
185
|
+
kind: str = "stock",
|
|
186
|
+
request_series_history: Callable[..., tuple[Any, int]],
|
|
187
|
+
normalize_kline_row: Callable[[Any, Any], dict[str, Any]],
|
|
188
|
+
kline_bars: Callable[[Any], Sequence[Any]],
|
|
189
|
+
row_sort_key: Callable[[dict[str, Any]], Any],
|
|
190
|
+
) -> KlineRequestResult:
|
|
191
|
+
series, page_count = request_series_history(
|
|
192
|
+
client,
|
|
193
|
+
tdx_code,
|
|
194
|
+
period=period,
|
|
195
|
+
page_size=page_size,
|
|
196
|
+
adjust=adjust,
|
|
197
|
+
anchor_date=anchor_date,
|
|
198
|
+
kind=kind,
|
|
199
|
+
)
|
|
200
|
+
rows = sorted((normalize_kline_row(series, bar) for bar in kline_bars(series)), key=row_sort_key)
|
|
201
|
+
return KlineRequestResult(index=index, rows=rows, series=series, page_count=page_count)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def request_recent_daily_bars(
|
|
205
|
+
client: Any,
|
|
206
|
+
tdx_code: str,
|
|
207
|
+
*,
|
|
208
|
+
count: int,
|
|
209
|
+
stats_date: Any,
|
|
210
|
+
max_count: int,
|
|
211
|
+
tdx_kline: Callable[..., Any],
|
|
212
|
+
kline_bars: Callable[[Any], Sequence[Any]],
|
|
213
|
+
get_value: Callable[[Any, str, Any], Any],
|
|
214
|
+
bar_trade_date: Callable[[Any], str | None],
|
|
215
|
+
) -> tuple[list[Any], int]:
|
|
216
|
+
stats_date_text = str(stats_date or "")
|
|
217
|
+
page_size = max(1, int(count))
|
|
218
|
+
current_start = 0
|
|
219
|
+
page_count = 0
|
|
220
|
+
|
|
221
|
+
while current_start <= max_count:
|
|
222
|
+
series = tdx_kline(
|
|
223
|
+
client,
|
|
224
|
+
tdx_code,
|
|
225
|
+
period="day",
|
|
226
|
+
start=current_start,
|
|
227
|
+
count=page_size,
|
|
228
|
+
adjust="none",
|
|
229
|
+
anchor_date=None,
|
|
230
|
+
)
|
|
231
|
+
page_count += 1
|
|
232
|
+
bars = sorted(kline_bars(series), key=lambda item: get_value(item, "time", None), reverse=True)
|
|
233
|
+
if not bars:
|
|
234
|
+
break
|
|
235
|
+
|
|
236
|
+
filtered: list[Any] = []
|
|
237
|
+
has_base_bar = False
|
|
238
|
+
for bar in bars:
|
|
239
|
+
trade_date = bar_trade_date(bar)
|
|
240
|
+
if stats_date_text and trade_date and trade_date > stats_date_text:
|
|
241
|
+
continue
|
|
242
|
+
filtered.append(bar)
|
|
243
|
+
if stats_date_text and trade_date and trade_date < stats_date_text:
|
|
244
|
+
has_base_bar = True
|
|
245
|
+
if len(filtered) >= 5:
|
|
246
|
+
return filtered, page_count
|
|
247
|
+
|
|
248
|
+
oldest_date = bar_trade_date(bars[-1])
|
|
249
|
+
if filtered and (not stats_date_text or has_base_bar):
|
|
250
|
+
return filtered, page_count
|
|
251
|
+
if stats_date_text and oldest_date and oldest_date < stats_date_text:
|
|
252
|
+
break
|
|
253
|
+
if len(bars) < page_size:
|
|
254
|
+
break
|
|
255
|
+
current_start += len(bars)
|
|
256
|
+
|
|
257
|
+
return [], page_count
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def request_kline_codes_on_host(
|
|
261
|
+
host: str,
|
|
262
|
+
indexed_codes: Sequence[tuple[int, str]],
|
|
263
|
+
*,
|
|
264
|
+
pool_size: int,
|
|
265
|
+
period: str,
|
|
266
|
+
page_size: int,
|
|
267
|
+
adjust: str,
|
|
268
|
+
anchor_date: Any,
|
|
269
|
+
create_client: Callable[..., Any],
|
|
270
|
+
request_code_history: Callable[..., KlineRequestResult],
|
|
271
|
+
client_meta: Callable[[Any], dict[str, Any]],
|
|
272
|
+
) -> KlineHostResult:
|
|
273
|
+
client = create_client(
|
|
274
|
+
hosts=[host],
|
|
275
|
+
pool_size=pool_size,
|
|
276
|
+
heartbeat_interval=None,
|
|
277
|
+
)
|
|
278
|
+
try:
|
|
279
|
+
if hasattr(client, "connect"):
|
|
280
|
+
client.connect()
|
|
281
|
+
worker_count = min(pool_size, max(1, len(indexed_codes)))
|
|
282
|
+
results: list[KlineRequestResult] = []
|
|
283
|
+
with ThreadPoolExecutor(max_workers=worker_count, thread_name_prefix="axdata-tdx-kline-host") as executor:
|
|
284
|
+
futures = [
|
|
285
|
+
executor.submit(
|
|
286
|
+
request_code_history,
|
|
287
|
+
client,
|
|
288
|
+
index,
|
|
289
|
+
tdx_code,
|
|
290
|
+
period=period,
|
|
291
|
+
page_size=page_size,
|
|
292
|
+
adjust=adjust,
|
|
293
|
+
anchor_date=anchor_date,
|
|
294
|
+
)
|
|
295
|
+
for index, tdx_code in indexed_codes
|
|
296
|
+
]
|
|
297
|
+
for future in as_completed(futures):
|
|
298
|
+
results.append(future.result())
|
|
299
|
+
return KlineHostResult(results=results, meta=client_meta(client))
|
|
300
|
+
finally:
|
|
301
|
+
if hasattr(client, "close"):
|
|
302
|
+
client.close()
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def request_kline_codes_parallel(
|
|
306
|
+
hosts: Sequence[str],
|
|
307
|
+
tdx_codes: Sequence[str],
|
|
308
|
+
*,
|
|
309
|
+
pool_size: int,
|
|
310
|
+
period: str,
|
|
311
|
+
page_size: int,
|
|
312
|
+
adjust: str,
|
|
313
|
+
anchor_date: Any,
|
|
314
|
+
request_on_host: Callable[..., KlineHostResult],
|
|
315
|
+
) -> KlineParallelResult:
|
|
316
|
+
capacity = len(hosts) * pool_size
|
|
317
|
+
concurrency_limit = min(len(tdx_codes), capacity)
|
|
318
|
+
|
|
319
|
+
indexed_codes = list(enumerate(tdx_codes))
|
|
320
|
+
worker_count = min(len(hosts), len(indexed_codes))
|
|
321
|
+
grouped_codes = [indexed_codes[index::worker_count] for index in range(worker_count)]
|
|
322
|
+
host_results: list[KlineHostResult] = []
|
|
323
|
+
with ThreadPoolExecutor(max_workers=worker_count, thread_name_prefix="axdata-tdx-kline") as executor:
|
|
324
|
+
futures = [
|
|
325
|
+
executor.submit(
|
|
326
|
+
request_on_host,
|
|
327
|
+
hosts[index],
|
|
328
|
+
grouped_codes[index],
|
|
329
|
+
pool_size=pool_size,
|
|
330
|
+
period=period,
|
|
331
|
+
page_size=page_size,
|
|
332
|
+
adjust=adjust,
|
|
333
|
+
anchor_date=anchor_date,
|
|
334
|
+
)
|
|
335
|
+
for index in range(worker_count)
|
|
336
|
+
if grouped_codes[index]
|
|
337
|
+
]
|
|
338
|
+
for future in as_completed(futures):
|
|
339
|
+
host_results.append(future.result())
|
|
340
|
+
|
|
341
|
+
return KlineParallelResult(
|
|
342
|
+
results=[result for host_result in host_results for result in host_result.results],
|
|
343
|
+
host_metas=[host_result.meta for host_result in host_results],
|
|
344
|
+
host_count=len(hosts),
|
|
345
|
+
pool_size_per_host=pool_size,
|
|
346
|
+
concurrency_capacity=capacity,
|
|
347
|
+
concurrency_limit=concurrency_limit,
|
|
348
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""TDX data-root scoped cache helpers owned by the provider package."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def tdx_server_cache_root(data_root: str | Path | None) -> str | None:
|
|
9
|
+
"""Return the data-root scoped TDX server cache directory."""
|
|
10
|
+
|
|
11
|
+
if data_root in (None, ""):
|
|
12
|
+
return None
|
|
13
|
+
return str(Path(data_root).expanduser().resolve() / "cache" / "tdx_servers")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def tdx_stats_cache_root(data_root: str | Path | None) -> str | None:
|
|
17
|
+
"""Return the data-root scoped TDX statistics resource cache directory."""
|
|
18
|
+
|
|
19
|
+
if data_root in (None, ""):
|
|
20
|
+
return None
|
|
21
|
+
return str(Path(data_root).expanduser().resolve() / "cache" / "tdx" / "stats")
|