diff --git a/src/web_dashboard.py b/src/web_dashboard.py index fa90998..ddbb1dc 100644 --- a/src/web_dashboard.py +++ b/src/web_dashboard.py @@ -1,3 +1,4 @@ +import httpx """ Trading Bot Web Dashboard Real-time tracking of trades, swaps, and performance @@ -68,9 +69,19 @@ async def websocket_endpoint(websocket: WebSocket): @app.get("/api/state") async def get_state(): - """Get current trading state""" + """Get current trading state from State Manager""" + try: + async with httpx.AsyncClient(timeout=2.0) as client: + resp = await client.get('http://localhost:8001/state') + if resp.status_code == 200: + return resp.json() + except Exception as e: + logger.warning(fState Manager unavailable, using cached state: {e}) + + # Fallback to cached state return trading_state + @app.post("/api/clear") async def clear_state(): """RESET: Clear all historical data, start fresh"""