chore: backtest engine fee model, metrics, and strategy fixes

- main.py: add IBKR-style tiered fee schedule (fee_base + fee_per_share),
  PIT universe support, and open-to-close execution improvements
- metrics.py: add raw_summary helper for JSON-safe metric export
- Misc strategy fixes: deprecation warnings, NaN handling

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-21 20:57:56 +08:00
parent 1f50253d13
commit 149a00c458
7 changed files with 154 additions and 74 deletions

View File

@@ -30,9 +30,9 @@ class DualMomentumStrategy(Strategy):
all_positive = (short_mom > 0) & (med_mom > 0) & (long_mom > 0)
# Composite score: average percentile rank across timeframes
short_rank = short_mom.rank(axis=1, pct=True, na_option="bottom")
med_rank = med_mom.rank(axis=1, pct=True, na_option="bottom")
long_rank = long_mom.rank(axis=1, pct=True, na_option="bottom")
short_rank = short_mom.rank(axis=1, pct=True, na_option="keep")
med_rank = med_mom.rank(axis=1, pct=True, na_option="keep")
long_rank = long_mom.rank(axis=1, pct=True, na_option="keep")
composite = (short_rank + med_rank + long_rank) / 3
# Only consider stocks passing absolute filter