Add pre-buy expiry breakeven columns to options chain table.

Show estimated expiry balance and distance from index in the chain list and order panel using ask price before opening a position.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-07 16:21:22 +08:00
parent 3570a6900e
commit 99f13817f8
6 changed files with 96 additions and 8 deletions
+8
View File
@@ -67,6 +67,14 @@ def test_option_moneyness():
assert option_moneyness_label("otm") == "虚值"
def test_expiry_breakeven_from_ask():
from lib.options.options_pricing_lib import expiry_breakeven_from_ask
assert expiry_breakeven_from_ask(opt_type="C", strike=1760, ask_px=15.6) == 1775.6
assert expiry_breakeven_from_ask(opt_type="P", strike=1760, ask_px=15.6) == 1744.4
assert expiry_breakeven_from_ask(opt_type="C", strike=1760, ask_px=None, mark_px=14.2) == 1774.2
def test_calc_order_size_too_small():
r = calc_order_size(
quote_per_unit=2000.0,