Bot auto-update: src/web_dashboard.py

This commit is contained in:
Marc Blatter 2026-07-04 13:39:51 +02:00
parent 42f4707461
commit 341778987a
1 changed files with 12 additions and 1 deletions

View File

@ -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"""