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
+34 -4
View File
@@ -71,6 +71,9 @@ export default function SettingsPage() {
const [orderInterval, setOrderInterval] = useState(1);
const [skipWeekends, setSkipWeekends] = useState(true);
const [leverage, setLeverage] = useState(3);
const [perpMarginMode, setPerpMarginMode] = useState<"cross" | "isolated">(
"cross",
);
const [minHours, setMinHours] = useState(12);
const [minOptLev, setMinOptLev] = useState(100);
const [atmOffOn, setAtmOffOn] = useState(false);
@@ -157,6 +160,9 @@ export default function SettingsPage() {
setOrderInterval(s.live_order_interval_sec ?? 1);
setSkipWeekends(s.skip_weekends !== false);
setLeverage(s.leverage ?? 3);
setPerpMarginMode(
s.perp_margin_mode === "isolated" ? "isolated" : "cross",
);
setMinHours(s.min_option_hours ?? 12);
setMinOptLev(s.min_option_leverage ?? 100);
setAtmOffOn(s.atm_open_offset_enabled === true);
@@ -292,7 +298,7 @@ export default function SettingsPage() {
e.preventDefault();
setStratOk("");
setErr("");
const isLive = (runtime?.mode ?? mode) === "LIVE";
const isLive = mode === "LIVE";
try {
const body: Record<string, unknown> = {
fee_rate: fee,
@@ -303,6 +309,7 @@ export default function SettingsPage() {
live_order_interval_sec: orderInterval,
skip_weekends: skipWeekends,
leverage,
perp_margin_mode: perpMarginMode,
min_option_hours: minHours,
min_option_leverage: minOptLev,
atm_open_offset_enabled: atmOffOn,
@@ -375,6 +382,7 @@ export default function SettingsPage() {
: `已切 LIVE,但未就绪:${r.live_ready_reason}`
: "已切换 SIM,配置已写入 .env",
);
window.dispatchEvent(new Event("funds-refresh"));
} catch (ex) {
setErr(ex instanceof Error ? ex.message : String(ex));
} finally {
@@ -531,7 +539,7 @@ export default function SettingsPage() {
</option>
</select>
</div>
{(runtime?.mode ?? mode) !== "LIVE" ? (
{mode !== "LIVE" ? (
<div className="field">
<label htmlFor="equity">USDT</label>
<input
@@ -559,6 +567,22 @@ export default function SettingsPage() {
onChange={(e) => setLeverage(Number(e.target.value))}
/>
</div>
<div className="field">
<label htmlFor="perpMm"></label>
<select
id="perpMm"
className="mono"
value={perpMarginMode}
onChange={(e) =>
setPerpMarginMode(
e.target.value === "isolated" ? "isolated" : "cross",
)
}
>
<option value="cross"></option>
<option value="isolated"></option>
</select>
</div>
<div className="field">
<label htmlFor="perp"> ETH </label>
<input
@@ -822,19 +846,23 @@ export default function SettingsPage() {
>
<ul className="settings-rules-list">
<li>
{(runtime?.mode ?? mode) === "LIVE"
{mode === "LIVE"
? "当前 LIVE:仓位/选约/出场影响真下单;模拟资金已隐藏。"
: "当前 SIM:本地撮合;可改模拟资金与交易所行情源。"}
</li>
{stratSub === "position" ? (
<>
<li></li>
{(runtime?.mode ?? mode) !== "LIVE" ? (
{mode !== "LIVE" ? (
<li>
SIM
10000
</li>
) : null}
<li>
/OKX
/cash
</li>
</>
) : null}
{stratSub === "select" ? (
@@ -1168,6 +1196,7 @@ export default function SettingsPage() {
}),
});
setFundsOk("兑换成功,顶部资金条将刷新");
window.dispatchEvent(new Event("funds-refresh"));
} catch (e) {
setFundsErr(e instanceof Error ? e.message : String(e));
} finally {
@@ -1257,6 +1286,7 @@ export default function SettingsPage() {
}),
});
setFundsOk("划转成功,顶部资金条将刷新");
window.dispatchEvent(new Event("funds-refresh"));
} catch (e) {
setFundsErr(e instanceof Error ? e.message : String(e));
} finally {