Show OKX-style perp/option position cards on plan page.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -389,6 +389,7 @@ class Matcher:
|
||||
}
|
||||
gw = get_gateway()
|
||||
snap = gw.snapshot()
|
||||
s = get_settings()
|
||||
index_px = snap.index_px
|
||||
if index_px is None and snap.perp:
|
||||
index_px = snap.perp.mark_px
|
||||
@@ -425,11 +426,37 @@ class Matcher:
|
||||
move = abs(float(index_px) - entry_idx) if index_px is not None and entry_idx else 0.0
|
||||
initial_premium = float(pos["initial_premium"] or 0)
|
||||
premium_gap = initial_premium - perp_upl
|
||||
|
||||
group_id = pos.get("group_id")
|
||||
g = (
|
||||
self.db.fetchone("SELECT * FROM groups WHERE group_id=?", (group_id,))
|
||||
if group_id
|
||||
else None
|
||||
)
|
||||
strike = float(g["strike"]) if g and g["strike"] is not None else None
|
||||
expiry_ymd = str(g["expiry_ymd"]) if g and g["expiry_ymd"] else None
|
||||
perp_inst_id = (
|
||||
str(g["perp_inst_id"])
|
||||
if g and g["perp_inst_id"]
|
||||
else s.perp_inst_id
|
||||
)
|
||||
|
||||
return {
|
||||
"has_position": True,
|
||||
"group_id": pos["group_id"],
|
||||
"group_id": group_id,
|
||||
"perp_side": perp_side,
|
||||
"option_side": option_side,
|
||||
"perp_inst_id": perp_inst_id,
|
||||
"perp_entry_px": perp_entry,
|
||||
"perp_qty_eth": perp_qty,
|
||||
"perp_mark_px": float(mark) if mark is not None else None,
|
||||
"option_inst_id": pos.get("option_inst_id"),
|
||||
"option_entry_px": float(pos["option_entry_px"] or 0),
|
||||
"option_qty_eth": float(pos["option_qty_eth"] or 0),
|
||||
"option_qty_contracts": float(pos["option_qty_contracts"] or 0),
|
||||
"option_mark_px": float(opt_mark) if opt_mark is not None else None,
|
||||
"strike": strike,
|
||||
"expiry_ymd": expiry_ymd,
|
||||
"perp_upl": perp_upl,
|
||||
"option_upl": option_upl,
|
||||
"index_px": index_px,
|
||||
|
||||
Reference in New Issue
Block a user