Fix option history to full closes only, 2-decimal USDC, restore hide-delete.
Filter OKX positions-history to type 2/3/6, format premium and bid recovery to 2 decimals, and allow locally hiding rows via delete button. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import sqlite3
|
||||
from lib.exchange.okx_options_lib import (
|
||||
format_option_history_row,
|
||||
format_usdc_amount,
|
||||
is_option_full_close_history,
|
||||
resolve_option_close_from_history,
|
||||
)
|
||||
from lib.options.options_db import init_options_tables
|
||||
@@ -11,9 +12,16 @@ from lib.options.options_monitor_lib import sync_open_options_trades
|
||||
|
||||
|
||||
def test_format_usdc_amount():
|
||||
assert format_usdc_amount(4.896) == "4.896"
|
||||
assert format_usdc_amount(4.90) == "4.9"
|
||||
assert format_usdc_amount(4.0) == "4"
|
||||
assert format_usdc_amount(4.896) == "4.90"
|
||||
assert format_usdc_amount(4.9) == "4.90"
|
||||
assert format_usdc_amount(4.0) == "4.00"
|
||||
|
||||
|
||||
def test_is_option_full_close_history():
|
||||
assert is_option_full_close_history({"type": "2"})
|
||||
assert is_option_full_close_history({"type": "3"})
|
||||
assert not is_option_full_close_history({"type": "1"})
|
||||
assert not is_option_full_close_history({"type": "5"})
|
||||
|
||||
|
||||
def test_format_option_history_row():
|
||||
@@ -36,7 +44,8 @@ def test_format_option_history_row():
|
||||
assert row["realized_pnl"] == -3.99
|
||||
assert row["status_label"] == "已平"
|
||||
assert row["open_avg_px_fmt"] == "380"
|
||||
assert row["premium_paid_fmt"] == "3.8"
|
||||
assert row["premium_paid_fmt"] == "3.80"
|
||||
assert row["history_key"] == "ex:pos-btc"
|
||||
|
||||
|
||||
def test_resolve_option_close_from_history_picks_latest():
|
||||
|
||||
Reference in New Issue
Block a user