Keep OO amplitude refreshed while holding a position.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2011,9 +2011,19 @@ class Matcher:
|
||||
if index_px is None and snap.perp:
|
||||
index_px = snap.perp.mark_px
|
||||
qty = float(pos.get("option_qty_eth") or 0)
|
||||
qty2 = float(pos.get("option2_qty_eth") or qty)
|
||||
raw_q2 = pos.get("option2_qty_eth")
|
||||
try:
|
||||
qty2 = float(raw_q2) if raw_q2 is not None else 0.0
|
||||
except (TypeError, ValueError):
|
||||
qty2 = 0.0
|
||||
if qty2 <= 0:
|
||||
qty2 = qty
|
||||
contracts1 = float(pos.get("option_qty_contracts") or 0)
|
||||
contracts2 = float(pos.get("option2_qty_contracts") or 0)
|
||||
raw_c2 = pos.get("option2_qty_contracts")
|
||||
try:
|
||||
contracts2 = float(raw_c2) if raw_c2 is not None else 0.0
|
||||
except (TypeError, ValueError):
|
||||
contracts2 = 0.0
|
||||
prem1 = float(pos.get("initial_premium") or 0)
|
||||
prem2 = float(pos.get("initial_premium2") or 0)
|
||||
call_id = str(pos.get("option_inst_id") or "")
|
||||
@@ -2022,6 +2032,19 @@ class Matcher:
|
||||
entry2 = float(pos.get("option2_entry_px") or 0)
|
||||
oq1 = self._quote_held_option(call_id) if call_id else None
|
||||
oq2 = self._quote_held_option(put_id) if put_id else None
|
||||
# 盘口缓存未订阅到 Put 时,回退 session 监控腿(与「持仓虚值」同数据源)
|
||||
if (oq2 is None or (oq2.bid is None and oq2.mark_px is None)) and put_id:
|
||||
try:
|
||||
if snap.put and str(getattr(snap.put, "inst_id", "") or "") == put_id:
|
||||
oq2 = snap.put
|
||||
except Exception:
|
||||
pass
|
||||
if (oq1 is None or (oq1.bid is None and oq1.mark_px is None)) and call_id:
|
||||
try:
|
||||
if snap.call and str(getattr(snap.call, "inst_id", "") or "") == call_id:
|
||||
oq1 = snap.call
|
||||
except Exception:
|
||||
pass
|
||||
option_upl = 0.0
|
||||
option2_upl = 0.0
|
||||
fees = 0.0
|
||||
|
||||
Reference in New Issue
Block a user