Clean up review charts: crop windows, simplify entry/exit markers.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+13
-5
@@ -928,19 +928,27 @@ def register_routes(app: Flask) -> None:
|
||||
flash("记录不存在或无权查看", "error")
|
||||
return redirect(url_for("records_page"))
|
||||
_annotate_trade_times(trade)
|
||||
# 以开仓~平仓为中心取窗口,保证入场/出场都在图内
|
||||
# 各周期不同前后窗口,避免 M1 过密、H1 过稀
|
||||
open_ts = float(
|
||||
trade.get("open_time") or trade.get("created_at") or database.now()
|
||||
)
|
||||
close_raw = trade.get("close_time")
|
||||
close_ts = float(close_raw) if close_raw not in (None, "") else open_ts
|
||||
pad = 3600 * 3
|
||||
start_ts = min(open_ts, close_ts) - pad
|
||||
end_ts = max(open_ts, close_ts) + pad
|
||||
tf_pad = {
|
||||
"M1": 90 * 60, # ±90 分钟
|
||||
"M5": 4 * 3600, # ±4 小时
|
||||
"M15": 8 * 3600, # ±8 小时
|
||||
"H1": 24 * 3600, # ±1 天
|
||||
}
|
||||
charts = {}
|
||||
for tf in ("M1", "M5", "M15", "H1"):
|
||||
pad = tf_pad[tf]
|
||||
charts[tf] = database.get_bars(
|
||||
conn, trade["symbol"], tf, start_ts, end_ts
|
||||
conn,
|
||||
trade["symbol"],
|
||||
tf,
|
||||
min(open_ts, close_ts) - pad,
|
||||
max(open_ts, close_ts) + pad,
|
||||
)
|
||||
return render_template(
|
||||
"record_detail.html",
|
||||
|
||||
Reference in New Issue
Block a user