Add live expiry countdown for options positions on instance page and trading hub.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -219,6 +219,20 @@ def test_format_position_row_premium_and_inst_parse():
|
||||
assert row["opt_type"] == "P"
|
||||
assert row["strike"] == 1700.0
|
||||
assert row["premium_paid"] == 1.24
|
||||
assert row["exp_time_ms"] is not None
|
||||
assert row["exp_time_ms"] > 0
|
||||
|
||||
|
||||
def test_expiry_ms_from_inst_id():
|
||||
from lib.exchange.okx_options_lib import expiry_ms_from_inst_id, normalize_option_exp_ms
|
||||
|
||||
ms = expiry_ms_from_inst_id("ETH-USD_UM-260709-1700-P")
|
||||
assert ms is not None
|
||||
from datetime import datetime, timezone
|
||||
|
||||
dt = datetime.fromtimestamp(ms / 1000, tz=timezone.utc)
|
||||
assert dt.year == 2026 and dt.month == 7 and dt.day == 9 and dt.hour == 8
|
||||
assert normalize_option_exp_ms(None, "ETH-USD_UM-260709-1700-P") == ms
|
||||
|
||||
|
||||
def test_format_position_row_breakeven():
|
||||
|
||||
Reference in New Issue
Block a user