Route manual USDT/USDC convert through trading account (not funding).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user