mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 23:54:21 +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
@@ -79,16 +79,15 @@ def backtest(
|
||||
|
||||
# 1. 加载策略(单策略 or 多因子组合)
|
||||
is_combo = combo_strategies is not None
|
||||
strategy = None
|
||||
|
||||
if is_combo:
|
||||
strategy = _load_combo_strategies(combo_strategies)
|
||||
assert combo_strategies is not None # narrowed by is_combo
|
||||
combo_classes = _load_combo_strategies(combo_strategies)
|
||||
else:
|
||||
strategy = _load_strategy(strategy_str, strategy_file)
|
||||
|
||||
if strategy is None:
|
||||
click.echo("错误: 必须指定 --strategy-file / --combo-strategies / --strategy", err=True)
|
||||
raise SystemExit(1)
|
||||
strategy_cls = _load_strategy(strategy_str, strategy_file)
|
||||
if strategy_cls is None:
|
||||
click.echo("错误: 必须指定 --strategy-file / --combo-strategies / --strategy", err=True)
|
||||
raise SystemExit(1)
|
||||
|
||||
# 2. 获取数据
|
||||
mkt = parse_market(market)
|
||||
@@ -111,21 +110,21 @@ def backtest(
|
||||
if is_combo:
|
||||
from ..backtest.combo import CombinationRunner
|
||||
|
||||
assert strategy is not None # for type checker
|
||||
runner = CombinationRunner(
|
||||
strategy_classes=strategy,
|
||||
strategy_classes=combo_classes,
|
||||
df=df,
|
||||
cash=cash,
|
||||
commission=commission,
|
||||
execution=execution,
|
||||
)
|
||||
result = runner.run_combination(
|
||||
indices=list(range(len(strategy))),
|
||||
indices=list(range(len(combo_classes))),
|
||||
mode=combo_mode.upper(),
|
||||
)
|
||||
else:
|
||||
assert strategy_cls is not None # guarded above by SystemExit
|
||||
engine = BacktestEngine(
|
||||
strategy=strategy,
|
||||
strategy=strategy_cls,
|
||||
cash=cash,
|
||||
commission=commission,
|
||||
execution=execution,
|
||||
|
||||
Reference in New Issue
Block a user