币本位期权开仓/翻倍提醒/翻倍平仓/目标平仓/手动平仓微信推送:按ETH/BTC计价并补齐全平必发

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-20 18:02:12 +08:00
parent 9bb05113f3
commit 8b5080bdda
6 changed files with 256 additions and 19 deletions
+37 -3
View File
@@ -233,6 +233,12 @@ def _notify_profit_exit_close(
result: dict[str, Any],
conn: Any = None,
) -> None:
from lib.options.options_notify_lib import resolve_options_premium_ccy
ccy = resolve_options_premium_ccy(inst_id=inst_id)
d = 6 if ccy in ("ETH", "BTC") else 4
mode = "币本位" if ccy != "USDC" else "USDC"
reason = f"翻倍出场({mult:g}倍)"
if result.get("fully_closed") or result.get("already_flat"):
if cfg is not None:
try:
@@ -242,26 +248,31 @@ def _notify_profit_exit_close(
cfg,
conn,
inst_id=inst_id,
reason=f"翻倍出场({mult:g}倍)",
reason=reason,
sheets=result.get("submitted_sheets"),
premium_received=result.get("premium_received"),
close_quote=result.get("locked_bid_px") or result.get("bid"),
premium_ccy=ccy,
)
# 无论首次/幂等跳过,全平路径不再走下方 fallback,避免重复推
return
except Exception:
pass
if not send_wechat:
return
try:
prem_txt = f"{float(premium_paid):.{d}f}" if premium_paid is not None else ""
recv_txt = f"{float(recycle):.{d}f}" if recycle is not None else ""
send_wechat(
"\n".join(
[
"【OKX期权·翻倍出场】",
f"账户:{account_label}",
f"本位:{mode}",
f"合约:{inst_id}",
f"倍数:{mult:g}(1倍=盈利=权利金)",
f"权利金:{premium_paid if premium_paid is not None else ''}",
f"可回收:{recycle if recycle is not None else ''}",
f"权利金:{prem_txt} {ccy}",
f"可回收:{recv_txt} {ccy}",
f"提交张数:{result.get('submitted_sheets') or ''}",
f"状态:{'已全平' if (result.get('fully_closed') or result.get('already_flat')) else '挂单中/部分'}",
]
@@ -330,6 +341,17 @@ def run_options_profit_exits(
if result.get("already_flat") or _result_fully_done(result):
_mark_state(conn, inst_id, "done")
_commit(conn)
_notify_profit_exit_close(
cfg,
send_wechat,
account_label=account_label,
inst_id=inst_id,
mult=mult,
premium_paid=prem,
recycle=None,
result={**result, "fully_closed": True},
conn=conn,
)
else:
_mark_state(conn, inst_id, "closing")
_commit(conn)
@@ -353,6 +375,18 @@ def run_options_profit_exits(
if result.get("already_flat"):
_mark_state(conn, inst_id, "done")
_commit(conn)
triggered += 1
_notify_profit_exit_close(
cfg,
send_wechat,
account_label=account_label,
inst_id=inst_id,
mult=mult,
premium_paid=prem,
recycle=recycle,
result=result,
conn=conn,
)
continue
if not result.get("ok"):
_mark_state(conn, inst_id, "active")