feat(options): use premium profit RR instead of target index
单独期权与中控改为盈亏比×权利金触发买一平仓,默认2;不达标等到期。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -123,21 +123,31 @@ def _resolve_options_source(conn, inst_id: str) -> tuple[str, str, int | None]:
|
||||
|
||||
def _format_options_target(p: dict[str, Any]) -> str:
|
||||
hedge = p.get("hedge_plan_target") if isinstance(p.get("hedge_plan_target"), dict) else None
|
||||
opt_type = str(p.get("opt_type") or p.get("optType") or "").upper()
|
||||
if hedge:
|
||||
ot = str(hedge.get("opt_type") or opt_type).upper()
|
||||
rr = _safe_float(hedge.get("oo_profit_rr") or hedge.get("profit_rr"))
|
||||
pid = hedge.get("plan_id")
|
||||
if rr is not None and rr > 0:
|
||||
return f"对冲#{pid} 盈亏比×{rr:g}" if pid is not None else f"盈亏比×{rr:g}"
|
||||
ot = str(hedge.get("opt_type") or p.get("opt_type") or p.get("optType") or "").upper()
|
||||
side = "Put ≤" if ot == "P" else "Call ≥"
|
||||
tgt = _safe_float(hedge.get("target_index"))
|
||||
pid = hedge.get("plan_id")
|
||||
if tgt is not None:
|
||||
return f"对冲#{pid} {side} {tgt:g}" if pid is not None else f"{side} {tgt:g}"
|
||||
mon = p.get("target_monitor") if isinstance(p.get("target_monitor"), dict) else None
|
||||
rr = _safe_float(p.get("profit_rr"))
|
||||
if rr is None and mon:
|
||||
rr = _safe_float(mon.get("profit_rr"))
|
||||
if rr is not None and rr > 0:
|
||||
return f"盈亏比×{rr:g}"
|
||||
tgt = _safe_float(p.get("target_index"))
|
||||
if tgt is None and mon:
|
||||
tgt = _safe_float(mon.get("target_index"))
|
||||
if tgt is not None and tgt > 0:
|
||||
opt_type = str(p.get("opt_type") or p.get("optType") or "").upper()
|
||||
side = "Put ≤" if opt_type == "P" else "Call ≥"
|
||||
return f"{side} {tgt:g}"
|
||||
return "—"
|
||||
|
||||
|
||||
def _format_options_item(p: dict[str, Any], *, conn=None) -> dict[str, Any]:
|
||||
inst = str(p.get("inst_id") or p.get("instId") or "-").strip() or "-"
|
||||
opt_type = str(p.get("opt_type") or p.get("optType") or "").upper()
|
||||
|
||||
Reference in New Issue
Block a user