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.
Files changed (427) hide show
  1. axdata/__init__.py +16 -0
  2. axdata/cache.py +19 -0
  3. axdata/client.py +1223 -0
  4. axdata-0.1.0.dist-info/METADATA +238 -0
  5. axdata-0.1.0.dist-info/RECORD +427 -0
  6. axdata-0.1.0.dist-info/WHEEL +5 -0
  7. axdata-0.1.0.dist-info/entry_points.txt +8 -0
  8. axdata-0.1.0.dist-info/licenses/LICENSE +162 -0
  9. axdata-0.1.0.dist-info/top_level.txt +6 -0
  10. axdata_core/__init__.py +221 -0
  11. axdata_core/_tdx_wire/__init__.py +35 -0
  12. axdata_core/_tdx_wire/_shim.py +140 -0
  13. axdata_core/_tdx_wire/api/__init__.py +51 -0
  14. axdata_core/_tdx_wire/api/auction.py +24 -0
  15. axdata_core/_tdx_wire/api/bars.py +24 -0
  16. axdata_core/_tdx_wire/api/base.py +26 -0
  17. axdata_core/_tdx_wire/api/codes.py +25 -0
  18. axdata_core/_tdx_wire/api/corporate.py +24 -0
  19. axdata_core/_tdx_wire/api/finance.py +24 -0
  20. axdata_core/_tdx_wire/api/intraday.py +24 -0
  21. axdata_core/_tdx_wire/api/quotes.py +26 -0
  22. axdata_core/_tdx_wire/api/resources.py +25 -0
  23. axdata_core/_tdx_wire/api/session.py +24 -0
  24. axdata_core/_tdx_wire/api/trades.py +24 -0
  25. axdata_core/_tdx_wire/client.py +33 -0
  26. axdata_core/_tdx_wire/exceptions.py +27 -0
  27. axdata_core/_tdx_wire/hosts.py +106 -0
  28. axdata_core/_tdx_wire/models/__init__.py +93 -0
  29. axdata_core/_tdx_wire/models/auction.py +26 -0
  30. axdata_core/_tdx_wire/models/corporate.py +27 -0
  31. axdata_core/_tdx_wire/models/finance.py +26 -0
  32. axdata_core/_tdx_wire/models/intraday.py +31 -0
  33. axdata_core/_tdx_wire/models/kline.py +27 -0
  34. axdata_core/_tdx_wire/models/quote.py +32 -0
  35. axdata_core/_tdx_wire/models/resource.py +24 -0
  36. axdata_core/_tdx_wire/models/security.py +24 -0
  37. axdata_core/_tdx_wire/models/session.py +27 -0
  38. axdata_core/_tdx_wire/models/subchart.py +25 -0
  39. axdata_core/_tdx_wire/models/trade.py +28 -0
  40. axdata_core/_tdx_wire/protocol/__init__.py +49 -0
  41. axdata_core/_tdx_wire/protocol/commands/__init__.py +43 -0
  42. axdata_core/_tdx_wire/protocol/commands/auction.py +110 -0
  43. axdata_core/_tdx_wire/protocol/commands/codec.py +43 -0
  44. axdata_core/_tdx_wire/protocol/commands/corporate.py +98 -0
  45. axdata_core/_tdx_wire/protocol/commands/finance.py +96 -0
  46. axdata_core/_tdx_wire/protocol/commands/intraday.py +122 -0
  47. axdata_core/_tdx_wire/protocol/commands/klines.py +102 -0
  48. axdata_core/_tdx_wire/protocol/commands/lookup.py +36 -0
  49. axdata_core/_tdx_wire/protocol/commands/price_limits.py +89 -0
  50. axdata_core/_tdx_wire/protocol/commands/quotes.py +102 -0
  51. axdata_core/_tdx_wire/protocol/commands/registry.py +36 -0
  52. axdata_core/_tdx_wire/protocol/commands/resources.py +99 -0
  53. axdata_core/_tdx_wire/protocol/commands/security.py +103 -0
  54. axdata_core/_tdx_wire/protocol/commands/session.py +82 -0
  55. axdata_core/_tdx_wire/protocol/commands/subchart.py +97 -0
  56. axdata_core/_tdx_wire/protocol/commands/trades.py +107 -0
  57. axdata_core/_tdx_wire/protocol/constants.py +124 -0
  58. axdata_core/_tdx_wire/protocol/frame.py +68 -0
  59. axdata_core/_tdx_wire/protocol/unit.py +85 -0
  60. axdata_core/_tdx_wire/py.typed +1 -0
  61. axdata_core/_tdx_wire/transport/__init__.py +34 -0
  62. axdata_core/_tdx_wire/transport/base.py +25 -0
  63. axdata_core/_tdx_wire/transport/memory.py +24 -0
  64. axdata_core/_tdx_wire/transport/pool.py +32 -0
  65. axdata_core/_tdx_wire/transport/socket.py +39 -0
  66. axdata_core/adapters/__init__.py +0 -0
  67. axdata_core/adapters/cls/__init__.py +17 -0
  68. axdata_core/adapters/cls/provider_bridge.py +23 -0
  69. axdata_core/adapters/cls/request.py +632 -0
  70. axdata_core/adapters/cls/source_adapter_registry.py +31 -0
  71. axdata_core/adapters/cninfo/__init__.py +17 -0
  72. axdata_core/adapters/cninfo/provider_bridge.py +25 -0
  73. axdata_core/adapters/cninfo/request.py +2425 -0
  74. axdata_core/adapters/cninfo/source_adapter_registry.py +42 -0
  75. axdata_core/adapters/eastmoney/__init__.py +17 -0
  76. axdata_core/adapters/eastmoney/provider_bridge.py +25 -0
  77. axdata_core/adapters/eastmoney/request.py +1128 -0
  78. axdata_core/adapters/eastmoney/source_adapter_registry.py +42 -0
  79. axdata_core/adapters/exchange/__init__.py +17 -0
  80. axdata_core/adapters/exchange/provider_bridge.py +25 -0
  81. axdata_core/adapters/exchange/request.py +1214 -0
  82. axdata_core/adapters/exchange/source_adapter_registry.py +42 -0
  83. axdata_core/adapters/kph/__init__.py +17 -0
  84. axdata_core/adapters/kph/provider_bridge.py +23 -0
  85. axdata_core/adapters/kph/request.py +509 -0
  86. axdata_core/adapters/kph/source_adapter_registry.py +31 -0
  87. axdata_core/adapters/sina/__init__.py +17 -0
  88. axdata_core/adapters/sina/provider_bridge.py +25 -0
  89. axdata_core/adapters/sina/request.py +5155 -0
  90. axdata_core/adapters/sina/source_adapter_registry.py +42 -0
  91. axdata_core/adapters/tdx/__init__.py +32 -0
  92. axdata_core/adapters/tdx/adjustment.py +50 -0
  93. axdata_core/adapters/tdx/adjustment_fetch.py +51 -0
  94. axdata_core/adapters/tdx/auction_fetch.py +51 -0
  95. axdata_core/adapters/tdx/client_factory.py +110 -0
  96. axdata_core/adapters/tdx/code_fetch.py +62 -0
  97. axdata_core/adapters/tdx/codes.py +54 -0
  98. axdata_core/adapters/tdx/derived_rows.py +69 -0
  99. axdata_core/adapters/tdx/downloader.py +193 -0
  100. axdata_core/adapters/tdx/downloader_interface_sets.py +50 -0
  101. axdata_core/adapters/tdx/downloader_profiles.py +43 -0
  102. axdata_core/adapters/tdx/downloader_registry.py +115 -0
  103. axdata_core/adapters/tdx/execution_utils.py +55 -0
  104. axdata_core/adapters/tdx/f10_executor.py +57 -0
  105. axdata_core/adapters/tdx/f10_normalize.py +61 -0
  106. axdata_core/adapters/tdx/f10_params.py +57 -0
  107. axdata_core/adapters/tdx/f10_postprocess.py +67 -0
  108. axdata_core/adapters/tdx/f10_render.py +48 -0
  109. axdata_core/adapters/tdx/f10_request.py +62 -0
  110. axdata_core/adapters/tdx/finance_fetch.py +61 -0
  111. axdata_core/adapters/tdx/finance_maps.py +54 -0
  112. axdata_core/adapters/tdx/finance_normalize.py +57 -0
  113. axdata_core/adapters/tdx/host_config.py +115 -0
  114. axdata_core/adapters/tdx/interface_sets.py +50 -0
  115. axdata_core/adapters/tdx/intraday_fetch.py +68 -0
  116. axdata_core/adapters/tdx/kline_helpers.py +58 -0
  117. axdata_core/adapters/tdx/limit_ladder_fetch.py +60 -0
  118. axdata_core/adapters/tdx/limit_ladder_topics.py +53 -0
  119. axdata_core/adapters/tdx/normalize_utils.py +75 -0
  120. axdata_core/adapters/tdx/options.py +61 -0
  121. axdata_core/adapters/tdx/price_limit_calendar.py +49 -0
  122. axdata_core/adapters/tdx/price_limit_fetch.py +53 -0
  123. axdata_core/adapters/tdx/price_limit_history.py +50 -0
  124. axdata_core/adapters/tdx/price_limits.py +58 -0
  125. axdata_core/adapters/tdx/provider_bridge.py +68 -0
  126. axdata_core/adapters/tdx/quote_fetch.py +61 -0
  127. axdata_core/adapters/tdx/quote_identity.py +49 -0
  128. axdata_core/adapters/tdx/rank_fetch.py +55 -0
  129. axdata_core/adapters/tdx/rank_params.py +52 -0
  130. axdata_core/adapters/tdx/realtime_refresh.py +45 -0
  131. axdata_core/adapters/tdx/request.py +11 -0
  132. axdata_core/adapters/tdx/request_adapter_runtime.py +41 -0
  133. axdata_core/adapters/tdx/request_client.py +51 -0
  134. axdata_core/adapters/tdx/request_compat.py +89 -0
  135. axdata_core/adapters/tdx/request_dispatch.py +50 -0
  136. axdata_core/adapters/tdx/request_filters.py +60 -0
  137. axdata_core/adapters/tdx/request_host_config.py +110 -0
  138. axdata_core/adapters/tdx/request_limits.py +59 -0
  139. axdata_core/adapters/tdx/request_methods.py +41 -0
  140. axdata_core/adapters/tdx/request_params.py +62 -0
  141. axdata_core/adapters/tdx/request_seams.py +41 -0
  142. axdata_core/adapters/tdx/resources/__init__.py +0 -0
  143. axdata_core/adapters/tdx/resources/finance_maps/__init__.py +0 -0
  144. axdata_core/adapters/tdx/resources/finance_maps/incon.dat +3702 -0
  145. axdata_core/adapters/tdx/resources/finance_maps/tdxhy.cfg +5620 -0
  146. axdata_core/adapters/tdx/resources/finance_maps/tdxzs.cfg +605 -0
  147. axdata_core/adapters/tdx/security_codes.py +54 -0
  148. axdata_core/adapters/tdx/series_history.py +57 -0
  149. axdata_core/adapters/tdx/server_cache.py +58 -0
  150. axdata_core/adapters/tdx/snapshot_normalize.py +56 -0
  151. axdata_core/adapters/tdx/source_adapter_registry.py +69 -0
  152. axdata_core/adapters/tdx/source_execution.py +44 -0
  153. axdata_core/adapters/tdx/source_execution_registry.py +70 -0
  154. axdata_core/adapters/tdx/stats_cache.py +184 -0
  155. axdata_core/adapters/tdx/stats_models.py +159 -0
  156. axdata_core/adapters/tdx/stats_resource.py +304 -0
  157. axdata_core/adapters/tdx/status_fetch.py +55 -0
  158. axdata_core/adapters/tdx/time_series_normalize.py +67 -0
  159. axdata_core/adapters/tdx/tqlex.py +50 -0
  160. axdata_core/adapters/tdx/wire_requests.py +60 -0
  161. axdata_core/adapters/tdx_ext/__init__.py +66 -0
  162. axdata_core/adapters/tdx_ext/client.py +688 -0
  163. axdata_core/adapters/tdx_ext/exceptions.py +51 -0
  164. axdata_core/adapters/tdx_ext/host_config.py +40 -0
  165. axdata_core/adapters/tdx_ext/interface_sets.py +65 -0
  166. axdata_core/adapters/tdx_ext/local_cache.py +649 -0
  167. axdata_core/adapters/tdx_ext/models.py +96 -0
  168. axdata_core/adapters/tdx_ext/options.py +36 -0
  169. axdata_core/adapters/tdx_ext/pool.py +153 -0
  170. axdata_core/adapters/tdx_ext/provider_bridge.py +35 -0
  171. axdata_core/adapters/tdx_ext/request.py +498 -0
  172. axdata_core/adapters/tdx_ext/request_execution.py +118 -0
  173. axdata_core/adapters/tdx_ext/request_instruments.py +221 -0
  174. axdata_core/adapters/tdx_ext/request_normalize.py +356 -0
  175. axdata_core/adapters/tdx_ext/request_params.py +157 -0
  176. axdata_core/adapters/tdx_ext/request_series.py +98 -0
  177. axdata_core/adapters/tdx_ext/server_cache.py +13 -0
  178. axdata_core/adapters/tdx_ext/servers.py +35 -0
  179. axdata_core/adapters/tdx_ext/source_adapter_registry.py +42 -0
  180. axdata_core/adapters/tdx_ext/source_execution.py +19 -0
  181. axdata_core/adapters/tdx_ext/source_execution_registry.py +43 -0
  182. axdata_core/adapters/tencent/__init__.py +17 -0
  183. axdata_core/adapters/tencent/provider_bridge.py +25 -0
  184. axdata_core/adapters/tencent/request.py +729 -0
  185. axdata_core/adapters/tencent/source_adapter_registry.py +42 -0
  186. axdata_core/axp.py +1843 -0
  187. axdata_core/builtin_providers.py +586 -0
  188. axdata_core/builtin_source_declarations.py +156 -0
  189. axdata_core/cli.py +1818 -0
  190. axdata_core/collector_registry.py +227 -0
  191. axdata_core/collector_runner.py +1016 -0
  192. axdata_core/collector_scheduler.py +3155 -0
  193. axdata_core/collector_templates.py +339 -0
  194. axdata_core/data_browser.py +1696 -0
  195. axdata_core/diagnostics.py +734 -0
  196. axdata_core/downloader_engine.py +1480 -0
  197. axdata_core/downloader_registry.py +62 -0
  198. axdata_core/downloaders.py +1619 -0
  199. axdata_core/legacy_provider_adapter.py +68 -0
  200. axdata_core/paths.py +51 -0
  201. axdata_core/plugin_config.py +272 -0
  202. axdata_core/plugin_status.py +419 -0
  203. axdata_core/plugins.py +1363 -0
  204. axdata_core/provider_catalog.py +462 -0
  205. axdata_core/provider_registry.py +833 -0
  206. axdata_core/quality.py +86 -0
  207. axdata_core/query.py +242 -0
  208. axdata_core/resources/__init__.py +2 -0
  209. axdata_core/resources/tdx_extended_servers.json +22 -0
  210. axdata_core/resources/tdx_quote_servers.json +49 -0
  211. axdata_core/sample_collectors.py +42 -0
  212. axdata_core/schema.py +385 -0
  213. axdata_core/source_adapter_factory.py +95 -0
  214. axdata_core/source_adapter_options.py +18 -0
  215. axdata_core/source_errors.py +43 -0
  216. axdata_core/source_execution_options.py +37 -0
  217. axdata_core/source_execution_registry.py +27 -0
  218. axdata_core/source_projection.py +21 -0
  219. axdata_core/source_request.py +441 -0
  220. axdata_core/source_session.py +355 -0
  221. axdata_core/sources/__init__.py +40 -0
  222. axdata_core/sources/base.py +112 -0
  223. axdata_core/sources/catalog.py +60 -0
  224. axdata_core/sources/cls/__init__.py +5 -0
  225. axdata_core/sources/cls/catalog.py +231 -0
  226. axdata_core/sources/cninfo/__init__.py +5 -0
  227. axdata_core/sources/cninfo/catalog.py +1994 -0
  228. axdata_core/sources/display_docs.py +139 -0
  229. axdata_core/sources/eastmoney/__init__.py +5 -0
  230. axdata_core/sources/eastmoney/catalog.py +509 -0
  231. axdata_core/sources/exchange/__init__.py +5 -0
  232. axdata_core/sources/exchange/catalog.py +361 -0
  233. axdata_core/sources/kph/__init__.py +5 -0
  234. axdata_core/sources/kph/catalog.py +255 -0
  235. axdata_core/sources/sina/__init__.py +5 -0
  236. axdata_core/sources/sina/catalog.py +2951 -0
  237. axdata_core/sources/tdx/__init__.py +5 -0
  238. axdata_core/sources/tdx/catalog.py +4546 -0
  239. axdata_core/sources/tdx_ext/__init__.py +5 -0
  240. axdata_core/sources/tdx_ext/catalog.py +1518 -0
  241. axdata_core/sources/tencent/__init__.py +5 -0
  242. axdata_core/sources/tencent/catalog.py +370 -0
  243. axdata_core/storage.py +186 -0
  244. axdata_core/tdx_f10_catalog.py +52 -0
  245. axdata_core/tdx_f10_models.py +50 -0
  246. axdata_core/tdx_f10_names.py +47 -0
  247. axdata_core/tdx_f10_specs.py +56 -0
  248. axdata_core/tdx_plugin_required.py +43 -0
  249. axdata_core/tdx_server_config.py +65 -0
  250. axdata_core/trade_calendar_cache.py +397 -0
  251. axdata_source_cninfo/__init__.py +15 -0
  252. axdata_source_cninfo/adapter.py +31 -0
  253. axdata_source_cninfo/axdata-provider.json +384 -0
  254. axdata_source_cninfo/catalog.py +209 -0
  255. axdata_source_cninfo/metadata.py +8 -0
  256. axdata_source_cninfo/provider.py +41 -0
  257. axdata_source_tdx/__init__.py +15 -0
  258. axdata_source_tdx/_tdx_wire/__init__.py +26 -0
  259. axdata_source_tdx/_tdx_wire/_binary.py +218 -0
  260. axdata_source_tdx/_tdx_wire/_code_utils.py +42 -0
  261. axdata_source_tdx/_tdx_wire/_command_codec.py +186 -0
  262. axdata_source_tdx/_tdx_wire/_command_codes.py +74 -0
  263. axdata_source_tdx/_tdx_wire/_command_defaults.py +15 -0
  264. axdata_source_tdx/_tdx_wire/_command_dispatch.py +96 -0
  265. axdata_source_tdx/_tdx_wire/_command_layouts.py +96 -0
  266. axdata_source_tdx/_tdx_wire/_command_lookup.py +25 -0
  267. axdata_source_tdx/_tdx_wire/_command_metadata.py +32 -0
  268. axdata_source_tdx/_tdx_wire/_command_registry.py +61 -0
  269. axdata_source_tdx/_tdx_wire/_connection_defaults.py +13 -0
  270. axdata_source_tdx/_tdx_wire/_host_defaults.py +51 -0
  271. axdata_source_tdx/_tdx_wire/_host_probe.py +81 -0
  272. axdata_source_tdx/_tdx_wire/_host_resource.py +70 -0
  273. axdata_source_tdx/_tdx_wire/_host_utils.py +31 -0
  274. axdata_source_tdx/_tdx_wire/_market.py +66 -0
  275. axdata_source_tdx/_tdx_wire/_request_defaults.py +11 -0
  276. axdata_source_tdx/_tdx_wire/_security_classification.py +61 -0
  277. axdata_source_tdx/_tdx_wire/_time_utils.py +7 -0
  278. axdata_source_tdx/_tdx_wire/api/__init__.py +45 -0
  279. axdata_source_tdx/_tdx_wire/api/auction.py +25 -0
  280. axdata_source_tdx/_tdx_wire/api/bars.py +31 -0
  281. axdata_source_tdx/_tdx_wire/api/base.py +39 -0
  282. axdata_source_tdx/_tdx_wire/api/codes.py +25 -0
  283. axdata_source_tdx/_tdx_wire/api/corporate.py +11 -0
  284. axdata_source_tdx/_tdx_wire/api/finance.py +10 -0
  285. axdata_source_tdx/_tdx_wire/api/intraday.py +38 -0
  286. axdata_source_tdx/_tdx_wire/api/quotes.py +78 -0
  287. axdata_source_tdx/_tdx_wire/api/resources.py +34 -0
  288. axdata_source_tdx/_tdx_wire/api/session.py +16 -0
  289. axdata_source_tdx/_tdx_wire/api/trades.py +34 -0
  290. axdata_source_tdx/_tdx_wire/client.py +470 -0
  291. axdata_source_tdx/_tdx_wire/exceptions.py +25 -0
  292. axdata_source_tdx/_tdx_wire/hosts.py +27 -0
  293. axdata_source_tdx/_tdx_wire/models/__init__.py +87 -0
  294. axdata_source_tdx/_tdx_wire/models/auction.py +58 -0
  295. axdata_source_tdx/_tdx_wire/models/corporate.py +59 -0
  296. axdata_source_tdx/_tdx_wire/models/finance.py +80 -0
  297. axdata_source_tdx/_tdx_wire/models/intraday.py +112 -0
  298. axdata_source_tdx/_tdx_wire/models/kline.py +58 -0
  299. axdata_source_tdx/_tdx_wire/models/quote.py +262 -0
  300. axdata_source_tdx/_tdx_wire/models/resource.py +18 -0
  301. axdata_source_tdx/_tdx_wire/models/security.py +28 -0
  302. axdata_source_tdx/_tdx_wire/models/session.py +30 -0
  303. axdata_source_tdx/_tdx_wire/models/subchart.py +39 -0
  304. axdata_source_tdx/_tdx_wire/models/trade.py +46 -0
  305. axdata_source_tdx/_tdx_wire/protocol/__init__.py +43 -0
  306. axdata_source_tdx/_tdx_wire/protocol/_frame_constants.py +5 -0
  307. axdata_source_tdx/_tdx_wire/protocol/commands/__init__.py +37 -0
  308. axdata_source_tdx/_tdx_wire/protocol/commands/auction.py +165 -0
  309. axdata_source_tdx/_tdx_wire/protocol/commands/codec.py +37 -0
  310. axdata_source_tdx/_tdx_wire/protocol/commands/corporate.py +163 -0
  311. axdata_source_tdx/_tdx_wire/protocol/commands/finance.py +180 -0
  312. axdata_source_tdx/_tdx_wire/protocol/commands/intraday.py +382 -0
  313. axdata_source_tdx/_tdx_wire/protocol/commands/klines.py +396 -0
  314. axdata_source_tdx/_tdx_wire/protocol/commands/lookup.py +31 -0
  315. axdata_source_tdx/_tdx_wire/protocol/commands/price_limits.py +110 -0
  316. axdata_source_tdx/_tdx_wire/protocol/commands/quotes.py +804 -0
  317. axdata_source_tdx/_tdx_wire/protocol/commands/registry.py +30 -0
  318. axdata_source_tdx/_tdx_wire/protocol/commands/resources.py +107 -0
  319. axdata_source_tdx/_tdx_wire/protocol/commands/security.py +163 -0
  320. axdata_source_tdx/_tdx_wire/protocol/commands/session.py +129 -0
  321. axdata_source_tdx/_tdx_wire/protocol/commands/subchart.py +182 -0
  322. axdata_source_tdx/_tdx_wire/protocol/commands/trades.py +275 -0
  323. axdata_source_tdx/_tdx_wire/protocol/constants.py +70 -0
  324. axdata_source_tdx/_tdx_wire/protocol/frame.py +141 -0
  325. axdata_source_tdx/_tdx_wire/protocol/unit.py +98 -0
  326. axdata_source_tdx/_tdx_wire/py.typed +1 -0
  327. axdata_source_tdx/_tdx_wire/transport/__init__.py +28 -0
  328. axdata_source_tdx/_tdx_wire/transport/base.py +21 -0
  329. axdata_source_tdx/_tdx_wire/transport/memory.py +42 -0
  330. axdata_source_tdx/_tdx_wire/transport/pool.py +148 -0
  331. axdata_source_tdx/_tdx_wire/transport/socket.py +373 -0
  332. axdata_source_tdx/adapter.py +31 -0
  333. axdata_source_tdx/adjustment.py +163 -0
  334. axdata_source_tdx/adjustment_fetch.py +148 -0
  335. axdata_source_tdx/auction_fetch.py +162 -0
  336. axdata_source_tdx/axdata-provider.json +23680 -0
  337. axdata_source_tdx/catalog.py +39 -0
  338. axdata_source_tdx/client_factory.py +61 -0
  339. axdata_source_tdx/code_fetch.py +579 -0
  340. axdata_source_tdx/codes.py +69 -0
  341. axdata_source_tdx/collectors.py +525 -0
  342. axdata_source_tdx/derived_rows.py +500 -0
  343. axdata_source_tdx/downloader.py +139 -0
  344. axdata_source_tdx/downloader_interface_sets.py +29 -0
  345. axdata_source_tdx/downloader_profiles.py +731 -0
  346. axdata_source_tdx/downloader_registry.py +85 -0
  347. axdata_source_tdx/execution_utils.py +141 -0
  348. axdata_source_tdx/f10_executor.py +414 -0
  349. axdata_source_tdx/f10_normalize.py +169 -0
  350. axdata_source_tdx/f10_params.py +221 -0
  351. axdata_source_tdx/f10_postprocess.py +405 -0
  352. axdata_source_tdx/f10_render.py +29 -0
  353. axdata_source_tdx/f10_request.py +365 -0
  354. axdata_source_tdx/finance_fetch.py +514 -0
  355. axdata_source_tdx/finance_maps.py +377 -0
  356. axdata_source_tdx/finance_normalize.py +273 -0
  357. axdata_source_tdx/host_config.py +51 -0
  358. axdata_source_tdx/interface_sets.py +180 -0
  359. axdata_source_tdx/intraday_fetch.py +600 -0
  360. axdata_source_tdx/kline_helpers.py +333 -0
  361. axdata_source_tdx/limit_ladder_fetch.py +614 -0
  362. axdata_source_tdx/limit_ladder_topics.py +280 -0
  363. axdata_source_tdx/metadata.py +8 -0
  364. axdata_source_tdx/normalize_utils.py +264 -0
  365. axdata_source_tdx/options.py +195 -0
  366. axdata_source_tdx/price_limit_calendar.py +106 -0
  367. axdata_source_tdx/price_limit_fetch.py +264 -0
  368. axdata_source_tdx/price_limit_history.py +100 -0
  369. axdata_source_tdx/price_limits.py +142 -0
  370. axdata_source_tdx/provider.py +44 -0
  371. axdata_source_tdx/provider_bridge.py +43 -0
  372. axdata_source_tdx/quote_fetch.py +485 -0
  373. axdata_source_tdx/quote_identity.py +50 -0
  374. axdata_source_tdx/rank_fetch.py +316 -0
  375. axdata_source_tdx/rank_params.py +181 -0
  376. axdata_source_tdx/realtime_refresh.py +51 -0
  377. axdata_source_tdx/request_adapter.py +533 -0
  378. axdata_source_tdx/request_adapter_runtime.py +302 -0
  379. axdata_source_tdx/request_client.py +98 -0
  380. axdata_source_tdx/request_compat.py +432 -0
  381. axdata_source_tdx/request_dispatch.py +138 -0
  382. axdata_source_tdx/request_entrypoints.py +146 -0
  383. axdata_source_tdx/request_filters.py +154 -0
  384. axdata_source_tdx/request_host_config.py +103 -0
  385. axdata_source_tdx/request_limits.py +15 -0
  386. axdata_source_tdx/request_methods.py +1910 -0
  387. axdata_source_tdx/request_params.py +225 -0
  388. axdata_source_tdx/request_seams.py +534 -0
  389. axdata_source_tdx/resources/__init__.py +0 -0
  390. axdata_source_tdx/resources/finance_maps/__init__.py +1 -0
  391. axdata_source_tdx/resources/finance_maps/incon.dat +3702 -0
  392. axdata_source_tdx/resources/finance_maps/tdxhy.cfg +5620 -0
  393. axdata_source_tdx/resources/finance_maps/tdxzs.cfg +605 -0
  394. axdata_source_tdx/resources/tdx_extended_servers.json +22 -0
  395. axdata_source_tdx/resources/tdx_quote_servers.json +49 -0
  396. axdata_source_tdx/security_codes.py +127 -0
  397. axdata_source_tdx/series_history.py +348 -0
  398. axdata_source_tdx/server_cache.py +21 -0
  399. axdata_source_tdx/snapshot_normalize.py +232 -0
  400. axdata_source_tdx/source_adapter_registry.py +42 -0
  401. axdata_source_tdx/source_execution.py +22 -0
  402. axdata_source_tdx/source_execution_registry.py +43 -0
  403. axdata_source_tdx/stats_cache.py +150 -0
  404. axdata_source_tdx/stats_models.py +161 -0
  405. axdata_source_tdx/stats_resource.py +242 -0
  406. axdata_source_tdx/status_fetch.py +209 -0
  407. axdata_source_tdx/tdx_f10_catalog.py +957 -0
  408. axdata_source_tdx/tdx_f10_models.py +47 -0
  409. axdata_source_tdx/tdx_f10_names.py +48 -0
  410. axdata_source_tdx/tdx_f10_specs.py +1142 -0
  411. axdata_source_tdx/tdx_server_config.py +389 -0
  412. axdata_source_tdx/time_series_normalize.py +370 -0
  413. axdata_source_tdx/tqlex.py +138 -0
  414. axdata_source_tdx/wire.py +32 -0
  415. axdata_source_tdx/wire_requests.py +190 -0
  416. axdata_source_tdx_ext/__init__.py +15 -0
  417. axdata_source_tdx_ext/adapter.py +31 -0
  418. axdata_source_tdx_ext/axdata-provider.json +9424 -0
  419. axdata_source_tdx_ext/catalog.py +33 -0
  420. axdata_source_tdx_ext/metadata.py +8 -0
  421. axdata_source_tdx_ext/provider.py +44 -0
  422. axdata_source_tencent/__init__.py +15 -0
  423. axdata_source_tencent/adapter.py +31 -0
  424. axdata_source_tencent/axdata-provider.json +291 -0
  425. axdata_source_tencent/catalog.py +190 -0
  426. axdata_source_tencent/metadata.py +8 -0
  427. axdata_source_tencent/provider.py +41 -0
@@ -0,0 +1,218 @@
1
+ """Provider-owned lightweight binary helpers for 7709 parsers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from importlib import import_module
6
+ _EXCEPTIONS_MODULE = "axdata_source_tdx._tdx_wire.exceptions"
7
+ _EXCEPTION_EXPORTS = {"ProtocolError"}
8
+ _STDLIB_EXPORTS = {"date", "datetime", "math", "struct"}
9
+
10
+
11
+ def _protocol_error():
12
+ return import_module(_EXCEPTIONS_MODULE).ProtocolError
13
+
14
+
15
+ def _date_exports():
16
+ module = import_module("datetime")
17
+ globals()["date"] = module.date
18
+ globals()["datetime"] = module.datetime
19
+ return module.date, module.datetime
20
+
21
+
22
+ def _math_module():
23
+ module = import_module("math")
24
+ globals()["math"] = module
25
+ return module
26
+
27
+
28
+ def _struct_module():
29
+ module = import_module("struct")
30
+ globals()["struct"] = module
31
+ return module
32
+
33
+
34
+ def little_u16(data: bytes) -> int:
35
+ return int.from_bytes(data, "little", signed=False)
36
+
37
+
38
+ def little_u32(data: bytes) -> int:
39
+ return int.from_bytes(data, "little", signed=False)
40
+
41
+
42
+ def little_f32(data: bytes) -> float:
43
+ return _struct_module().unpack("<f", data)[0]
44
+
45
+
46
+ def tdx_quantity_u32(data: bytes) -> float:
47
+ raw = little_u32(data)
48
+ if raw == 0:
49
+ return 0.0
50
+ return tdx_quantity_from_u32(raw)
51
+
52
+
53
+ def tdx_quantity_from_u32(raw: int) -> float:
54
+ """Decode TDX's packed quantity number used by some capital-change fields."""
55
+
56
+ log_point = raw >> 24
57
+ byte_2 = (raw >> 16) & 0xFF
58
+ byte_1 = (raw >> 8) & 0xFF
59
+ byte_0 = raw & 0xFF
60
+
61
+ exp_main = log_point * 2 - 0x7F
62
+ exp_byte_2 = log_point * 2 - 0x86
63
+ exp_byte_1 = log_point * 2 - 0x8E
64
+ exp_byte_0 = log_point * 2 - 0x96
65
+
66
+ main = 2.0 ** abs(exp_main)
67
+ if exp_main < 0:
68
+ main = 1.0 / main
69
+
70
+ if byte_2 > 0x80:
71
+ byte_2_value = (2.0**exp_byte_2) * 128.0
72
+ byte_2_value += float(byte_2 & 0x7F) * (2.0 ** (exp_byte_2 + 1))
73
+ elif exp_byte_2 >= 0:
74
+ byte_2_value = (2.0**exp_byte_2) * float(byte_2)
75
+ else:
76
+ byte_2_value = (1.0 / (2.0**exp_byte_2)) * float(byte_2)
77
+
78
+ byte_1_value = (2.0**exp_byte_1) * float(byte_1)
79
+ byte_0_value = (2.0**exp_byte_0) * float(byte_0)
80
+ if byte_2 & 0x80:
81
+ byte_1_value *= 2.0
82
+ byte_0_value *= 2.0
83
+
84
+ return main + byte_2_value + byte_1_value + byte_0_value
85
+
86
+
87
+ def decode_compact_float(value: int) -> float:
88
+ """Decode the compact float encoding used by TDX quote and K-line amounts."""
89
+
90
+ if value == 0:
91
+ return 0.0
92
+
93
+ signed = int.from_bytes(value.to_bytes(4, "big", signed=False), "big", signed=True)
94
+ logpoint = signed >> 24
95
+ hleax = (signed >> 16) & 0xFF
96
+ lheax = (signed >> 8) & 0xFF
97
+ lleax = signed & 0xFF
98
+
99
+ base = _math_module().pow(2.0, float(logpoint * 2 - 0x7F))
100
+ if hleax > 0x80:
101
+ high = base * (64.0 + float(hleax & 0x7F)) / 64.0
102
+ else:
103
+ high = base * float(hleax) / 128.0
104
+
105
+ scale = 2.0 if hleax & 0x80 else 1.0
106
+ middle = base * float(lheax) / 32768.0 * scale
107
+ low = base * float(lleax) / 8388608.0 * scale
108
+ return base + high + middle + low
109
+
110
+
111
+ def decode_gbk_text(data: bytes) -> str:
112
+ return data.decode("gbk", errors="ignore").replace("\x00", "").strip()
113
+
114
+
115
+ def yyyymmdd(value: str | int | date | datetime | None = None) -> int:
116
+ if value is None:
117
+ date_cls, _ = _date_exports()
118
+ return int(date_cls.today().strftime("%Y%m%d"))
119
+ if isinstance(value, int):
120
+ return value
121
+ if not isinstance(value, str):
122
+ date_cls, datetime_cls = _date_exports()
123
+ if isinstance(value, datetime_cls):
124
+ return int(value.date().strftime("%Y%m%d"))
125
+ if isinstance(value, date_cls):
126
+ return int(value.strftime("%Y%m%d"))
127
+
128
+ text = str(value).strip().replace("-", "")
129
+ if len(text) != 8 or not text.isdigit():
130
+ raise _protocol_error()(f"invalid date: {value!r}")
131
+ return int(text)
132
+
133
+
134
+ def date_from_yyyymmdd(raw: int) -> date | None:
135
+ text = f"{raw:08d}"
136
+ try:
137
+ _, datetime_cls = _date_exports()
138
+ return datetime_cls.strptime(text, "%Y%m%d").date()
139
+ except ValueError:
140
+ return None
141
+
142
+
143
+ def consume_tdx_signed_varint(payload: bytes, offset: int) -> tuple[int, int]:
144
+ if offset >= len(payload):
145
+ raise _protocol_error()("unexpected end of payload")
146
+
147
+ value = 0
148
+ position = offset
149
+ shift = 0
150
+ while True:
151
+ if position >= len(payload):
152
+ raise _protocol_error()("unterminated varint")
153
+ byte = payload[position]
154
+ if position == offset:
155
+ value += byte & 0x3F
156
+ shift = 6
157
+ else:
158
+ value += (byte & 0x7F) << shift
159
+ shift += 7
160
+ position += 1
161
+ if byte & 0x80 == 0:
162
+ break
163
+ if payload[offset] & 0x40:
164
+ value = -value
165
+ return value, position
166
+
167
+
168
+ def consume_tdx_varint(payload: bytes, offset: int) -> tuple[int, int]:
169
+ if offset >= len(payload):
170
+ raise _protocol_error()("unexpected end of payload")
171
+
172
+ value = 0
173
+ position = offset
174
+ shift = 0
175
+ while True:
176
+ if position >= len(payload):
177
+ raise _protocol_error()("unterminated varint")
178
+ byte = payload[position]
179
+ value += (byte & 0x7F) << shift
180
+ shift += 7
181
+ position += 1
182
+ if byte & 0x80 == 0:
183
+ break
184
+ return value, position
185
+
186
+
187
+ def __getattr__(name: str):
188
+ if name in _EXCEPTION_EXPORTS:
189
+ value = getattr(import_module(_EXCEPTIONS_MODULE), name)
190
+ globals()[name] = value
191
+ return value
192
+ if name == "math":
193
+ return _math_module()
194
+ if name == "struct":
195
+ return _struct_module()
196
+ if name in {"date", "datetime"}:
197
+ _date_exports()
198
+ return globals()[name]
199
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
200
+
201
+
202
+ def __dir__() -> list[str]:
203
+ return sorted(set(globals()) | set(__all__) | _EXCEPTION_EXPORTS | _STDLIB_EXPORTS)
204
+
205
+
206
+ __all__ = [
207
+ "consume_tdx_signed_varint",
208
+ "consume_tdx_varint",
209
+ "date_from_yyyymmdd",
210
+ "decode_compact_float",
211
+ "decode_gbk_text",
212
+ "little_f32",
213
+ "little_u16",
214
+ "little_u32",
215
+ "tdx_quantity_from_u32",
216
+ "tdx_quantity_u32",
217
+ "yyyymmdd",
218
+ ]
@@ -0,0 +1,42 @@
1
+ """Lightweight TDX security code normalization helpers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from importlib import import_module
6
+
7
+ from axdata_source_tdx._tdx_wire._market import market_to_id
8
+
9
+ _EXCEPTIONS_MODULE = "axdata_source_tdx._tdx_wire.exceptions"
10
+
11
+
12
+ def _protocol_error():
13
+ return import_module(_EXCEPTIONS_MODULE).ProtocolError
14
+
15
+
16
+ def split_code(code: str) -> tuple[int, str, str]:
17
+ full_code = normalize_code(code)
18
+ market = full_code[:2]
19
+ number = full_code[2:]
20
+ return market_to_id(market), market, number
21
+
22
+
23
+ def normalize_code(code: str) -> str:
24
+ text = str(code or "").strip().lower()
25
+ if len(text) == 8 and text[:2] in {"sz", "sh", "bj"} and text[2:].isdigit():
26
+ return text
27
+ if len(text) == 9 and text[6] == ".":
28
+ symbol, suffix = text[:6], text[7:].upper()
29
+ suffix_to_market = {"SH": "sh", "SZ": "sz", "BJ": "bj"}
30
+ market = suffix_to_market.get(suffix)
31
+ if market is None or not symbol.isdigit():
32
+ raise _protocol_error()(f"invalid code: {code!r}")
33
+ return market + symbol
34
+ if len(text) != 6 or not text.isdigit():
35
+ raise _protocol_error()(f"invalid code: {code!r}")
36
+ if text.startswith(("6", "9")):
37
+ return "sh" + text
38
+ if text.startswith(("0", "1", "2", "3")):
39
+ return "sz" + text
40
+ if text.startswith(("8", "92")):
41
+ return "bj" + text
42
+ raise _protocol_error()(f"unable to infer market for code: {code!r}")
@@ -0,0 +1,186 @@
1
+ """Provider-owned command codec dispatch for TDX 7709 protocol commands."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from importlib import import_module
6
+ from typing import Any, Callable
7
+
8
+ _COMMAND_PACKAGE = "axdata_source_tdx._tdx_wire.protocol.commands"
9
+ _CODES_MODULE = "axdata_source_tdx._tdx_wire._command_codes"
10
+ _DISPATCH_MODULE = "axdata_source_tdx._tdx_wire._command_dispatch"
11
+ _EXCEPTIONS_MODULE = "axdata_source_tdx._tdx_wire.exceptions"
12
+
13
+ Builder = Callable[[dict[str, Any], int], Any]
14
+ Parser = Callable[[Any, dict[str, Any] | None], Any]
15
+ _BUILDER_CACHE: dict[int, Builder] = {}
16
+ _PARSER_CACHE: dict[int, Parser] = {}
17
+
18
+
19
+ def _load_callable(module_name: str, function_name: str) -> Callable[..., Any]:
20
+ module = import_module(f"{_COMMAND_PACKAGE}.{module_name}")
21
+ return getattr(module, function_name)
22
+
23
+
24
+ def _lazy_builder(module_name: str, function_name: str) -> Builder:
25
+ def builder(payload: dict[str, Any], msg_id: int) -> Any:
26
+ return _load_callable(module_name, function_name)(payload, msg_id)
27
+
28
+ builder.__name__ = function_name
29
+ builder.__qualname__ = function_name
30
+ builder.__module__ = f"{_COMMAND_PACKAGE}.{module_name}"
31
+ return builder
32
+
33
+
34
+ def _lazy_parser(module_name: str, function_name: str, *, pass_request_payload: bool = True) -> Parser:
35
+ def parser(response: Any, request_payload: dict[str, Any] | None = None) -> Any:
36
+ target = _load_callable(module_name, function_name)
37
+ if pass_request_payload:
38
+ return target(response, request_payload)
39
+ return target(response)
40
+
41
+ parser.__name__ = function_name
42
+ parser.__qualname__ = function_name
43
+ parser.__module__ = f"{_COMMAND_PACKAGE}.{module_name}"
44
+ return parser
45
+
46
+
47
+ def build_command_frame(command: int, payload: dict[str, Any] | None, msg_id: int) -> Any:
48
+ try:
49
+ builder = _builder(command)
50
+ except KeyError as exc:
51
+ raise _unsupported_command_error()(f"7709 command 0x{command:04x} is not enabled yet") from exc
52
+ return builder(dict(payload or {}), msg_id)
53
+
54
+
55
+ def parse_command_response(command: int, response: Any, request_payload: dict[str, Any] | None = None) -> Any:
56
+ try:
57
+ parser = _parser(command)
58
+ except KeyError as exc:
59
+ raise _unsupported_command_error()(f"7709 command 0x{command:04x} is not enabled yet") from exc
60
+ return parser(response, request_payload)
61
+
62
+
63
+ def _command_codes() -> dict[str, int]:
64
+ return import_module(_CODES_MODULE).COMMAND_CODES
65
+
66
+
67
+ def _command_code(name: str) -> int:
68
+ return import_module(_CODES_MODULE).command_code(name)
69
+
70
+
71
+ def _command_name(command: int) -> str:
72
+ return import_module(_CODES_MODULE).command_name(command)
73
+
74
+
75
+ def _builder_targets() -> dict[str, tuple[str, str]]:
76
+ return import_module(_DISPATCH_MODULE).BUILDER_TARGETS
77
+
78
+
79
+ def _parser_targets() -> dict[str, tuple[str, str, bool]]:
80
+ return import_module(_DISPATCH_MODULE).PARSER_TARGETS
81
+
82
+
83
+ def _builder_target_items() -> tuple[tuple[str, tuple[str, str]], ...]:
84
+ return import_module(_DISPATCH_MODULE).BUILDER_TARGET_ITEMS
85
+
86
+
87
+ def _parser_target_items() -> tuple[tuple[str, tuple[str, str, bool]], ...]:
88
+ return import_module(_DISPATCH_MODULE).PARSER_TARGET_ITEMS
89
+
90
+
91
+ def _builder_target(name: str) -> tuple[str, str]:
92
+ return import_module(_DISPATCH_MODULE).builder_target(name)
93
+
94
+
95
+ def _parser_target(name: str) -> tuple[str, str, bool]:
96
+ return import_module(_DISPATCH_MODULE).parser_target(name)
97
+
98
+
99
+ def _builder(command: int) -> Builder:
100
+ builders = globals().get("BUILDERS")
101
+ if builders is not None:
102
+ return builders[command]
103
+ cached = _BUILDER_CACHE.get(command)
104
+ if cached is not None:
105
+ return cached
106
+ command_name = _command_name(command)
107
+ module_name, function_name = _builder_target(command_name)
108
+ builder = _lazy_builder(module_name, function_name)
109
+ _BUILDER_CACHE[command] = builder
110
+ return builder
111
+
112
+
113
+ def _parser(command: int) -> Parser:
114
+ parsers = globals().get("PARSERS")
115
+ if parsers is not None:
116
+ return parsers[command]
117
+ cached = _PARSER_CACHE.get(command)
118
+ if cached is not None:
119
+ return cached
120
+ command_name = _command_name(command)
121
+ module_name, function_name, pass_request_payload = _parser_target(command_name)
122
+ parser = _lazy_parser(module_name, function_name, pass_request_payload=pass_request_payload)
123
+ _PARSER_CACHE[command] = parser
124
+ return parser
125
+
126
+
127
+ def _builders() -> dict[int, Builder]:
128
+ cached = globals().get("BUILDERS")
129
+ if cached is not None:
130
+ return cached
131
+ builders = {}
132
+ for name, (module_name, function_name) in _builder_target_items():
133
+ command = _command_code(name)
134
+ builder = _BUILDER_CACHE.get(command)
135
+ if builder is None:
136
+ builder = _lazy_builder(module_name, function_name)
137
+ _BUILDER_CACHE[command] = builder
138
+ builders[command] = builder
139
+ globals()["BUILDERS"] = builders
140
+ return builders
141
+
142
+
143
+ def _parsers() -> dict[int, Parser]:
144
+ cached = globals().get("PARSERS")
145
+ if cached is not None:
146
+ return cached
147
+ parsers = {}
148
+ for name, (module_name, function_name, pass_request_payload) in _parser_target_items():
149
+ command = _command_code(name)
150
+ parser = _PARSER_CACHE.get(command)
151
+ if parser is None:
152
+ parser = _lazy_parser(module_name, function_name, pass_request_payload=pass_request_payload)
153
+ _PARSER_CACHE[command] = parser
154
+ parsers[command] = parser
155
+ globals()["PARSERS"] = parsers
156
+ return parsers
157
+
158
+
159
+ def _unsupported_command_error() -> type[Exception]:
160
+ return import_module(_EXCEPTIONS_MODULE).UnsupportedCommandError
161
+
162
+
163
+ def __getattr__(name: str) -> Any:
164
+ if name == "BUILDERS":
165
+ return _builders()
166
+ if name == "PARSERS":
167
+ return _parsers()
168
+ if name == "COMMAND_CODES":
169
+ return _command_codes()
170
+ if name == "BUILDER_TARGETS":
171
+ return _builder_targets()
172
+ if name == "PARSER_TARGETS":
173
+ return _parser_targets()
174
+ if name == "UnsupportedCommandError":
175
+ return _unsupported_command_error()
176
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
177
+
178
+
179
+ __all__ = [
180
+ "BUILDERS",
181
+ "Builder",
182
+ "PARSERS",
183
+ "Parser",
184
+ "build_command_frame",
185
+ "parse_command_response",
186
+ ]
@@ -0,0 +1,74 @@
1
+ """Provider-owned 7709 command code facts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ COMMAND_CODE_ITEMS: tuple[tuple[str, int], ...] = (
6
+ ("heartbeat", 0x0004),
7
+ ("handshake", 0x000D),
8
+ ("capital_changes", 0x000F),
9
+ ("finance_info", 0x0010),
10
+ ("security_list", 0x044D),
11
+ ("security_count", 0x044E),
12
+ ("price_limits", 0x0452),
13
+ ("intraday_subchart", 0x051B),
14
+ ("klines", 0x052D),
15
+ ("today_intraday", 0x0537),
16
+ ("legacy_quotes", 0x053E),
17
+ ("refresh_quotes", 0x0547),
18
+ ("category_quotes", 0x054B),
19
+ ("explicit_quotes", 0x054C),
20
+ ("auction_process", 0x056A),
21
+ ("file_content", 0x06B9),
22
+ ("historical_intraday", 0x0FB4),
23
+ ("today_trades", 0x0FC5),
24
+ ("historical_trades", 0x0FC6),
25
+ ("recent_historical_intraday", 0x0FEB),
26
+ )
27
+
28
+ _TYPE_EXPORTS = {
29
+ "TYPE_HEARTBEAT": "heartbeat",
30
+ "TYPE_HANDSHAKE": "handshake",
31
+ }
32
+
33
+
34
+ def command_code(name: str) -> int:
35
+ for command_name, code in COMMAND_CODE_ITEMS:
36
+ if command_name == name:
37
+ return code
38
+ raise KeyError(name)
39
+
40
+
41
+ def command_name(code: int) -> str:
42
+ for command_name, command_code_value in COMMAND_CODE_ITEMS:
43
+ if command_code_value == code:
44
+ return command_name
45
+ raise KeyError(code)
46
+
47
+
48
+ def _command_codes() -> dict[str, int]:
49
+ cached = globals().get("COMMAND_CODES")
50
+ if cached is not None:
51
+ return cached
52
+ command_codes = dict(COMMAND_CODE_ITEMS)
53
+ globals()["COMMAND_CODES"] = command_codes
54
+ return command_codes
55
+
56
+
57
+ def __getattr__(name: str):
58
+ if name == "COMMAND_CODES":
59
+ return _command_codes()
60
+ if name in _TYPE_EXPORTS:
61
+ value = command_code(_TYPE_EXPORTS[name])
62
+ globals()[name] = value
63
+ return value
64
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
65
+
66
+
67
+ __all__ = [
68
+ "COMMAND_CODE_ITEMS",
69
+ "COMMAND_CODES",
70
+ "TYPE_HEARTBEAT",
71
+ "TYPE_HANDSHAKE",
72
+ "command_code",
73
+ "command_name",
74
+ ]
@@ -0,0 +1,15 @@
1
+ """Provider-owned TDX command defaults kept outside command runtimes."""
2
+
3
+ DEFAULT_AUCTION_MODE = 3
4
+ DEFAULT_AUCTION_COUNT = 500
5
+ DEFAULT_TODAY_INTRADAY_RESERVED_TAIL = b"\x00\x00\x00\x93"
6
+ RECENT_HISTORICAL_INTRADAY_DATE_BASE = 0xFED62304
7
+ FILE_PATH_FIELD_SIZE = 300
8
+
9
+ __all__ = [
10
+ "DEFAULT_AUCTION_COUNT",
11
+ "DEFAULT_AUCTION_MODE",
12
+ "DEFAULT_TODAY_INTRADAY_RESERVED_TAIL",
13
+ "FILE_PATH_FIELD_SIZE",
14
+ "RECENT_HISTORICAL_INTRADAY_DATE_BASE",
15
+ ]
@@ -0,0 +1,96 @@
1
+ """Provider-owned command dispatch target facts."""
2
+
3
+ BUILDER_TARGET_ITEMS: tuple[tuple[str, tuple[str, str]], ...] = (
4
+ ("heartbeat", ("session", "build_heartbeat_frame")),
5
+ ("handshake", ("session", "build_handshake_frame")),
6
+ ("capital_changes", ("corporate", "build_capital_changes_frame")),
7
+ ("finance_info", ("finance", "build_finance_info_frame")),
8
+ ("security_list", ("security", "build_security_list_frame")),
9
+ ("security_count", ("security", "build_security_count_frame")),
10
+ ("price_limits", ("price_limits", "build_price_limits_frame")),
11
+ ("intraday_subchart", ("subchart", "build_intraday_subchart_frame")),
12
+ ("klines", ("klines", "build_klines_frame")),
13
+ ("today_intraday", ("intraday", "build_today_intraday_frame")),
14
+ ("legacy_quotes", ("quotes", "build_legacy_quotes_frame")),
15
+ ("refresh_quotes", ("quotes", "build_refresh_quotes_frame")),
16
+ ("category_quotes", ("quotes", "build_category_quotes_frame")),
17
+ ("explicit_quotes", ("quotes", "build_explicit_quotes_frame")),
18
+ ("auction_process", ("auction", "build_auction_process_frame")),
19
+ ("file_content", ("resources", "build_file_content_frame")),
20
+ ("historical_intraday", ("intraday", "build_historical_intraday_frame")),
21
+ ("today_trades", ("trades", "build_today_trades_frame")),
22
+ ("historical_trades", ("trades", "build_historical_trades_frame")),
23
+ ("recent_historical_intraday", ("intraday", "build_recent_historical_intraday_frame")),
24
+ )
25
+
26
+ PARSER_TARGET_ITEMS: tuple[tuple[str, tuple[str, str, bool]], ...] = (
27
+ ("heartbeat", ("session", "parse_heartbeat_payload", False)),
28
+ ("handshake", ("session", "parse_handshake_payload", False)),
29
+ ("capital_changes", ("corporate", "parse_capital_changes_payload", True)),
30
+ ("finance_info", ("finance", "parse_finance_info_payload", True)),
31
+ ("security_list", ("security", "parse_security_list_payload", True)),
32
+ ("security_count", ("security", "parse_security_count_payload", False)),
33
+ ("price_limits", ("price_limits", "parse_price_limits_payload", True)),
34
+ ("intraday_subchart", ("subchart", "parse_intraday_subchart_payload", True)),
35
+ ("klines", ("klines", "parse_klines_payload", True)),
36
+ ("today_intraday", ("intraday", "parse_today_intraday_payload", True)),
37
+ ("legacy_quotes", ("quotes", "parse_legacy_quotes_payload", True)),
38
+ ("refresh_quotes", ("quotes", "parse_refresh_quotes_payload", True)),
39
+ ("category_quotes", ("quotes", "parse_category_quotes_payload", True)),
40
+ ("explicit_quotes", ("quotes", "parse_explicit_quotes_payload", True)),
41
+ ("auction_process", ("auction", "parse_auction_process_payload", True)),
42
+ ("file_content", ("resources", "parse_file_content_payload", True)),
43
+ ("historical_intraday", ("intraday", "parse_historical_intraday_payload", True)),
44
+ ("today_trades", ("trades", "parse_today_trades_payload", True)),
45
+ ("historical_trades", ("trades", "parse_historical_trades_payload", True)),
46
+ ("recent_historical_intraday", ("intraday", "parse_recent_historical_intraday_payload", True)),
47
+ )
48
+
49
+
50
+ def builder_target(name: str) -> tuple[str, str]:
51
+ for command_name, target in BUILDER_TARGET_ITEMS:
52
+ if command_name == name:
53
+ return target
54
+ raise KeyError(name)
55
+
56
+
57
+ def parser_target(name: str) -> tuple[str, str, bool]:
58
+ for command_name, target in PARSER_TARGET_ITEMS:
59
+ if command_name == name:
60
+ return target
61
+ raise KeyError(name)
62
+
63
+
64
+ def _builder_targets() -> dict[str, tuple[str, str]]:
65
+ cached = globals().get("BUILDER_TARGETS")
66
+ if cached is not None:
67
+ return cached
68
+ builder_targets = dict(BUILDER_TARGET_ITEMS)
69
+ globals()["BUILDER_TARGETS"] = builder_targets
70
+ return builder_targets
71
+
72
+
73
+ def _parser_targets() -> dict[str, tuple[str, str, bool]]:
74
+ cached = globals().get("PARSER_TARGETS")
75
+ if cached is not None:
76
+ return cached
77
+ parser_targets = dict(PARSER_TARGET_ITEMS)
78
+ globals()["PARSER_TARGETS"] = parser_targets
79
+ return parser_targets
80
+
81
+
82
+ def __getattr__(name: str):
83
+ if name == "BUILDER_TARGETS":
84
+ return _builder_targets()
85
+ if name == "PARSER_TARGETS":
86
+ return _parser_targets()
87
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
88
+
89
+ __all__ = [
90
+ "BUILDER_TARGET_ITEMS",
91
+ "BUILDER_TARGETS",
92
+ "PARSER_TARGET_ITEMS",
93
+ "PARSER_TARGETS",
94
+ "builder_target",
95
+ "parser_target",
96
+ ]