pytdxdata 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 (52) hide show
  1. pytdxdata/__init__.py +2 -0
  2. pytdxdata/_binary.py +20 -0
  3. pytdxdata/api.py +925 -0
  4. pytdxdata/cache/__init__.py +0 -0
  5. pytdxdata/cache/disk.py +135 -0
  6. pytdxdata/cache/key.py +46 -0
  7. pytdxdata/cache/manager.py +123 -0
  8. pytdxdata/cache/memory.py +59 -0
  9. pytdxdata/cache/ttl.py +50 -0
  10. pytdxdata/cli.py +433 -0
  11. pytdxdata/codec/__init__.py +0 -0
  12. pytdxdata/codec/payload.py +16 -0
  13. pytdxdata/config.py +109 -0
  14. pytdxdata/indicator.py +136 -0
  15. pytdxdata/models/__init__.py +316 -0
  16. pytdxdata/pool/__init__.py +0 -0
  17. pytdxdata/pool/connection.py +105 -0
  18. pytdxdata/pool/ex_connection.py +103 -0
  19. pytdxdata/pool/ex_pool.py +89 -0
  20. pytdxdata/pool/health.py +61 -0
  21. pytdxdata/pool/pool.py +328 -0
  22. pytdxdata/protocol/__init__.py +0 -0
  23. pytdxdata/protocol/commands/__init__.py +32 -0
  24. pytdxdata/protocol/commands/base.py +38 -0
  25. pytdxdata/protocol/commands/ex_ext.py +171 -0
  26. pytdxdata/protocol/commands/ex_proto.py +122 -0
  27. pytdxdata/protocol/commands/finance.py +50 -0
  28. pytdxdata/protocol/commands/kline.py +115 -0
  29. pytdxdata/protocol/commands/mac.py +80 -0
  30. pytdxdata/protocol/commands/mac_ext.py +502 -0
  31. pytdxdata/protocol/commands/minute.py +54 -0
  32. pytdxdata/protocol/commands/quotes.py +118 -0
  33. pytdxdata/protocol/commands/security_list.py +60 -0
  34. pytdxdata/protocol/commands/setup.py +9 -0
  35. pytdxdata/protocol/commands/std_ext.py +195 -0
  36. pytdxdata/protocol/commands/transaction.py +126 -0
  37. pytdxdata/protocol/commands/xdxr.py +65 -0
  38. pytdxdata/protocol/datetime_.py +28 -0
  39. pytdxdata/protocol/frame.py +43 -0
  40. pytdxdata/protocol/mac_frame.py +22 -0
  41. pytdxdata/protocol/price.py +67 -0
  42. pytdxdata/protocol/volume.py +46 -0
  43. pytdxdata/router.py +17 -0
  44. pytdxdata/scheduler/__init__.py +0 -0
  45. pytdxdata/scheduler/paginator.py +128 -0
  46. pytdxdata/server_probe.py +148 -0
  47. pytdxdata/servers.json +423 -0
  48. pytdxdata-0.1.0.dist-info/METADATA +295 -0
  49. pytdxdata-0.1.0.dist-info/RECORD +52 -0
  50. pytdxdata-0.1.0.dist-info/WHEEL +4 -0
  51. pytdxdata-0.1.0.dist-info/entry_points.txt +3 -0
  52. pytdxdata-0.1.0.dist-info/licenses/LICENSE +21 -0
pytdxdata/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ def main() -> None:
2
+ print("Hello from pytdxdata!")
pytdxdata/_binary.py ADDED
@@ -0,0 +1,20 @@
1
+ """二进制解包工具"""
2
+ from __future__ import annotations
3
+
4
+ import struct
5
+ from typing import Any
6
+
7
+
8
+ def unpack_from(fmt: str, data: bytes | bytearray | memoryview, pos: int, what: str = "") -> tuple[Any, ...]:
9
+ """从 pos 处按 fmt 解包,越界抛清晰错误。"""
10
+ try:
11
+ return struct.unpack_from(fmt, data, pos)
12
+ except struct.error as e:
13
+ raise ValueError(f"{what} 解包失败 @{pos} fmt={fmt}: {e}") from e
14
+
15
+
16
+ def slice_bytes(data: bytes | bytearray | memoryview, pos: int, length: int, what: str = "") -> bytes:
17
+ end = pos + length
18
+ if end > len(data):
19
+ raise ValueError(f"{what} 截断 @{pos} need {length} have {len(data) - pos}")
20
+ return bytes(data[pos:end])