Compare commits

...

2 Commits

Author SHA1 Message Date
robinsxe ccf375eafd
Update tradingagents/graph/portfolio_analysis.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-26 18:20:23 +01:00
Robin Lindbladh 138c077cc6 fix: stop restoring log_states_dict after portfolio analysis
The log_states_dict is meant to accumulate per-ticker state logs.
Restoring it after propagate_portfolio() was discarding all the
detailed logs generated during the portfolio run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:15:27 +01:00
2 changed files with 2 additions and 4 deletions

View File

@ -181,12 +181,12 @@ class PortfolioAnalyzer:
directory.mkdir(parents=True, exist_ok=True)
log_data = {
"trade_date": str(trade_date),
"trade_date": trade_date,
"tickers": tickers,
"individual_results": individual_results,
"portfolio_summary": portfolio_summary,
}
log_file = directory / f"portfolio_analysis_{re.sub(r'[^\w.-]', '_', str(trade_date))}.json"
log_file = directory / f"portfolio_analysis_{re.sub(r'[^\w.-]', '_', trade_date)}.json"
with log_file.open("w", encoding="utf-8") as f:
json.dump(log_data, f, indent=4)

View File

@ -283,7 +283,6 @@ class TradingAgentsGraph:
"""
original_ticker = self.ticker
original_curr_state = self.curr_state
original_log_states = self.log_states_dict.copy()
try:
return self.portfolio_analyzer.analyze(
tickers, trade_date, self.propagate, debug=self.debug
@ -291,7 +290,6 @@ class TradingAgentsGraph:
finally:
self.ticker = original_ticker
self.curr_state = original_curr_state
self.log_states_dict = original_log_states
def reflect_and_remember(self, returns_losses):
"""Reflect on decisions and update memory based on returns."""