Files
easy_tdx_max/src/easy_tdx/codec/industry.py
T
GitHubandClaude Opus 4.8 4dfd18050e 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>
2026-06-10 15:03:41 +08:00

25 lines
825 B
Python

"""通达信行业配置文件 (tdxhy.cfg) 解析器。"""
def parse_tdxhy_cfg(content: bytes) -> dict[str, tuple[str, str]]:
"""解析 tdxhy.cfg 字节内容。
返回字典: { "code": (tdx_industry, sw_industry), ... }
"""
results = {}
try:
text = content.decode("gbk", errors="replace")
for line in text.splitlines():
parts = line.strip().split("|")
if len(parts) >= 3:
# 格式: 市场|代码|行业1|||行业2
# 我们只关心 A 股 6 位代码
code = parts[1]
if len(code) == 6:
tdx_ind = parts[2]
sw_ind = parts[5] if len(parts) >= 6 else ""
results[code] = (tdx_ind, sw_ind)
except Exception:
pass
return results