Prevent env autofill from overwriting OKX API keys when saving hedge settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-14 11:22:28 +08:00
parent 1fa98425e7
commit 9e17814e37
6 changed files with 52 additions and 21 deletions
+13 -10
View File
@@ -105,18 +105,21 @@ def total_funds_usdt(
options_funding_usdt: float | None = None,
options_trading_usdt: float | None = None,
) -> float | None:
if funding_usdt is None:
parts = [
funding_usdt,
trading_usdt,
options_funding_usdc,
options_funding_usdt,
options_trading_usdc,
options_trading_usdt,
]
if all(v is None for v in parts):
return None
try:
total = float(funding_usdt) + float(trading_usdt or 0)
if options_funding_usdc is not None:
total += float(options_funding_usdc)
if options_funding_usdt is not None:
total += float(options_funding_usdt)
if options_trading_usdc is not None:
total += float(options_trading_usdc)
if options_trading_usdt is not None:
total += float(options_trading_usdt)
total = 0.0
for v in parts:
if v is not None:
total += float(v)
return round(total, 2)
except (TypeError, ValueError):
return None