实现OKX单笔期权币本位与USDT桥复利(中控只读,不改Gate)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -96,6 +96,47 @@ def build_options_hub_snapshot(cfg: dict[str, Any]) -> dict[str, Any]:
|
||||
has_upl = True
|
||||
upl_total += float(pnl)
|
||||
bal = cfg["fetch_options_balances"](ex)
|
||||
from lib.options.options_margin_mode_lib import (
|
||||
is_coin_margin_mode,
|
||||
normalize_options_margin_mode,
|
||||
premium_ccy_for_mode,
|
||||
)
|
||||
|
||||
margin_mode = normalize_options_margin_mode()
|
||||
for p in positions:
|
||||
mid = str(p.get("inst_id") or "")
|
||||
from lib.options.options_margin_mode_lib import margin_mode_from_inst_id
|
||||
|
||||
row_mode = margin_mode_from_inst_id(mid) if mid else margin_mode
|
||||
p["margin_mode"] = row_mode
|
||||
p["premium_ccy"] = p.get("premium_ccy") or premium_ccy_for_mode(
|
||||
row_mode, str(p.get("underlying") or mid.split("-")[0] if mid else "ETH")
|
||||
)
|
||||
p["margin_mode_label"] = "币本位" if row_mode == "coin" else "USDC"
|
||||
|
||||
coin_budget = None
|
||||
bridge_status = None
|
||||
open_bridges = []
|
||||
if is_coin_margin_mode():
|
||||
try:
|
||||
from lib.options.options_coin_open_lib import coin_budget_preview
|
||||
|
||||
coin_budget = coin_budget_preview(cfg, ex)
|
||||
except Exception:
|
||||
coin_budget = None
|
||||
try:
|
||||
conn_b = cfg["get_db"]()
|
||||
try:
|
||||
from lib.options.options_spot_bridge_lib import list_open_bridges
|
||||
|
||||
open_bridges = list_open_bridges(conn_b)
|
||||
if open_bridges:
|
||||
bridge_status = str(open_bridges[0].get("status") or "")
|
||||
finally:
|
||||
conn_b.close()
|
||||
except Exception:
|
||||
open_bridges = []
|
||||
|
||||
return {
|
||||
"ok": True,
|
||||
"enabled": True,
|
||||
@@ -113,6 +154,11 @@ def build_options_hub_snapshot(cfg: dict[str, Any]) -> dict[str, Any]:
|
||||
"trade_budget": cfg.get("trade_budget"),
|
||||
"account_label": cfg.get("account_label") or "OKX期权",
|
||||
"max_active_positions": options_max_active_positions(),
|
||||
"options_margin_mode": margin_mode,
|
||||
"options_margin_mode_label": "币本位" if margin_mode == "coin" else "USDC",
|
||||
"coin_budget": coin_budget,
|
||||
"bridge_status": bridge_status,
|
||||
"open_bridges": open_bridges,
|
||||
}
|
||||
except Exception as e:
|
||||
return {"ok": False, "enabled": True, "msg": str(e)}
|
||||
|
||||
Reference in New Issue
Block a user