Files
MBT/scripts/run_exit_opt.py
T
FXDavidandClaude Sonnet 4.6 3490441649 Audit fixes: public repo readiness + MCP improvements
- Add MIT LICENSE
- Anonymize broker path in config.example.yaml; add slippage_points + risk_per_trade
- Fix encoding ansi→cp1252 in signals.py (cross-platform safe)
- Fix install.py silently ignoring pip errors
- Cap get_ohlcv at 2000 bars; add ping tool; clarify HTML report UX in descriptions
- Escape symbol/timeframe in HTML report to prevent malformed output
- Move run_*.py to scripts/; move example CSVs to examples/
- Update .gitignore to block accidental CSV commits from root
- README: Python 3.9+ requirement, Chart.js internet note, new sections for examples/ and scripts/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 12:08:23 -07:00

43 lines
1.3 KiB
Python

from core.optimize_exits import optimize_exits
import time
t0 = time.time()
r = optimize_exits()
print(f"took {round(time.time()-t0,1)}s")
print("train:", r["train_period"].replace("→", "to"))
print("test :", r["test_period"].replace("→", "to"))
print("cost/trade (price):", r["cost_price_per_trade"])
print()
rrs = sorted(set(g["RR"] for g in r["grid"]))
ms = sorted(set(g["M"] for g in r["grid"]))
print("=== TRAIN: expectancy (R per trade) — rows=SL mult, cols=RR ===")
header = "SL\\RR".ljust(7) + "".join(f"{rr:>8}" for rr in rrs)
print(header)
for M in ms:
row = f"{M:>6} "
for rr in rrs:
g = next(x for x in r["grid"] if x["M"] == M and x["RR"] == rr)
row += f"{g['expectancy']:>8.3f}"
print(row)
print()
print("=== TRAIN: net R — rows=SL mult, cols=RR ===")
print(header)
for M in ms:
row = f"{M:>6} "
for rr in rrs:
g = next(x for x in r["grid"] if x["M"] == M and x["RR"] == rr)
row += f"{g['net_r']:>8.0f}"
print(row)
def show(label, d):
print(f"\n{label}: M={d['M']} RR={d['RR']} | trades={d['trades']} "
f"WR={d['win_rate']}% PF={d['profit_factor']} "
f"exp={d['expectancy']}R net={d['net_r']}R maxDD={d['max_dd_r']}R")
show("TRAIN BEST", r["train_best"])
show(" -> on LOCKED TEST", r["test_result"])
show("BASELINE 2.5/3.5 on TEST", r["baseline_on_test"])