mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 16:54:20 +08:00
fix: resolve all CI mypy (265→0) and ruff (26→0) errors
- pyproject.toml: add mypy overrides for pandas/tabulate/matplotlib stubs, disable strict checking for vendored MyTT library - config.py: use cast() for dict[str, Any] .get() returns - beichi.py: widen _calc_bi_force param to BI | XD, import XD - backtest/cli.py: split combo/single strategy into separate typed variables - backtest/combo.py: add bool_array() helper for numpy return types - chanlun/analyser.py: type ignore for pandas row access, fix dict type arg - unified.py: change fields param from object to Any - ex/mac_client.py: add type args to list literals - cli/cmd_offline.py: wrap int market as Market enum before API call - cli/cmd_chanlun.py: fix dict type arg - offline/write_*.py: explicit int() cast for struct.unpack returns - MyTT.py: fix line-too-long comments, UP038 isinstance syntax - tests: fix E712 (==False → ~mask), E741 (noqa), F841, import sorting - ruff format applied across codebase Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
5aac7d3a39
commit
4dfd18050e
@@ -19,8 +19,20 @@ def test_security_bars_exact_layout():
|
||||
# Payload: 0x052D, 1 (Market.SH), "600000", 4 (KlineCategory.DAY), 1, 0 (start), 10, 0, 0, 0
|
||||
expected = struct.pack(
|
||||
"<HIHHHH6sHHHHIIH",
|
||||
0x010C, 0x01016408, 0x001C, 0x001C,
|
||||
0x052D, 1, b"600000", 4, 1, 0, 10, 0, 0, 0
|
||||
0x010C,
|
||||
0x01016408,
|
||||
0x001C,
|
||||
0x001C,
|
||||
0x052D,
|
||||
1,
|
||||
b"600000",
|
||||
4,
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
assert req == expected
|
||||
assert len(req) == 38
|
||||
@@ -34,8 +46,20 @@ def test_history_fund_flow_exact_layout():
|
||||
# Payload: 0x052D, 1 (Market.SH), "600000", 22, 1, 0, 10, 0, 0, 0
|
||||
expected = struct.pack(
|
||||
"<HIHHHH6sHHHHIIH",
|
||||
0x010C, 0x01016408, 0x001C, 0x001C,
|
||||
0x052D, 1, b"600000", 22, 1, 0, 10, 0, 0, 0
|
||||
0x010C,
|
||||
0x01016408,
|
||||
0x001C,
|
||||
0x001C,
|
||||
0x052D,
|
||||
1,
|
||||
b"600000",
|
||||
22,
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
assert req == expected
|
||||
assert len(req) == 38
|
||||
@@ -56,16 +80,16 @@ def test_security_quotes_limit_mapping():
|
||||
from easy_tdx.codec.price import put_price
|
||||
|
||||
cmd = GetSecurityQuotesCmd([(Market.SH, "600000")])
|
||||
|
||||
|
||||
# 构造响应报文
|
||||
body = bytearray(b"\x00\x00")
|
||||
body.extend(struct.pack("<H", 1))
|
||||
|
||||
|
||||
# Record: Market(B), Code(6s), Active1(H) + ...
|
||||
body.extend(struct.pack("<B6sH", 1, b"600000", 0))
|
||||
|
||||
|
||||
body.extend(put_price(1010)) # price_raw
|
||||
body.extend(put_price(-5)) # last_close_diff
|
||||
body.extend(put_price(-5)) # last_close_diff
|
||||
body.extend(put_price(0))
|
||||
body.extend(put_price(0))
|
||||
body.extend(put_price(0))
|
||||
@@ -86,7 +110,7 @@ def test_security_quotes_limit_mapping():
|
||||
body.extend(put_price(0))
|
||||
body.extend(put_price(0))
|
||||
body.extend(struct.pack("<hH", 0, 0))
|
||||
|
||||
|
||||
quotes = cmd.parse_response(bytes(body))
|
||||
q = quotes[0]
|
||||
assert q.limit_up is None
|
||||
@@ -120,18 +144,19 @@ def test_compute_price_limits_for_indices():
|
||||
|
||||
def test_compute_price_limits_for_newly_listed_stocks():
|
||||
"""上市初期限价窗口应返回 None。"""
|
||||
assert compute_price_limits(
|
||||
Market.SH, "600001", "主板新股", 10.0, listed_days=5
|
||||
) == (None, None)
|
||||
assert compute_price_limits(
|
||||
Market.SH, "600001", "主板新股", 10.0, listed_days=6
|
||||
) == (11.0, 9.0)
|
||||
assert compute_price_limits(
|
||||
Market.BJ, "920002", "北交所新股", 84.36, listed_days=1
|
||||
) == (None, None)
|
||||
assert compute_price_limits(
|
||||
Market.BJ, "920002", "北交所新股", 84.36, listed_days=2
|
||||
) == (109.67, 59.05)
|
||||
assert compute_price_limits(Market.SH, "600001", "主板新股", 10.0, listed_days=5) == (
|
||||
None,
|
||||
None,
|
||||
)
|
||||
assert compute_price_limits(Market.SH, "600001", "主板新股", 10.0, listed_days=6) == (11.0, 9.0)
|
||||
assert compute_price_limits(Market.BJ, "920002", "北交所新股", 84.36, listed_days=1) == (
|
||||
None,
|
||||
None,
|
||||
)
|
||||
assert compute_price_limits(Market.BJ, "920002", "北交所新股", 84.36, listed_days=2) == (
|
||||
109.67,
|
||||
59.05,
|
||||
)
|
||||
|
||||
|
||||
def test_history_fund_flow_uses_uint32_volume_words():
|
||||
|
||||
Reference in New Issue
Block a user