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:
@@ -115,9 +115,13 @@ async def funds_summary(_user: Annotated[str, Depends(require_user)]) -> dict[st
|
||||
trading_usdt = bal.get("trading_usdt")
|
||||
funding_usdc = bal.get("funding_usdc")
|
||||
trading_usdc = bal.get("trading_usdc")
|
||||
parts = [funding_usdt, trading_usdt, funding_usdc, trading_usdc]
|
||||
vals = [float(x) for x in parts if x is not None]
|
||||
total = round(sum(vals), 2) if vals else None
|
||||
r = float(rate) if rate and rate > 0 else 1.0
|
||||
total = round(
|
||||
(funding_usdt or 0.0)
|
||||
+ (trading_usdt or 0.0)
|
||||
+ ((funding_usdc or 0.0) + (trading_usdc or 0.0)) * r,
|
||||
2,
|
||||
)
|
||||
except Exception as e:
|
||||
return {
|
||||
"ok": False,
|
||||
@@ -128,11 +132,13 @@ async def funds_summary(_user: Annotated[str, Depends(require_user)]) -> dict[st
|
||||
finally:
|
||||
client.close()
|
||||
else:
|
||||
# 非 OKX LIVE:回退本地账本
|
||||
led = Ledger(db).snapshot()
|
||||
trading_usdt = float(led["equity"])
|
||||
total = trading_usdt
|
||||
|
||||
# 非 OKX LIVE:暂无统一资金接口,不回退模拟账本(避免实盘显示假资金)
|
||||
return {
|
||||
"ok": False,
|
||||
"mode": mode,
|
||||
"exchange": exchange,
|
||||
"detail": f"{exchange} 实盘资金摘要暂未接入,请用 OKX 或交易所 App 查看",
|
||||
}
|
||||
return {
|
||||
"ok": True,
|
||||
"mode": mode,
|
||||
|
||||
Reference in New Issue
Block a user