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.
- pytdxdata/__init__.py +2 -0
- pytdxdata/_binary.py +20 -0
- pytdxdata/api.py +925 -0
- pytdxdata/cache/__init__.py +0 -0
- pytdxdata/cache/disk.py +135 -0
- pytdxdata/cache/key.py +46 -0
- pytdxdata/cache/manager.py +123 -0
- pytdxdata/cache/memory.py +59 -0
- pytdxdata/cache/ttl.py +50 -0
- pytdxdata/cli.py +433 -0
- pytdxdata/codec/__init__.py +0 -0
- pytdxdata/codec/payload.py +16 -0
- pytdxdata/config.py +109 -0
- pytdxdata/indicator.py +136 -0
- pytdxdata/models/__init__.py +316 -0
- pytdxdata/pool/__init__.py +0 -0
- pytdxdata/pool/connection.py +105 -0
- pytdxdata/pool/ex_connection.py +103 -0
- pytdxdata/pool/ex_pool.py +89 -0
- pytdxdata/pool/health.py +61 -0
- pytdxdata/pool/pool.py +328 -0
- pytdxdata/protocol/__init__.py +0 -0
- pytdxdata/protocol/commands/__init__.py +32 -0
- pytdxdata/protocol/commands/base.py +38 -0
- pytdxdata/protocol/commands/ex_ext.py +171 -0
- pytdxdata/protocol/commands/ex_proto.py +122 -0
- pytdxdata/protocol/commands/finance.py +50 -0
- pytdxdata/protocol/commands/kline.py +115 -0
- pytdxdata/protocol/commands/mac.py +80 -0
- pytdxdata/protocol/commands/mac_ext.py +502 -0
- pytdxdata/protocol/commands/minute.py +54 -0
- pytdxdata/protocol/commands/quotes.py +118 -0
- pytdxdata/protocol/commands/security_list.py +60 -0
- pytdxdata/protocol/commands/setup.py +9 -0
- pytdxdata/protocol/commands/std_ext.py +195 -0
- pytdxdata/protocol/commands/transaction.py +126 -0
- pytdxdata/protocol/commands/xdxr.py +65 -0
- pytdxdata/protocol/datetime_.py +28 -0
- pytdxdata/protocol/frame.py +43 -0
- pytdxdata/protocol/mac_frame.py +22 -0
- pytdxdata/protocol/price.py +67 -0
- pytdxdata/protocol/volume.py +46 -0
- pytdxdata/router.py +17 -0
- pytdxdata/scheduler/__init__.py +0 -0
- pytdxdata/scheduler/paginator.py +128 -0
- pytdxdata/server_probe.py +148 -0
- pytdxdata/servers.json +423 -0
- pytdxdata-0.1.0.dist-info/METADATA +295 -0
- pytdxdata-0.1.0.dist-info/RECORD +52 -0
- pytdxdata-0.1.0.dist-info/WHEEL +4 -0
- pytdxdata-0.1.0.dist-info/entry_points.txt +3 -0
- pytdxdata-0.1.0.dist-info/licenses/LICENSE +21 -0
pytdxdata/__init__.py
ADDED
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])
|