From a9939bbbdd57b3b0c97b01ecd46fd5f787e5a160 Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 30 Jul 2026 00:23:16 +0800 Subject: [PATCH] Route manual USDT/USDC convert through trading account (not funding). Co-authored-by: Cursor --- backend/app/api/funds.py | 12 +++++++++++- docs/更新说明.md | 9 +++++++++ frontend/src/pages/Settings.tsx | 6 +++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/backend/app/api/funds.py b/backend/app/api/funds.py index b17d322..de3d2e9 100644 --- a/backend/app/api/funds.py +++ b/backend/app/api/funds.py @@ -167,11 +167,15 @@ async def funds_summary(_user: Annotated[str, Depends(require_user)]) -> dict[st async def funds_convert( body: ConvertBody, _user: Annotated[str, Depends(require_user)] ) -> dict[str, Any]: + """USDT↔USDC 市价兑换:一律在交易账户(对齐 OKX 现货 cash;SIM 同口径)。""" s = get_settings() rate = usdc_usdt_mid_rate() if s.is_sim: r = SimFundsWallets(get_db()).convert( - direction=body.direction, amount=float(body.amount), rate=rate + direction=body.direction, + amount=float(body.amount), + rate=rate, + account="trading", ) if not r.get("ok"): raise HTTPException(status_code=400, detail=r.get("detail") or "兑换失败") @@ -186,6 +190,12 @@ async def funds_convert( ) finally: client.close() + try: + from ..strategy.open_capacity import invalidate_live_balance_cache + + invalidate_live_balance_cache() + except Exception: + pass if not r.get("ok"): raise HTTPException(status_code=400, detail=r.get("detail") or "兑换失败") return r diff --git a/docs/更新说明.md b/docs/更新说明.md index 4272994..1c92215 100644 --- a/docs/更新说明.md +++ b/docs/更新说明.md @@ -5,6 +5,15 @@ --- +## 2026-07-30 — 手动兑换改走交易账户 + +### 变更 + +1. `/api/funds/convert`(SIM)改为 `account=trading`;LIVE 本就现货交易账户,兑换后清余额缓存。 +2. 设置页文案改为「交易账户」兑换。 + +--- + ## 2026-07-30 — 持仓锁定出场目标 / 暂停以损定仓重算 ### 变更 diff --git a/frontend/src/pages/Settings.tsx b/frontend/src/pages/Settings.tsx index 2c262ad..6efaa5c 100644 --- a/frontend/src/pages/Settings.tsx +++ b/frontend/src/pages/Settings.tsx @@ -1474,8 +1474,8 @@ export default function SettingsPage() { onToggle={() => setFundsRulesOpen((v) => !v)} >

- 币种兑换:对齐 OKX 现货市价 USDC-USDT,手动兑换在资金账户 - 内完成。参考价{" "} + 币种兑换:对齐 OKX 现货市价 USDC-USDT,在交易账户 + 内完成(不走资金账户)。参考价{" "} {usdcRate != null ? `1 USDC ≈ ${usdcRate.toFixed(4)} USDT` : "—"}。

@@ -1489,7 +1489,7 @@ export default function SettingsPage() {

-

币种兑换(USDT ↔ USDC)

+

币种兑换(交易账户 · USDT ↔ USDC)