Add expiry profit estimate and remove chain quick-buy button.

Let users enter a target index in the order panel for estimated expiry P&L, and remove the redundant buy button from the options chain row.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-07 16:46:21 +08:00
parent 2cfc1a490f
commit 27921213b0
5 changed files with 146 additions and 10 deletions
+15
View File
@@ -67,6 +67,21 @@ def test_option_moneyness():
assert option_moneyness_label("otm") == "虚值"
def test_estimate_expiry_profit_at_index():
from lib.options.options_pricing_lib import estimate_expiry_profit_at_index
# Call 1780, ask 12.2, 0.01 ETH, target 1793 -> (13-12.2)*0.01 = 0.008
p = estimate_expiry_profit_at_index(
opt_type="C", strike=1780, target_idx=1793, entry_px=12.2, eth_amount=0.01
)
assert p == 0.008
# OTM call loses premium
p2 = estimate_expiry_profit_at_index(
opt_type="C", strike=1780, target_idx=1770, entry_px=12.2, eth_amount=0.01
)
assert p2 == round(-12.2 * 0.01, 4)
def test_format_quote_liquidity():
from lib.options.options_pricing_lib import format_quote_liquidity