Support LIVE exchange funds and perp margin mode.

Hide sim equity when LIVE is selected; OKX funds bar uses exchange balances; add cross/isolated for perp only (options stay cash).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-29 19:57:09 +08:00
parent 50a4540aaf
commit c6e8f6fe1e
12 changed files with 134 additions and 24 deletions
+26 -5
View File
@@ -4,6 +4,7 @@ import { apiFetch } from "../api/client";
export type FundsSummary = {
ok: boolean;
exchange: string;
mode?: string;
trading_day: string;
total_trades: number;
win_rate: number;
@@ -53,22 +54,42 @@ function DualCcy({
export default function FundsBar() {
const [s, setS] = useState<FundsSummary | null>(null);
const [err, setErr] = useState("");
const load = useCallback(() => {
apiFetch<FundsSummary>("/api/funds/summary")
.then(setS)
.catch(() => {
/* 顶栏静默失败,避免刷屏 */
.then((r) => {
setS(r);
setErr(r.ok ? "" : r.detail || "资金摘要不可用");
})
.catch((e) => {
setErr(e instanceof Error ? e.message : String(e));
});
}, []);
useEffect(() => {
load();
const t = window.setInterval(load, 5000);
return () => window.clearInterval(t);
const onRefresh = () => load();
window.addEventListener("funds-refresh", onRefresh);
return () => {
window.clearInterval(t);
window.removeEventListener("funds-refresh", onRefresh);
};
}, [load]);
if (!s?.ok) return null;
if (!s?.ok) {
if (!err) return null;
return (
<div className="funds-bar-shell">
<div className="funds-bar-inner">
<div className="funds-bar funds-bar--err" aria-label="资金摘要异常">
<span className="meta">{err}</span>
</div>
</div>
</div>
);
}
return (
<div className="funds-bar-shell">