Show option bid as price/size and option leverage on plan and trades.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-31 16:01:34 +08:00
parent dffcd77837
commit dffcc4eeb9
5 changed files with 75 additions and 1 deletions
+10
View File
@@ -1034,6 +1034,7 @@ class Matcher:
option_upl = 0.0
est_opt_close_fee = 0.0
opt_mark = None
opt_bid_sz = None
if oq and oq.bid is not None:
bid = float(oq.bid)
of = option_fill(
@@ -1045,10 +1046,12 @@ class Matcher:
)
est_opt_close_fee = of.fee
opt_mark = bid
opt_bid_sz = float(oq.bid_sz) if oq.bid_sz is not None else None
# 浮盈亏:买一×数量 − 初始权利金(对齐可市价卖出)
option_upl = bid * opt_qty - initial_premium
elif oq:
opt_mark = oq.bid or oq.mark_px
opt_bid_sz = float(oq.bid_sz) if oq.bid_sz is not None else None
if opt_mark is not None:
option_upl = float(opt_mark) * opt_qty - initial_premium
@@ -1063,6 +1066,11 @@ class Matcher:
leverage = self.ledger.get_setting_float("leverage", s.leverage)
notional = abs(perp_entry * perp_qty)
margin = notional / leverage if leverage > 0 else None
from ..strategy.selection import option_leverage as _opt_lev
opt_lev = _opt_lev(entry_idx, opt_entry) if entry_idx > 0 and opt_entry > 0 else None
if opt_lev is not None:
opt_lev = round(float(opt_lev), 1)
group_id = pos.get("group_id")
g = (
@@ -1105,6 +1113,8 @@ class Matcher:
"option_qty_eth": opt_qty,
"option_qty_contracts": float(pos["option_qty_contracts"] or 0),
"option_mark_px": float(opt_mark) if opt_mark is not None else None,
"option_bid_sz": float(opt_bid_sz) if opt_bid_sz is not None else None,
"option_leverage": float(opt_lev) if opt_lev is not None else None,
"strike": strike,
"expiry_ymd": expiry_ymd,
"expiry_ms": expiry_ms,