feat: add hub fund overview tab with 180-day equity curves
Add /funds page for total and per-account balance (funding+trading), drawdown, and daily snapshots from monitor board aggregation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -248,6 +248,12 @@ async def _run_chart_poll() -> dict:
|
||||
async def _run_board_aggregate() -> dict:
|
||||
try:
|
||||
body = await asyncio.wait_for(_build_monitor_board_payload(), timeout=HUB_BOARD_TIMEOUT)
|
||||
try:
|
||||
from hub_fund_history_lib import record_fund_snapshot_from_board
|
||||
|
||||
await asyncio.to_thread(record_fund_snapshot_from_board, body.get("rows") or [])
|
||||
except Exception:
|
||||
pass
|
||||
return {"ok": True, **body}
|
||||
except asyncio.TimeoutError:
|
||||
return {
|
||||
@@ -641,6 +647,7 @@ def root_redirect():
|
||||
@app.get("/monitor")
|
||||
@app.get("/market")
|
||||
@app.get("/archive")
|
||||
@app.get("/funds")
|
||||
@app.get("/ai")
|
||||
@app.get("/settings")
|
||||
def shell_pages():
|
||||
@@ -2067,6 +2074,22 @@ async def api_archive_sync():
|
||||
return body
|
||||
|
||||
|
||||
@app.get("/api/hub/fund-overview")
|
||||
def api_hub_fund_overview():
|
||||
from hub_fund_history_lib import build_fund_overview
|
||||
from hub_ai.config import trading_day_reset_hour
|
||||
|
||||
settings = load_settings()
|
||||
snap = board_store.snapshot_dict()
|
||||
payload = build_fund_overview(
|
||||
settings.get("exchanges") or [],
|
||||
board_rows=snap.get("rows") or [],
|
||||
reset_hour=trading_day_reset_hour(),
|
||||
updated_at=snap.get("updated_at"),
|
||||
)
|
||||
return payload
|
||||
|
||||
|
||||
@app.get("/api/ping")
|
||||
def api_ping():
|
||||
return {
|
||||
@@ -2074,7 +2097,7 @@ def api_ping():
|
||||
"service": "manual-trading-hub",
|
||||
"build": HUB_BUILD,
|
||||
"trade_ui": False,
|
||||
"features": ["monitor", "settings", "auth", "board_sse", "archive"],
|
||||
"features": ["monitor", "settings", "auth", "board_sse", "archive", "funds"],
|
||||
"board_poll_interval_sec": HUB_BOARD_POLL_INTERVAL,
|
||||
"board_version": board_store.version,
|
||||
"board_aggregating": board_store.aggregating,
|
||||
|
||||
Reference in New Issue
Block a user