From 6eceb84d986d30123db7ddc8c4b26f9c7fd21786 Mon Sep 17 00:00:00 2001 From: tiffanychum <71036662+tiffanychum@users.noreply.github.com> Date: Thu, 2 Apr 2026 01:23:25 +0800 Subject: [PATCH] fix: write only current trade_date state to log file, not full history Each log file is named for a specific trade_date, so it should only contain that date's state. Writing self.log_states_dict caused O(N^2) storage and I/O as every daily file redundantly included all previously processed dates. Suggested by GitHub Copilot review on PR #499. --- tradingagents/graph/trading_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tradingagents/graph/trading_graph.py b/tradingagents/graph/trading_graph.py index acd461d3..af3ced2f 100644 --- a/tradingagents/graph/trading_graph.py +++ b/tradingagents/graph/trading_graph.py @@ -264,7 +264,7 @@ class TradingAgentsGraph: log_path = directory / f"full_states_log_{trade_date}.json" with open(log_path, "w", encoding="utf-8") as f: - json.dump(self.log_states_dict, f, indent=4) + json.dump(self.log_states_dict[str(trade_date)], f, indent=4) def reflect_and_remember(self, returns_losses): """Reflect on decisions and update memory based on returns."""