diff --git a/hub_fund_history_lib.py b/hub_fund_history_lib.py index 674e168..cd037a9 100644 --- a/hub_fund_history_lib.py +++ b/hub_fund_history_lib.py @@ -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) diff --git a/manual_trading_hub/hub.py b/manual_trading_hub/hub.py index 3f68cbb..6f910a4 100644 --- a/manual_trading_hub/hub.py +++ b/manual_trading_hub/hub.py @@ -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"), diff --git a/manual_trading_hub/hub_dashboard.py b/manual_trading_hub/hub_dashboard.py index b6fe97f..d0e752f 100644 --- a/manual_trading_hub/hub_dashboard.py +++ b/manual_trading_hub/hub_dashboard.py @@ -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 { diff --git a/tests/test_hub_fund_history_lib.py b/tests/test_hub_fund_history_lib.py index f3e28f0..e779162 100644 --- a/tests/test_hub_fund_history_lib.py +++ b/tests/test_hub_fund_history_lib.py @@ -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