fix: 3 bugs — synthesis crash, stale running cycle, invalid tickers
- knowledge.py: trade_line crash when pnl_pct is None in dict
(t.get('pnl_pct',0) returns None if key exists with None value — use 'or 0')
- database.py: cleanup_stale_running_cycles() marks any 'running' cycle
as 'error' on startup (uvicorn reload mid-cycle left status stuck)
- main.py: call cleanup_stale_running_cycles() at startup with warning log
- database.py: _normalize_ticker() converts GPT-4o exchange:symbol format
(NSE:RELIANCE → RELIANCE.NS, BSE:X → X.BO, etc.) so yfinance stops
spamming 404 errors for every MTM request
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -64,8 +64,9 @@ Note timing: {timing[:150]}
|
||||
|
||||
def trade_line(t):
|
||||
mat = t.get("maturity", {})
|
||||
pnl = t.get("pnl_pct") or 0
|
||||
return (f"{t.get('underlying','?')} {t.get('strategy','?')} "
|
||||
f"P&L={t.get('pnl_pct',0):+.1f}% score={t.get('latest_score','?')} "
|
||||
f"P&L={pnl:+.1f}% score={t.get('latest_score','?')} "
|
||||
f"regime={t.get('macro_regime','?')} [{mat.get('readable','')}]")
|
||||
|
||||
trades_block = f"""
|
||||
|
||||
Reference in New Issue
Block a user