fix: исправить расчёт Sharpe и мутацию словарей в A/B тестах

- Sharpe: использовать реальную частоту сделок вместо sqrt(52),
  предыдущее значение завышало Sharpe в ~1.44 раза
- run_test/combos: копировать dict перед добавлением pretrained_model
  (предотвращает мутацию исходных combo-конфигов)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-08 12:20:51 +10:00
co-authored by Claude Opus 4.6
parent 1f568c35d4
commit 2b7d6f915e
2 changed files with 15 additions and 11 deletions
+5 -4
View File
@@ -325,10 +325,11 @@ def analyze(asset: str, result: dict, prices: np.ndarray, dates: list[date]):
else:
annual_ret = 0
# Sharpe (annualized from weekly returns)
weekly_rets = [t["pnl_pct"] / 100 for t in trades]
if len(weekly_rets) > 2 and np.std(weekly_rets) > 0:
sharpe = np.mean(weekly_rets) / np.std(weekly_rets) * np.sqrt(52)
# Sharpe (annualized based on actual trading frequency)
trade_rets = [t["pnl_pct"] / 100 for t in trades]
if len(trade_rets) > 2 and np.std(trade_rets) > 0:
trades_per_year = len(trade_rets) / years if years > 0 else 52
sharpe = np.mean(trade_rets) / np.std(trade_rets) * np.sqrt(trades_per_year)
else:
sharpe = 0