Remove 12h timeframe and stabilize chart wheel zoom.

Drop 12h from market chart options and storage, and avoid left-pan reload and tail refresh from resetting the viewport while zooming.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-08 07:54:37 +08:00
parent 4afea6bb97
commit 3ac854d74c
5 changed files with 50 additions and 66 deletions
+5 -10
View File
@@ -15,7 +15,6 @@ CHART_TIMEFRAMES = frozenset(
"1h",
"2h",
"4h",
"12h",
"1d",
"1w",
}
@@ -27,15 +26,14 @@ CHART_TIMEFRAME_ORDER = (
"1h",
"2h",
"4h",
"12h",
"1d",
"1w",
)
DAILY_PLUS_TIMEFRAMES = frozenset({"1d", "1w"})
# 入库 / 同步真源(交易所拉取)
STORED_TIMEFRAMES = frozenset({"1m", "5m", "1h", "12h", "1d", "1w"})
PERMANENT_STORED_TIMEFRAMES = frozenset({"12h", "1d", "1w"})
STORED_TIMEFRAMES = frozenset({"1m", "5m", "1h", "1d", "1w"})
PERMANENT_STORED_TIMEFRAMES = frozenset({"1d", "1w"})
YEAR_ROLLING_STORED = frozenset({"5m", "1h"})
# 展示周期 → 本地聚合源(不落库)
@@ -52,10 +50,8 @@ HUB_KLINE_1M_MAX_BARS = max(1000, int(os.getenv("HUB_KLINE_1M_MAX_BARS", "10000"
HUB_KLINE_5M_1H_RETENTION_DAYS = max(30, int(os.getenv("HUB_KLINE_5M_1H_RETENTION_DAYS", "365")))
HUB_KLINE_SEED_BARS = max(100, int(os.getenv("HUB_KLINE_SEED_BARS", "500")))
# 部分交易所 ccxt 无原生 12h,或原生 K 线间隔异常时从 1h 聚合(仅远程拉取 fallback
OHLCV_AGGREGATE_FROM: dict[str, str] = {
"12h": "1h",
}
# 交易所无原生周期时的远程拉取 fallback(行情区当前无映射
OHLCV_AGGREGATE_FROM: dict[str, str] = {}
TIMEFRAME_MS: dict[str, int] = {
"1m": 60_000,
@@ -126,7 +122,7 @@ def bar_limit_for_timeframe(timeframe: str) -> int:
def storage_retention_days(storage_tf: str) -> int | None:
"""None 表示不按天截断(1m 按根数;12h/1d/1w 永久)。"""
"""None 表示不按天截断(1m 按根数;1d/1w 永久)。"""
tf = normalize_chart_timeframe(storage_tf)
if tf in YEAR_ROLLING_STORED:
return HUB_KLINE_5M_1H_RETENTION_DAYS
@@ -159,7 +155,6 @@ def retention_policy_meta() -> dict[str, Any]:
"1m": {"mode": "bars", "max_bars": HUB_KLINE_1M_MAX_BARS},
"5m": {"mode": "days", "days": HUB_KLINE_5M_1H_RETENTION_DAYS},
"1h": {"mode": "days", "days": HUB_KLINE_5M_1H_RETENTION_DAYS},
"12h": {"mode": "permanent"},
"1d": {"mode": "permanent"},
"1w": {"mode": "permanent"},
"aggregate_from": dict(CHART_DISPLAY_AGGREGATE_FROM),