fix: KeyError 'stats' in cycle log line — use .get() defensively

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-17 08:43:10 +02:00
parent a3fb486477
commit 7b50a9b339

View File

@@ -141,7 +141,7 @@ def run_cycle_once(trigger: str = "auto") -> Dict[str, Any]:
logger.info(
f"[Cycle {run_id[:16]}] Portfolio lessons loaded "
f"(report from {portfolio_lessons.get('created_at','?')[:10]}, "
f"{age_hours:.0f}h ago, avg_pnl={portfolio_lessons['stats'].get('avg_pnl_pct')}%)"
f"{age_hours:.0f}h ago, avg_pnl={portfolio_lessons.get('stats', {}).get('avg_pnl_pct')}%)"
)
else:
logger.info(f"[Cycle {run_id[:16]}] No portfolio report yet — cycle runs without performance feedback")