chore: restore codebase to state before 2026-08-11 changes
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -646,17 +646,6 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
mode = (data.get("mode") or "budget_full").strip()
|
||||
signal_note = (data.get("signal_note") or "").strip()
|
||||
target_index = None
|
||||
profit_rr = None
|
||||
raw_rr = data.get("profit_rr")
|
||||
if raw_rr is None or str(raw_rr).strip() == "":
|
||||
raw_rr = data.get("oo_profit_rr")
|
||||
if raw_rr is not None and str(raw_rr).strip() != "":
|
||||
try:
|
||||
profit_rr = float(raw_rr)
|
||||
except (TypeError, ValueError):
|
||||
return jsonify({"ok": False, "msg": "盈亏比无效"})
|
||||
if profit_rr <= 0:
|
||||
return jsonify({"ok": False, "msg": "盈亏比须大于 0"})
|
||||
raw_target = data.get("target_index")
|
||||
if raw_target is not None and str(raw_target).strip() != "":
|
||||
try:
|
||||
@@ -665,9 +654,6 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
return jsonify({"ok": False, "msg": "目标位无效"})
|
||||
if target_index <= 0:
|
||||
return jsonify({"ok": False, "msg": "目标位无效"})
|
||||
# 未显式传目标时默认盈亏比 2
|
||||
if profit_rr is None and target_index is None:
|
||||
profit_rr = 2.0
|
||||
if not inst_id:
|
||||
return jsonify({"ok": False, "msg": "缺少 inst_id"})
|
||||
q = cfg["quote_option_contract"](ex, inst_id)
|
||||
@@ -834,14 +820,13 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
),
|
||||
)
|
||||
trade_id = int(cur.lastrowid)
|
||||
if profit_rr is not None or target_index is not None:
|
||||
if target_index is not None:
|
||||
from lib.options.options_target_lib import upsert_target_monitor
|
||||
|
||||
target_mon = upsert_target_monitor(
|
||||
conn,
|
||||
inst_id=inst_id,
|
||||
target_index=target_index,
|
||||
profit_rr=profit_rr,
|
||||
underlying=u,
|
||||
opt_type=str(opt_type) if opt_type else None,
|
||||
trade_id=trade_id,
|
||||
@@ -869,7 +854,6 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
premium_paid=sizing.get("total_premium"),
|
||||
open_quote=fill_px,
|
||||
target_index=target_index,
|
||||
profit_rr=profit_rr,
|
||||
signal_note=signal_note,
|
||||
)
|
||||
finally:
|
||||
@@ -985,14 +969,11 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
mon = tgt_map.get(inst)
|
||||
if mon:
|
||||
row["target_index"] = mon.get("target_index")
|
||||
row["profit_rr"] = mon.get("profit_rr")
|
||||
row["target_monitor_id"] = mon.get("id")
|
||||
row["target_monitor"] = mon
|
||||
hedge_target = hedge_target_map.get(inst)
|
||||
if hedge_target:
|
||||
row["hedge_plan_target"] = hedge_target
|
||||
if hedge_target.get("oo_profit_rr") is not None:
|
||||
row.setdefault("profit_rr", hedge_target.get("oo_profit_rr"))
|
||||
try:
|
||||
from lib.instance.instance_dashboard_lib import _resolve_options_source
|
||||
|
||||
@@ -1050,28 +1031,12 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
conn_h.close()
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "msg": f"对冲托管校验失败: {e}"})
|
||||
profit_rr = None
|
||||
target_index = None
|
||||
raw_rr = data.get("profit_rr")
|
||||
if raw_rr is None or str(raw_rr).strip() == "":
|
||||
raw_rr = data.get("oo_profit_rr")
|
||||
if raw_rr is not None and str(raw_rr).strip() != "":
|
||||
try:
|
||||
profit_rr = float(raw_rr)
|
||||
except (TypeError, ValueError):
|
||||
return jsonify({"ok": False, "msg": "盈亏比无效"})
|
||||
if profit_rr <= 0:
|
||||
return jsonify({"ok": False, "msg": "盈亏比须大于 0"})
|
||||
raw_tgt = data.get("target_index")
|
||||
if raw_tgt is not None and str(raw_tgt).strip() != "":
|
||||
try:
|
||||
target_index = float(raw_tgt)
|
||||
except (TypeError, ValueError):
|
||||
return jsonify({"ok": False, "msg": "目标位无效"})
|
||||
if target_index <= 0:
|
||||
return jsonify({"ok": False, "msg": "目标位无效"})
|
||||
if profit_rr is None and target_index is None:
|
||||
profit_rr = 2.0
|
||||
try:
|
||||
target_index = float(data.get("target_index"))
|
||||
except (TypeError, ValueError):
|
||||
return jsonify({"ok": False, "msg": "目标位无效"})
|
||||
if target_index <= 0:
|
||||
return jsonify({"ok": False, "msg": "目标位无效"})
|
||||
raw = cfg["fetch_option_positions"](ex)
|
||||
if raw is None:
|
||||
return jsonify({"ok": False, "msg": "获取期权持仓失败"})
|
||||
@@ -1100,7 +1065,6 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
conn,
|
||||
inst_id=inst_id,
|
||||
target_index=target_index,
|
||||
profit_rr=profit_rr,
|
||||
underlying=str(underlying) if underlying else None,
|
||||
opt_type=str(opt_type) if opt_type else None,
|
||||
trade_id=trade_id,
|
||||
@@ -1447,24 +1411,7 @@ def _start_monitor_thread(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
raw = cfg["fetch_option_positions"](ex)
|
||||
if raw is None:
|
||||
return []
|
||||
rows = [cfg["format_position_row"](p) for p in raw]
|
||||
try:
|
||||
from lib.options.options_db import sum_open_premium_paid
|
||||
|
||||
conn = cfg["get_db"]()
|
||||
try:
|
||||
for row in rows:
|
||||
inst = str(row.get("inst_id") or "")
|
||||
if not inst:
|
||||
continue
|
||||
paid = sum_open_premium_paid(conn, inst)
|
||||
if paid is not None:
|
||||
row["premium_paid"] = paid
|
||||
finally:
|
||||
conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
return rows
|
||||
return [cfg["format_position_row"](p) for p in raw]
|
||||
|
||||
def _sync(conn):
|
||||
from lib.exchange.okx_options_lib import fetch_option_position_history
|
||||
|
||||
Reference in New Issue
Block a user