feat(options): use premium profit RR instead of target index

单独期权与中控改为盈亏比×权利金触发买一平仓,默认2;不达标等到期。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-11 10:34:14 +08:00
parent 3b56e15fb1
commit 5c3969674a
13 changed files with 494 additions and 194 deletions
+19 -2
View File
@@ -55,6 +55,7 @@ def build_options_open_message(
premium_paid: Any = None,
open_quote: Any = None,
target_index: Any = None,
profit_rr: Any = None,
signal_note: str = "",
trade_id: Any = None,
) -> str:
@@ -73,7 +74,12 @@ def build_options_open_message(
f"权利金:{_fmt(premium_paid)} USDC",
]
)
if target_index is not None and str(target_index).strip() != "":
if profit_rr is not None and str(profit_rr).strip() != "":
try:
lines.append(f"盈亏比:×{float(profit_rr):g}(达标全平;不达标等到期)")
except (TypeError, ValueError):
lines.append(f"盈亏比:{profit_rr}")
elif target_index is not None and str(target_index).strip() != "":
try:
lines.append(f"目标指数:{float(target_index):g}")
except (TypeError, ValueError):
@@ -96,6 +102,7 @@ def build_options_close_message(
realized_pnl: Any = None,
close_quote: Any = None,
target_index: Any = None,
profit_rr: Any = None,
trigger_idx: Any = None,
trade_id: Any = None,
) -> str:
@@ -116,7 +123,12 @@ def build_options_close_message(
f"实现盈亏:{_fmt(realized_pnl, 4)} USDC",
]
)
if target_index is not None and str(target_index).strip() != "":
if profit_rr is not None and str(profit_rr).strip() != "":
try:
lines.append(f"盈亏比:×{float(profit_rr):g}")
except (TypeError, ValueError):
lines.append(f"盈亏比:{profit_rr}")
elif target_index is not None and str(target_index).strip() != "":
try:
lines.append(f"目标指数:{float(target_index):g}")
except (TypeError, ValueError):
@@ -141,6 +153,7 @@ def notify_options_open(
premium_paid: Any = None,
open_quote: Any = None,
target_index: Any = None,
profit_rr: Any = None,
signal_note: str = "",
) -> bool:
ensure_options_notify_columns(conn) if conn is not None else None
@@ -160,6 +173,7 @@ def notify_options_open(
premium_paid=premium_paid,
open_quote=open_quote,
target_index=target_index,
profit_rr=profit_rr,
signal_note=signal_note,
trade_id=trade_id,
)
@@ -196,6 +210,7 @@ def notify_options_close(
realized_pnl: Any = None,
close_quote: Any = None,
target_index: Any = None,
profit_rr: Any = None,
trigger_idx: Any = None,
force: bool = False,
) -> bool:
@@ -257,6 +272,7 @@ def notify_options_close(
realized_pnl=total_pnl,
close_quote=close_quote if close_quote is not None else head.get("close_quote"),
target_index=target_index,
profit_rr=profit_rr,
trigger_idx=trigger_idx,
trade_id=head.get("id") if len(rows) == 1 else None,
)
@@ -286,6 +302,7 @@ def notify_options_close(
realized_pnl=realized_pnl,
close_quote=close_quote,
target_index=target_index,
profit_rr=profit_rr,
trigger_idx=trigger_idx,
trade_id=trade_id,
)