Bot auto-update: src/web_dashboard.py
This commit is contained in:
parent
42f4707461
commit
341778987a
|
|
@ -1,3 +1,4 @@
|
||||||
|
import httpx
|
||||||
"""
|
"""
|
||||||
Trading Bot Web Dashboard
|
Trading Bot Web Dashboard
|
||||||
Real-time tracking of trades, swaps, and performance
|
Real-time tracking of trades, swaps, and performance
|
||||||
|
|
@ -68,9 +69,19 @@ async def websocket_endpoint(websocket: WebSocket):
|
||||||
|
|
||||||
@app.get("/api/state")
|
@app.get("/api/state")
|
||||||
async def get_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
|
return trading_state
|
||||||
|
|
||||||
|
|
||||||
@app.post("/api/clear")
|
@app.post("/api/clear")
|
||||||
async def clear_state():
|
async def clear_state():
|
||||||
"""RESET: Clear all historical data, start fresh"""
|
"""RESET: Clear all historical data, start fresh"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue