From c8ffc764e1bb299b9d714dcfe56f0aa02f730653 Mon Sep 17 00:00:00 2001 From: dekun Date: Mon, 8 Jun 2026 08:23:43 +0800 Subject: [PATCH] Increase default chart initial bar counts per timeframe. Load 2000 bars for 1m/5m/15m, 1000 for 1h/2h/4h, and 500 for 1d/1w on first screen instead of 300-bar chunked defaults. Co-authored-by: Cursor --- hub_ohlcv_lib.py | 10 ++++++---- manual_trading_hub/static/chart.js | 16 ++++++++-------- tests/test_hub_kline_store.py | 4 +++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/hub_ohlcv_lib.py b/hub_ohlcv_lib.py index 98ca998..7e9ee2b 100644 --- a/hub_ohlcv_lib.py +++ b/hub_ohlcv_lib.py @@ -87,10 +87,12 @@ def aggregate_ratio(display_tf: str, source_tf: str) -> int: def chart_initial_limit(timeframe: str) -> int: tf = normalize_chart_timeframe(timeframe) if tf in SMALL_DISPLAY_TFS: - return 300 - if tf == "1w": - return 150 - return 200 + return 2000 + if tf in MID_DISPLAY_TFS: + return 1000 + if tf in DAILY_PLUS_TIMEFRAMES: + return 500 + return 500 def chart_chunk_limit(timeframe: str) -> int: diff --git a/manual_trading_hub/static/chart.js b/manual_trading_hub/static/chart.js index bc8cbbe..8cf270f 100644 --- a/manual_trading_hub/static/chart.js +++ b/manual_trading_hub/static/chart.js @@ -8,14 +8,14 @@ const DEFAULT_VISIBLE_BARS = 200; const CHART_LOAD_LEFT_THRESHOLD = 25; const CHART_INITIAL_LIMITS = { - "1m": 300, - "5m": 300, - "15m": 300, - "1h": 200, - "2h": 200, - "4h": 200, - "1d": 200, - "1w": 150, + "1m": 2000, + "5m": 2000, + "15m": 2000, + "1h": 1000, + "2h": 1000, + "4h": 1000, + "1d": 500, + "1w": 500, }; const CHART_CHUNK_LIMITS = { "1m": 500, diff --git a/tests/test_hub_kline_store.py b/tests/test_hub_kline_store.py index d923ce8..2ec7b3f 100644 --- a/tests/test_hub_kline_store.py +++ b/tests/test_hub_kline_store.py @@ -39,7 +39,9 @@ class TestHubKlineStore(unittest.TestCase): self.assertEqual(bar_limit_for_timeframe("1h"), 1000) self.assertEqual(bar_limit_for_timeframe("1d"), 1000) self.assertEqual(bar_limit_for_timeframe("1w"), 500) - self.assertEqual(chart_initial_limit("5m"), 300) + self.assertEqual(chart_initial_limit("5m"), 2000) + self.assertEqual(chart_initial_limit("1h"), 1000) + self.assertEqual(chart_initial_limit("1d"), 500) def test_chart_fetch_window_exceeds_retention(self): now = int(time.time() * 1000)