Fix coin-margin expiry breakeven to use coin premium formula.
Use K/(1-p) and K/(1+p) for coin calls/puts instead of adding ETH premium to USD strike; align T-view straddle band with coin quotes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -889,6 +889,7 @@ def build_option_chain(
|
||||
strike=strike,
|
||||
ask_px=ask,
|
||||
mark_px=mark,
|
||||
quote_in_coin="_UM" not in (family or "").upper(),
|
||||
)
|
||||
mny = option_moneyness(opt_type=opt_type, strike=strike, index_px=idx)
|
||||
exp_key = str(exp_ms)
|
||||
@@ -1028,11 +1029,18 @@ def quote_option_contract(ex: ccxt.okx, inst_id: str) -> dict[str, Any]:
|
||||
idx = fetch_index_price(ex, uly)
|
||||
opt_type = meta.get("optType")
|
||||
strike = _safe_float(meta.get("stk"))
|
||||
try:
|
||||
from lib.options.options_margin_mode_lib import margin_mode_from_inst_id
|
||||
|
||||
quote_in_coin = margin_mode_from_inst_id(inst_id) == "coin"
|
||||
except Exception:
|
||||
quote_in_coin = "USD_UM" not in inst_id.upper() and "-USD-" in inst_id.upper()
|
||||
expiry_be = expiry_breakeven_from_ask(
|
||||
opt_type=str(opt_type or ""),
|
||||
strike=strike,
|
||||
ask_px=book_ask if can_open else None,
|
||||
mark_px=mark,
|
||||
quote_in_coin=quote_in_coin,
|
||||
)
|
||||
return {
|
||||
"ok": True,
|
||||
@@ -1824,11 +1832,18 @@ def format_position_row(
|
||||
round(total_premium(avg, eth_amount), 8) if avg is not None and eth_amount > 0 else None
|
||||
)
|
||||
delta_pa = _safe_float(pos.get("deltaPA"))
|
||||
try:
|
||||
from lib.options.options_margin_mode_lib import margin_mode_from_inst_id
|
||||
|
||||
quote_in_coin = margin_mode_from_inst_id(inst_id) == "coin"
|
||||
except Exception:
|
||||
quote_in_coin = "USD_UM" not in inst_id.upper() and "-USD-" in inst_id.upper()
|
||||
expiry_be = expiry_breakeven_px(
|
||||
opt_type=str(opt_type or ""),
|
||||
strike=strike,
|
||||
avg_px=avg,
|
||||
be_px_api=_safe_float(pos.get("bePx")),
|
||||
quote_in_coin=quote_in_coin,
|
||||
)
|
||||
close_be = close_breakeven_idx(
|
||||
opt_type=str(opt_type or ""),
|
||||
|
||||
Reference in New Issue
Block a user