Define entry styles: trend/reversal x 3 patterns, plus messy other.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-17 22:54:19 +08:00
parent ae1b91fcc5
commit bc50f300ba
4 changed files with 139 additions and 8 deletions
+13 -1
View File
@@ -699,7 +699,13 @@ def register_routes(app: Flask) -> None:
charts[tf] = database.get_bars(
conn, trade["symbol"], tf, float(center) - window, float(center) + window
)
return render_template("record_detail.html", trade=trade, charts=charts)
return render_template(
"record_detail.html",
trade=trade,
charts=charts,
entry_styles=database.ENTRY_STYLES,
entry_patterns=database.ENTRY_PATTERN_TYPES,
)
@app.post("/records/<int:tid>/annotate")
@login_required
@@ -707,11 +713,17 @@ def register_routes(app: Flask) -> None:
u = current_user()
entry_style = (request.form.get("entry_style") or "").strip()
note = (request.form.get("review_note") or "").strip()
allowed = set(database.ENTRY_STYLES)
with database.get_db() as conn:
trade = database.get_trade(conn, tid)
if not trade or not database.user_can_access_account(u, trade.get("account_id")):
flash("无权标注该记录", "error")
return redirect(url_for("records_page"))
# 允许清空;或保留已有旧标注值;新选必须在标准列表内
prev = (trade.get("entry_style") or "").strip()
if entry_style and entry_style not in allowed and entry_style != prev:
flash("入场形式不在可选列表中", "error")
return redirect(url_for("record_detail", tid=tid))
conn.execute(
"UPDATE trades SET entry_style=?, review_note=? WHERE id=?",
(entry_style, note, tid),