Add day amplitude metric (high-low range and percent).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -811,6 +811,7 @@ class OrderApp(tk.Tk):
|
||||
self._metric_box(metrics, "open", "开盘价")
|
||||
self._metric_box(metrics, "high", "最高价")
|
||||
self._metric_box(metrics, "low", "最低价")
|
||||
self._metric_box(metrics, "range", "振幅")
|
||||
self.lbl_day_ohlc = tk.Label(
|
||||
q, text="", bg=COLOR_CARD, fg=COLOR_MUTED, font=("Microsoft YaHei UI", 10),
|
||||
)
|
||||
@@ -1484,6 +1485,14 @@ class OrderApp(tk.Tk):
|
||||
self._set_metric("open", f"{day['open']:.{digits}f}")
|
||||
self._set_metric("high", f"{day['high']:.{digits}f}", COLOR_PROFIT)
|
||||
self._set_metric("low", f"{day['low']:.{digits}f}", COLOR_LOSS)
|
||||
amp = float(day["high"]) - float(day["low"])
|
||||
base = float(day["open"]) or float(day["low"]) or 1.0
|
||||
amp_pct = (amp / base) * 100.0 if base else 0.0
|
||||
self._set_metric(
|
||||
"range",
|
||||
f"{amp:.{digits}f} ({amp_pct:.2f}%)",
|
||||
COLOR_ACCENT,
|
||||
)
|
||||
ot = day["open_time"].strftime("%m-%d %H:%M")
|
||||
tag = "交易中" if day["market_open"] else "休市 · 显示最近交易日"
|
||||
self.lbl_day_ohlc.configure(text=f"{tag} · 日线开盘 {ot}")
|
||||
@@ -1492,6 +1501,7 @@ class OrderApp(tk.Tk):
|
||||
self._set_metric("open", "--")
|
||||
self._set_metric("high", "--")
|
||||
self._set_metric("low", "--")
|
||||
self._set_metric("range", "--")
|
||||
self.lbl_day_ohlc.configure(text="日线暂不可用(休市也会尽量显示最近交易日)")
|
||||
try:
|
||||
self._refresh_today_stats(symbol)
|
||||
@@ -1513,6 +1523,14 @@ class OrderApp(tk.Tk):
|
||||
self._set_metric("open", f"{day['open']:.{digits}f}")
|
||||
self._set_metric("high", f"{day['high']:.{digits}f}", COLOR_PROFIT)
|
||||
self._set_metric("low", f"{day['low']:.{digits}f}", COLOR_LOSS)
|
||||
amp = float(day["high"]) - float(day["low"])
|
||||
base = float(day["open"]) or float(day["low"]) or 1.0
|
||||
amp_pct = (amp / base) * 100.0 if base else 0.0
|
||||
self._set_metric(
|
||||
"range",
|
||||
f"{amp:.{digits}f} ({amp_pct:.2f}%)",
|
||||
COLOR_ACCENT,
|
||||
)
|
||||
self.lbl_session.configure(text="时段 休市", bg="#3a2820", fg=COLOR_WARN)
|
||||
self.lbl_day_ohlc.configure(text="休市 · 显示最近交易日日线")
|
||||
except Exception:
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user