修复一些bug
This commit is contained in:
@@ -39,6 +39,8 @@ from history_window_lib import (
|
||||
PRESET_UTC_LAST24H,
|
||||
PRESET_UTC_LAST7D,
|
||||
PRESET_UTC_TODAY,
|
||||
list_window_redirect_query,
|
||||
resolve_list_window,
|
||||
resolve_window,
|
||||
utc_window_to_bj_sql_strings,
|
||||
)
|
||||
@@ -884,6 +886,7 @@ ENTRY_REASON_OPTIONS = (
|
||||
"趋势多头:小分歧低吸入场(左侧),确认条件:二次探底",
|
||||
"趋势空头:小分歧高吸入场(左侧),确认条件:二次探顶",
|
||||
"波段单:5m顺势突破,确认条件:2根k线+成交量放大+4h同向+日成交量前20",
|
||||
"趋势回调",
|
||||
)
|
||||
# 复盘表单「其他」选项的 value(非入库值;自定义文本走 entry_reason_custom)
|
||||
ENTRY_REASON_OTHER = "__OTHER__"
|
||||
@@ -898,7 +901,7 @@ def normalize_entry_reason(raw, custom_text=None):
|
||||
|
||||
|
||||
def entry_reason_valid_for_storage(s):
|
||||
"""允许五种固定整句、或自定义短文本(不含未解析的 __OTHER__ 占位)。"""
|
||||
"""允许固定开仓类型选项、或自定义短文本(不含未解析的 __OTHER__ 占位)。"""
|
||||
t = str(s or "").strip()
|
||||
if not t:
|
||||
return True
|
||||
@@ -946,6 +949,7 @@ def ai_extract_journal_from_image(image_b64):
|
||||
- 趋势多头:小分歧低吸入场(左侧),确认条件:二次探底
|
||||
- 趋势空头:小分歧高吸入场(左侧),确认条件:二次探顶
|
||||
- 波段单:5m顺势突破,确认条件:2根k线+成交量放大+4h同向+日成交量前20
|
||||
- 趋势回调
|
||||
6) early_exit_trigger 只能从下列取值中选一个(无法识别则填空字符串):保本止盈、移动止盈、手动平仓、止损、其他。
|
||||
7) 若触发为「手动平仓」,early_exit_note 必须写出图中可见的补充说明;其他触发类型 early_exit_note 留空。
|
||||
8) 若图中有无法归类的离场说明原文,可放进 early_exit_note,early_exit_trigger 填「其他」或留空。
|
||||
@@ -3567,7 +3571,12 @@ def trend_plan_history_status_label(status):
|
||||
|
||||
|
||||
def _list_window_from_request():
|
||||
return resolve_window(request.args, default_preset=PRESET_UTC_TODAY)
|
||||
return resolve_list_window(request.args, session, default_preset=PRESET_UTC_TODAY)
|
||||
|
||||
|
||||
def _redirect_records():
|
||||
qs = list_window_redirect_query(session)
|
||||
return redirect(f"/records?{qs}" if qs else "/records")
|
||||
|
||||
|
||||
def calc_trend_manual_breakeven_stop(direction, entry_price, offset_pct=None):
|
||||
@@ -6700,7 +6709,7 @@ def add_miss():
|
||||
conn.commit()
|
||||
conn.close()
|
||||
flash("已记录错过机会")
|
||||
return redirect("/records")
|
||||
return _redirect_records()
|
||||
|
||||
|
||||
@app.route("/add_journal", methods=["POST"])
|
||||
@@ -6710,15 +6719,15 @@ def add_journal():
|
||||
entry_reason_norm = normalize_entry_reason(d.get("entry_reason"), d.get("entry_reason_custom"))
|
||||
if not entry_reason_norm:
|
||||
flash("请选择开仓类型;若选「其他」请在下方填写自定义说明")
|
||||
return redirect("/records")
|
||||
return _redirect_records()
|
||||
early_exit_trigger = normalize_early_exit_trigger(d.get("early_exit_trigger"))
|
||||
early_exit_note = str(d.get("early_exit_note") or "").strip()
|
||||
if not early_exit_trigger:
|
||||
flash("请选择离场触发")
|
||||
return redirect("/records")
|
||||
return _redirect_records()
|
||||
if early_exit_trigger == "手动平仓" and not early_exit_note:
|
||||
flash("手工平仓必须填写补充说明")
|
||||
return redirect("/records")
|
||||
return _redirect_records()
|
||||
if early_exit_trigger != "手动平仓":
|
||||
early_exit_note = ""
|
||||
# 兼容字段:仅「手工平仓」记为「主观提前」语义下的「是」
|
||||
@@ -6816,14 +6825,20 @@ def add_journal():
|
||||
flash(f"交易复盘记录已保存。{chart_msg}")
|
||||
else:
|
||||
flash("交易复盘记录已保存")
|
||||
return redirect("/records")
|
||||
return _redirect_records()
|
||||
|
||||
|
||||
@app.route("/api/journals")
|
||||
@login_required
|
||||
def api_journals():
|
||||
win = _list_window_from_request()
|
||||
start_bj, end_bj = utc_window_to_bj_sql_strings(win["start_utc"], win["end_utc"], APP_TZ)
|
||||
conn = get_db()
|
||||
rows = conn.execute("SELECT * FROM journal_entries ORDER BY created_at DESC").fetchall()
|
||||
rows = conn.execute(
|
||||
"SELECT * FROM journal_entries WHERE COALESCE(close_datetime, created_at, open_datetime) >= ? "
|
||||
"AND COALESCE(close_datetime, created_at, open_datetime) <= ? ORDER BY created_at DESC LIMIT 500",
|
||||
(start_bj, end_bj),
|
||||
).fetchall()
|
||||
conn.close()
|
||||
result = []
|
||||
for r in rows:
|
||||
@@ -6871,8 +6886,13 @@ def delete_journal(jid):
|
||||
@app.route("/api/reviews")
|
||||
@login_required
|
||||
def api_reviews():
|
||||
win = _list_window_from_request()
|
||||
start_bj, end_bj = utc_window_to_bj_sql_strings(win["start_utc"], win["end_utc"], APP_TZ)
|
||||
conn = get_db()
|
||||
rows = conn.execute("SELECT * FROM ai_reviews ORDER BY created_at DESC").fetchall()
|
||||
rows = conn.execute(
|
||||
"SELECT * FROM ai_reviews WHERE created_at >= ? AND created_at <= ? ORDER BY created_at DESC LIMIT 200",
|
||||
(start_bj, end_bj),
|
||||
).fetchall()
|
||||
conn.close()
|
||||
return jsonify([row_to_dict(r) for r in rows])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user