Enable hedge review with dual-timeframe K-line charts.
Always install the review module in hedge-only mode, expose 对冲复盘 in nav, and allow auto charts for closed hedge plans. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -139,8 +139,12 @@ def _maybe_schedule_options_review_chart(
|
||||
trade: dict[str, Any],
|
||||
data: dict[str, Any],
|
||||
) -> bool:
|
||||
"""纯期权 + 无手动截图 + 勾选自动K线 → 后台生成标的永续双周期拼图(只钉进/出场)."""
|
||||
if str(trade.get("source_type") or "").strip() != "option_spot":
|
||||
"""无手动截图 + 勾选自动K线 → 后台生成标的永续双周期拼图(只钉进/出场).
|
||||
|
||||
纯期权与永期/期期对冲均可;对冲按计划开平时间钉在标的永续 K 线上.
|
||||
"""
|
||||
src = str(trade.get("source_type") or "").strip()
|
||||
if src not in ("option_spot", "perp_options", "options_options"):
|
||||
return False
|
||||
images = data.get("images") if isinstance(data.get("images"), list) else []
|
||||
has_manual = any(str((x or {}).get("file") or "").strip() for x in images)
|
||||
@@ -205,12 +209,17 @@ def _maybe_schedule_options_review_chart(
|
||||
except Exception:
|
||||
now_ms = None
|
||||
|
||||
inst = str(trade.get("inst_id") or underlying or f"#{trade.get('id') or ''}").strip()
|
||||
plan_id = trade.get("hedge_plan_id")
|
||||
if plan_id:
|
||||
title_prefix = f"{underlying or 'HEDGE'} plan#{plan_id} review"
|
||||
else:
|
||||
inst = str(trade.get("inst_id") or underlying or f"#{trade.get('id') or ''}").strip()
|
||||
title_prefix = f"{underlying or 'OPT'} {inst} review"
|
||||
upload_folder = options_review_upload_dir(cfg["upload_folder"])
|
||||
schedule_options_review_exchange_chart(
|
||||
trade_id=int(trade["id"]),
|
||||
exchange_symbol=exchange_symbol,
|
||||
title_prefix=f"{underlying or 'OPT'} {inst} review",
|
||||
title_prefix=title_prefix,
|
||||
journal_tfs=journal_tfs,
|
||||
journal_limit=journal_limit,
|
||||
marker_payload={
|
||||
@@ -231,9 +240,7 @@ def _maybe_schedule_options_review_chart(
|
||||
def register_options_review_routes(app: Flask, cfg: dict[str, Any], repo_root: str) -> None:
|
||||
lr = cfg["login_required"]
|
||||
|
||||
@app.route("/options/review")
|
||||
@lr
|
||||
def options_review_page():
|
||||
def _review_page():
|
||||
from lib.instance.instance_embed_lib import redirect_to_embed_shell_if_enabled
|
||||
|
||||
redir = redirect_to_embed_shell_if_enabled("options_review")
|
||||
@@ -241,6 +248,17 @@ def register_options_review_routes(app: Flask, cfg: dict[str, Any], repo_root: s
|
||||
return redir
|
||||
return cfg["render_main_page"]("options_review")
|
||||
|
||||
@app.route("/options/review")
|
||||
@lr
|
||||
def options_review_page():
|
||||
return _review_page()
|
||||
|
||||
@app.route("/hedge-plan/review")
|
||||
@lr
|
||||
def hedge_plan_review_page():
|
||||
"""对冲复盘入口(与 /options/review 同页;本仓主入口)."""
|
||||
return _review_page()
|
||||
|
||||
@app.route("/static/options_review.js")
|
||||
@lr
|
||||
def static_options_review_js():
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
</style>
|
||||
|
||||
<div class="or-page-head">
|
||||
<h2>期权复盘</h2>
|
||||
<h2>{% if okx_trade_mode|default('') in ('perp_options', 'options_options') %}对冲复盘{% else %}期权复盘{% endif %}</h2>
|
||||
<span class="muted" id="or-sync-status" style="font-size:.72rem"></span>
|
||||
<button type="button" class="btn-secondary" id="or-reload-btn" style="font-size:.76rem;padding:4px 10px">刷新</button>
|
||||
</div>
|
||||
@@ -356,7 +356,7 @@
|
||||
<option value="now" {% if journal_chart_default_anchor == 'now' %}selected{% endif %}>当前时间</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="sub or-chart-hint hidden" id="or-chart-hint" style="font-size:.72rem;margin-top:2px;margin-bottom:0">纯期权:按标的永续画双周期上下图;只按时间标记进场/出场,不标止损;有手动截图时不自动生成</div>
|
||||
<div class="sub or-chart-hint hidden" id="or-chart-hint" style="font-size:.72rem;margin-top:2px;margin-bottom:0">{% if okx_trade_mode|default('') in ('perp_options', 'options_options') %}对冲:按标的永续画双周期上下图;按计划开仓/平仓时间钉点;有手动截图时不自动生成{% else %}纯期权:按标的永续画双周期上下图;只按时间标记进场/出场,不标止损;有手动截图时不自动生成{% endif %}</div>
|
||||
|
||||
<div class="or-mood-grid mood-grid">
|
||||
<label><input type="checkbox" class="or-mood" value="怕踏空">怕踏空</label>
|
||||
@@ -447,4 +447,4 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<script src="/static/options_review.js?v=23"></script>
|
||||
<script src="/static/options_review.js?v=24"></script>
|
||||
|
||||
Reference in New Issue
Block a user