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 <noreply@anthropic.com>
This commit is contained in:
Harwinder
2026-05-06 18:49:29 -04:00
parent 8df42cd384
commit 6524238ce9
+1 -1
View File
@@ -694,7 +694,7 @@ def main() -> int:
df.to_csv(out_dir / "trades.csv", index=False) df.to_csv(out_dir / "trades.csv", index=False)
summary = summarize(df) summary = summarize(df)
(out_dir / "summary.txt").write_text(summary) (out_dir / "summary.txt").write_text(summary, encoding="utf-8")
print("\n" + summary) print("\n" + summary)
print(f"\n📁 trades.csv → {out_dir/'trades.csv'}") print(f"\n📁 trades.csv → {out_dir/'trades.csv'}")