Show premium paid on options position card and parse strike/type from instId when OKX omits them.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -202,6 +202,25 @@ def test_format_options_breakeven_line():
|
||||
assert "指数3480" in s
|
||||
|
||||
|
||||
def test_format_position_row_premium_and_inst_parse():
|
||||
from lib.exchange.okx_options_lib import format_position_row
|
||||
|
||||
row = format_position_row(
|
||||
{
|
||||
"instId": "ETH-USD_UM-260709-1700-P",
|
||||
"pos": "20",
|
||||
"avgPx": "6.2",
|
||||
"markPx": "6.3241",
|
||||
"idxPx": "1746",
|
||||
"upl": "0.0248",
|
||||
"uplRatio": "0.02",
|
||||
}
|
||||
)
|
||||
assert row["opt_type"] == "P"
|
||||
assert row["strike"] == 1700.0
|
||||
assert row["premium_paid"] == 1.24
|
||||
|
||||
|
||||
def test_format_position_row_breakeven():
|
||||
from lib.exchange.okx_options_lib import format_position_row
|
||||
|
||||
|
||||
Reference in New Issue
Block a user