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.
This commit is contained in:
parent
ce241998c6
commit
6eceb84d98
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue