Hide disabled exchanges from dashboard and fund overview.

Only aggregate and display exchanges with enabled monitoring in system settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-23 18:41:52 +08:00
parent faa41eece1
commit d3d366d0ee
4 changed files with 21 additions and 14 deletions
+7 -5
View File
@@ -289,12 +289,14 @@ def build_fund_overview(
live_known = 0
for ex in exchanges or []:
if not _exchange_monitored(ex):
continue
key = str(ex.get("key") or "").strip()
monitored = _exchange_monitored(ex)
row = _live_row_for_exchange(ex, rows_by_key) if monitored else None
monitored = True
row = _live_row_for_exchange(ex, rows_by_key)
fu = tu = total = None
data_ok = False
if monitored and row and row.get("account_ok"):
if row and row.get("account_ok"):
fu = _safe_float(row.get("funding_usdt"))
tu = _safe_float(row.get("trading_usdt"))
total = account_total_usdt(fu, tu)
@@ -303,7 +305,7 @@ def build_fund_overview(
live_total += total
live_known += 1
series = _account_series(history, key) if monitored and key else []
series = _account_series(history, key) if key else []
dd = compute_drawdown([p["total_usdt"] for p in series]) if series else {
"peak_usdt": None,
"max_drawdown_u": None,
@@ -331,7 +333,7 @@ def build_fund_overview(
"day_delta_usdt": day_delta,
}
)
if monitored and key:
if key:
monitored_keys.append(key)
total_series = _series_from_history(history, monitored_keys)
+3 -3
View File
@@ -728,7 +728,7 @@ async def _run_dashboard_aggregate() -> dict:
try:
return await asyncio.to_thread(
build_dashboard_payload,
_all_exchanges_for_ai(),
enabled_exchanges(),
trading_day=default_trading_day(),
)
except Exception as exc:
@@ -746,7 +746,7 @@ def api_dashboard_daily(trading_day: str = ""):
return dashboard_store.snapshot_dict()
try:
payload = build_dashboard_payload(
_all_exchanges_for_ai(),
enabled_exchanges(),
trading_day=day,
)
except Exception as exc:
@@ -2598,7 +2598,7 @@ def api_hub_fund_overview():
settings = load_settings()
snap = board_store.snapshot_dict()
payload = build_fund_overview(
settings.get("exchanges") or [],
enabled_exchanges(settings),
board_rows=snap.get("rows") or [],
reset_hour=trading_day_reset_hour(),
updated_at=snap.get("updated_at"),
+9 -2
View File
@@ -79,8 +79,15 @@ def build_dashboard_payload(
ctx = build_daily_context(exchanges, trading_day=trading_day)
day = ctx["trading_day"]
accounts_raw = ctx.get("accounts") or []
accounts = [_enrich_account_row(ac) for ac in accounts_raw]
closed_trades = collect_closed_trades_snapshot(accounts_raw, today=day)
accounts = [
_enrich_account_row(ac)
for ac in accounts_raw
if ac.get("status") != "未监控"
]
closed_trades = collect_closed_trades_snapshot(
[ac for ac in accounts_raw if ac.get("status") != "未监控"],
today=day,
)
loss_alert_count = sum(1 for ac in accounts if ac.get("loss_alert"))
now = datetime.now(timezone.utc).astimezone().strftime("%Y-%m-%d %H:%M:%S")
return {
+2 -4
View File
@@ -73,10 +73,8 @@ def test_build_fund_overview_skips_unmonitored(tmp_path, monkeypatch):
)
assert out["totals"]["total_usdt"] == 40.0
assert out["totals"]["monitored_count"] == 1
assert len(out["accounts"]) == 2
off = next(a for a in out["accounts"] if a["key"] == "gate_bot")
assert off["monitored"] is False
assert off["total_usdt"] is None
assert len(out["accounts"]) == 1
assert all(a["monitored"] for a in out["accounts"])
assert out["totals"]["drawdown"]["max_drawdown_u"] == 0.0