修复期权历史/复盘金额为0:模拟盘合成历史、币本位按ETH精度展示,复盘折算为U。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-20 21:51:01 +08:00
parent 4eef0d9fd6
commit e1c2e5889f
6 changed files with 255 additions and 17 deletions
+29
View File
@@ -355,6 +355,31 @@ def _patch_okx_options_lib(app_module: Any) -> None:
pass
return _orig_fetch_pos(ex)
_orig_fetch_hist = getattr(opt_lib, "fetch_option_position_history", None)
_orig_fetch_all_hist = getattr(opt_lib, "fetch_all_option_positions_history", None)
def fetch_option_position_history(ex, inst_id, limit=50):
try:
if _GET_DB is not None and is_sim_mode(_GET_DB):
return broker().option_positions_history_okx_rows(
ex, inst_id=inst_id, limit=limit
)
except Exception:
pass
if callable(_orig_fetch_hist):
return _orig_fetch_hist(ex, inst_id, limit=limit)
return []
def fetch_all_option_positions_history(ex, *, limit=200):
try:
if _GET_DB is not None and is_sim_mode(_GET_DB):
return broker().option_positions_history_okx_rows(ex, limit=limit)
except Exception:
pass
if callable(_orig_fetch_all_hist):
return _orig_fetch_all_hist(ex, limit=limit)
return []
opt_lib.options_header_balances = options_header_balances
opt_lib.fetch_options_balances = fetch_options_balances
opt_lib.options_api_ready = options_api_ready
@@ -363,6 +388,8 @@ def _patch_okx_options_lib(app_module: Any) -> None:
opt_lib.fetch_option_order = fetch_option_order
opt_lib.wait_option_order_full_fill = wait_option_order_full_fill
opt_lib.fetch_option_positions = fetch_option_positions
opt_lib.fetch_option_position_history = fetch_option_position_history
opt_lib.fetch_all_option_positions_history = fetch_all_option_positions_history
opt_lib._sim_hooks_applied = True
_patch_spot_bridge_lib()
@@ -533,6 +560,8 @@ def patch_options_cfg(cfg: dict[str, Any]) -> dict[str, Any]:
"fetch_option_positions",
"fetch_option_order",
"wait_option_order_full_fill",
"fetch_option_position_history",
"fetch_all_option_positions_history",
):
if key in cfg and hasattr(opt_lib, key):
cfg[key] = getattr(opt_lib, key)