Review charts: M1/M5/M15/H1 bar counts 500/200/100/50; simplify markers.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-21 17:33:18 +08:00
parent 11c14fbb21
commit e2847c90df
6 changed files with 87 additions and 125 deletions
+11 -9
View File
@@ -928,27 +928,29 @@ def register_routes(app: Flask) -> None:
flash("记录不存在或无权查看", "error")
return redirect(url_for("records_page"))
_annotate_trade_times(trade)
# 各周期不同前后窗口,避免 M1 过密、H1 过稀
# 按目标根数取足够时间窗:M1=500, M5=200, M15=100, H1=50
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
tf_pad = {
"M1": 90 * 60, # ±90 分钟
"M5": 4 * 3600, # ±4 小时
"M15": 8 * 3600, # ±8 小时
"H1": 24 * 3600, # ±1 天
# 秒/根 × 目标根数,再略留余量
tf_span = {
"M1": 500 * 60,
"M5": 200 * 5 * 60,
"M15": 100 * 15 * 60,
"H1": 50 * 3600,
}
charts = {}
for tf in ("M1", "M5", "M15", "H1"):
pad = tf_pad[tf]
span = tf_span[tf]
mid = (min(open_ts, close_ts) + max(open_ts, close_ts)) / 2.0
charts[tf] = database.get_bars(
conn,
trade["symbol"],
tf,
min(open_ts, close_ts) - pad,
max(open_ts, close_ts) + pad,
mid - span / 2.0,
mid + span / 2.0,
)
return render_template(
"record_detail.html",