Align options review PnL with OKX positions-history realizedPnl.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -556,8 +556,24 @@ def sync_all_review_sources(
|
||||
return out
|
||||
|
||||
|
||||
def ensure_local_review_synced(conn: sqlite3.Connection) -> dict[str, Any]:
|
||||
"""列表/统计前轻量刷新本地源."""
|
||||
def ensure_local_review_synced(
|
||||
conn: sqlite3.Connection,
|
||||
*,
|
||||
ex: Any | None = None,
|
||||
backfill_exchange_pnl: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
"""列表/统计前轻量刷新本地源;有交易所时先用历史仓位盈亏覆盖本地再导入复盘."""
|
||||
if backfill_exchange_pnl and ex is not None:
|
||||
try:
|
||||
from lib.exchange.okx_options_lib import fetch_all_option_positions_history
|
||||
from lib.options.options_monitor_lib import (
|
||||
backfill_closed_options_realized_pnl_from_history,
|
||||
)
|
||||
|
||||
hist = fetch_all_option_positions_history(ex, limit=200)
|
||||
backfill_closed_options_realized_pnl_from_history(conn, hist)
|
||||
except Exception:
|
||||
pass
|
||||
return sync_all_review_sources(conn, from_exchange=False)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user