Add OKX options expiry and close breakeven to hub monitor and dashboard.
Expose bePx-based expiry balance and mark-to-close breakeven on positions so monitor and dashboard can show both labels per contract. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -989,17 +989,29 @@ def format_dashboard_account_detail(ac: dict) -> dict[str, Any]:
|
||||
}
|
||||
)
|
||||
opt_snap = ac.get("options_snapshot") if isinstance(ac.get("options_snapshot"), dict) else {}
|
||||
options_positions: list[dict[str, Any]] = []
|
||||
if opt_snap.get("ok") is not False and opt_snap.get("enabled") is not False:
|
||||
from lib.options.options_pricing_lib import format_options_breakeven_line
|
||||
|
||||
for p in opt_snap.get("positions") or []:
|
||||
if not isinstance(p, dict):
|
||||
continue
|
||||
options_positions.append(p)
|
||||
inst = p.get("inst_id") or "?"
|
||||
opt_type = (p.get("opt_type") or "").upper()
|
||||
label = "Call" if opt_type == "C" else "Put" if opt_type == "P" else opt_type or "OPT"
|
||||
upl = p.get("upl")
|
||||
be_line = format_options_breakeven_line(
|
||||
expiry_be_px=p.get("expiry_be_px"),
|
||||
close_be_px=p.get("close_be_px"),
|
||||
idx_px=p.get("idx_px"),
|
||||
)
|
||||
text = f"期权 {inst} {label}"
|
||||
if be_line:
|
||||
text = f"{text} {be_line}"
|
||||
line: dict[str, Any] = {
|
||||
"kind": "options",
|
||||
"text": f"期权 {inst} {label}",
|
||||
"text": text,
|
||||
}
|
||||
if upl is not None:
|
||||
try:
|
||||
@@ -1016,6 +1028,7 @@ def format_dashboard_account_detail(ac: dict) -> dict[str, Any]:
|
||||
"rolls": len(mon.get("rolls") or []),
|
||||
},
|
||||
"position_lines": position_lines,
|
||||
"options_positions": options_positions,
|
||||
"issues": issues,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user