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
+14 -8
View File
@@ -2735,9 +2735,12 @@ def resolve_order_entry_price(order_resp, exchange_symbol, fallback_price):
def get_contract_size(exchange_symbol):
ensure_markets_loaded()
market = exchange.market(exchange_symbol)
return float(market.get("contractSize") or 1)
try:
ensure_markets_loaded()
market = exchange.market(exchange_symbol)
return float(market.get("contractSize") or 1)
except Exception:
return 1.0
def parse_positive_float(value):
@@ -6945,11 +6948,14 @@ def api_account_snapshot():
except Exception:
return exchange.fetch_positions() or []
unrealized_pnl = resolve_instance_unrealized_pnl(
_okx_positions,
active_pnl_rows,
get_live_position_exchange_metrics,
)
try:
unrealized_pnl = resolve_instance_unrealized_pnl(
_okx_positions,
active_pnl_rows,
get_live_position_exchange_metrics,
)
except Exception:
unrealized_pnl = None
options_unrealized_pnl = None
if OKX_OPTIONS_ENABLED and exchange_options.apiKey:
try: