Fix false options close sync, restore bar layout, and show open premium in history.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-09 17:51:07 +08:00
parent 08a61fd4ae
commit 5a97e14f3e
6 changed files with 124 additions and 24 deletions
+4 -2
View File
@@ -147,7 +147,7 @@ def _sync_options_trades(cfg: dict[str, Any]) -> None:
if ex is None:
return
from lib.exchange.okx_options_lib import fetch_option_position_history
from lib.options.options_monitor_lib import sync_open_options_trades
from lib.options.options_monitor_lib import reconcile_live_open_trades, sync_open_options_trades
raw = cfg["fetch_option_positions"](ex)
live_ids = {str(p.get("instId") or "") for p in raw if str(p.get("instId") or "")}
@@ -158,6 +158,7 @@ def _sync_options_trades(cfg: dict[str, Any]) -> None:
conn = cfg["get_db"]()
try:
init_options_tables(conn)
reconcile_live_open_trades(conn, live_inst_ids=live_ids)
sync_open_options_trades(conn, live_inst_ids=live_ids, fetch_history_fn=_hist)
conn.commit()
finally:
@@ -715,13 +716,14 @@ def _start_monitor_thread(app: Flask, cfg: dict[str, Any]) -> None:
def _sync(conn):
from lib.exchange.okx_options_lib import fetch_option_position_history
from lib.options.options_monitor_lib import sync_open_options_trades
from lib.options.options_monitor_lib import reconcile_live_open_trades, sync_open_options_trades
ex = cfg.get("exchange_options")
if ex is None:
return 0
raw = cfg["fetch_option_positions"](ex)
live_ids = {str(p.get("instId") or "") for p in raw if str(p.get("instId") or "")}
reconcile_live_open_trades(conn, live_inst_ids=live_ids)
return sync_open_options_trades(
conn,
live_inst_ids=live_ids,