BluefxPraise/The_Oracle
0
1"""A/B compare two strategy configs side-by-side."""2 3import logging4from typing import Any, Dict, List5 6from backtest.backtest_engine import run as run_backtest7 8log = logging.getLogger("oracle.compare")9 10 11def compare(pair: str, candles: List[Dict[str, Any]], days: int) -> Dict[str, Any]:12 config_a = {"name": "A: weights(2,1,1.5) thr=70",13 "weights": {"trend": 2.0, "mr": 1.0, "ml": 1.5}, "threshold": 70.0}14 config_b = {"name": "B: weights(1.5,1.5,2) thr=65",15 "weights": {"trend": 1.5, "mr": 1.5, "ml": 2.0}, "threshold": 65.0}16 res_a = run_backtest(pair, candles, days, weights=config_a["weights"],17 threshold=config_a["threshold"])18 res_b = run_backtest(pair, candles, days, weights=config_b["weights"],19 threshold=config_b["threshold"])20 winner = "A" if res_a["pnl"] >= res_b["pnl"] else "B"21 return {22 "configs": [config_a, config_b],23 "results": {"A": res_a, "B": res_b},24 "winner": winner,25 }26 