Align hedge UI/fees: drop 未启动, premium coin/U, equity incl perp margin, OKX option fees.
Option net uses Min(0.03%×coin, 7%×premium) with bid/ask fills (no slip); live PnL colors fixed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,9 +4,10 @@ from __future__ import annotations
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Any, Optional
|
||||
|
||||
from lib.hedge_plan.hedge_plan_option_primary_lib import (
|
||||
from lib.hedge_plan.hedge_plan_option_primary_lib import (
|
||||
estimate_combo_net_pnl,
|
||||
fee_rate,
|
||||
option_fee_rate,
|
||||
opt_type_for_view,
|
||||
option_bid_liquidity_ok,
|
||||
perp_direction_for_view,
|
||||
@@ -129,6 +130,7 @@ def build_live_hedge_cards(cfg: dict[str, Any], conn: Any) -> list[dict[str, Any
|
||||
get_cs = cfg.get("get_contract_size")
|
||||
fetch_idx = cfg.get("fetch_index_price")
|
||||
fr = fee_rate()
|
||||
fr_opt = option_fee_rate()
|
||||
now_ms = int(datetime.now(tz=_BJ).timestamp() * 1000)
|
||||
out: list[dict[str, Any]] = []
|
||||
|
||||
@@ -226,11 +228,15 @@ def build_live_hedge_cards(cfg: dict[str, Any], conn: Any) -> list[dict[str, Any
|
||||
contracts=float(contracts or 0),
|
||||
contract_size=float(cs or 0.01),
|
||||
fee=fr,
|
||||
option_fee=fr_opt,
|
||||
)
|
||||
opt_net_coin = float(net.get("opt_net") or 0)
|
||||
# 币→U:用当前指数(与买币参考价同口径)
|
||||
opt_net_usdt = round(opt_net_coin * float(idx or 0), 4) if idx else None
|
||||
perp_net = float(net.get("perp_net") or 0)
|
||||
combo_usdt = round((opt_net_usdt or 0) + perp_net, 4) if opt_net_usdt is not None else round(perp_net, 4)
|
||||
prem_coin = float(net.get("premium") or (float(avg_open or 0) * float(sheets or 0) * float(ct or 0.01)))
|
||||
prem_usdt = round(prem_coin * float(idx or 0), 2) if idx else None
|
||||
|
||||
opened_at = plan.get("opened_at")
|
||||
opened_ms = _parse_opened_ms(opened_at)
|
||||
@@ -253,6 +259,7 @@ def build_live_hedge_cards(cfg: dict[str, Any], conn: Any) -> list[dict[str, Any
|
||||
"remain_sec": remain_sec,
|
||||
"index_px": idx,
|
||||
"fee_rate": fr,
|
||||
"option_fee_rate": fr_opt,
|
||||
"option": {
|
||||
"inst_id": inst_id or "—",
|
||||
"opt_type": opt_type,
|
||||
@@ -266,6 +273,8 @@ def build_live_hedge_cards(cfg: dict[str, Any], conn: Any) -> list[dict[str, Any
|
||||
"leverage": opt_leverage,
|
||||
"liq_ok": bool(liq_ok),
|
||||
"liq_msg": liq_msg or "",
|
||||
"premium_coin": round(prem_coin, 4),
|
||||
"premium_usdt": prem_usdt,
|
||||
"net_coin": opt_net_coin,
|
||||
"net_usdt": opt_net_usdt,
|
||||
"live": bool(opt_raw),
|
||||
|
||||
Reference in New Issue
Block a user