Show bid/ask liquidity as price per sheet in options chain.
Display OKX askSz and bidSz beside top-of-book prices in the chain table and order panel using price/sheets format. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -28,6 +28,24 @@ def premium_per_sheet(quote_per_unit: float, ct_mult: float = 0.01) -> float:
|
||||
return float(quote_per_unit) * float(ct_mult)
|
||||
|
||||
|
||||
def format_quote_liquidity(px: float | None, sz: float | None, *, px_decimals: int = 4) -> str | None:
|
||||
"""盘口展示:价格/张数,如 17.2/150。"""
|
||||
if px is None:
|
||||
return None
|
||||
try:
|
||||
price = f"{float(px):.{px_decimals}f}".rstrip("0").rstrip(".")
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
if sz is None:
|
||||
return price
|
||||
try:
|
||||
s = float(sz)
|
||||
size = str(int(s)) if abs(s - int(s)) < 1e-9 else str(s).rstrip("0").rstrip(".")
|
||||
except (TypeError, ValueError):
|
||||
return price
|
||||
return f"{price}/{size}"
|
||||
|
||||
|
||||
def total_premium(quote_per_unit: float, eth_amount: float, ct_mult: float = 0.01) -> float:
|
||||
return float(quote_per_unit) * float(eth_amount)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user