From 6524238ce934353ba81570d9ba225f0ef5804020 Mon Sep 17 00:00:00 2001 From: Harwinder Date: Wed, 6 May 2026 18:49:29 -0400 Subject: [PATCH] Fix backtest summary.txt UnicodeEncodeError on Windows write_text() defaults to the platform encoding (cp1252 on Windows), which can't encode the arrow character used in the summary header. Force UTF-8 explicitly so backtests complete on Windows hosts. Co-Authored-By: Claude Opus 4.7 --- backtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backtest.py b/backtest.py index 0299028..4874a6c 100644 --- a/backtest.py +++ b/backtest.py @@ -694,7 +694,7 @@ def main() -> int: df.to_csv(out_dir / "trades.csv", index=False) summary = summarize(df) - (out_dir / "summary.txt").write_text(summary) + (out_dir / "summary.txt").write_text(summary, encoding="utf-8") print("\n" + summary) print(f"\nšŸ“ trades.csv → {out_dir/'trades.csv'}")