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:
@@ -167,37 +167,6 @@ class TestHubOhlcvLib(unittest.TestCase):
|
||||
self.assertGreaterEqual(len(ex.calls), 3)
|
||||
self.assertAlmostEqual(out["bars"][-1]["close"], 3.05)
|
||||
|
||||
def test_aggregate_12h_from_1h_when_exchange_lacks_native(self):
|
||||
"""无原生 12h 时应从 1h 聚合。"""
|
||||
from hub_ohlcv_lib import TIMEFRAME_MS
|
||||
|
||||
h1 = TIMEFRAME_MS["1h"]
|
||||
h12 = TIMEFRAME_MS["12h"]
|
||||
base = (1_700_000_000_000 // h12) * h12
|
||||
one_h = [
|
||||
[base + i * h1, 100.0 + i, 101.0 + i, 99.0 + i, 100.5 + i, 10.0]
|
||||
for i in range(48)
|
||||
]
|
||||
ex = _FakeExchange(
|
||||
[one_h],
|
||||
timeframes={"1h": "1h", "4h": "4h"},
|
||||
)
|
||||
out = fetch_ohlcv_for_hub(
|
||||
symbol="BTC/USDT",
|
||||
timeframe="12h",
|
||||
since_ms=base,
|
||||
limit=4,
|
||||
normalize_symbol_input=lambda s: str(s).strip().upper(),
|
||||
normalize_exchange_symbol=lambda s: f"{s}:USDT" if ":" not in s else s,
|
||||
ensure_markets_loaded=lambda: None,
|
||||
exchange=ex,
|
||||
)
|
||||
self.assertTrue(out.get("ok"))
|
||||
bars = out.get("bars") or []
|
||||
self.assertEqual(len(bars), 4)
|
||||
self.assertTrue(bars_spacing_matches_timeframe(bars, "12h"))
|
||||
self.assertEqual(ex.calls[0]["timeframe"], "1h")
|
||||
|
||||
def test_pagination_stops_when_next_since_reaches_now(self):
|
||||
"""Gate 等:分页 since 不得越过当前时间,避免 from>to。"""
|
||||
from hub_ohlcv_lib import TIMEFRAME_MS
|
||||
@@ -230,8 +199,8 @@ class TestHubOhlcvLib(unittest.TestCase):
|
||||
from hub_ohlcv_lib import TIMEFRAME_MS
|
||||
|
||||
h1 = TIMEFRAME_MS["1h"]
|
||||
h12 = TIMEFRAME_MS["12h"]
|
||||
base = (1_700_000_000_000 // h12) * h12
|
||||
h4 = TIMEFRAME_MS["4h"]
|
||||
base = (1_700_000_000_000 // h4) * h4
|
||||
src = [
|
||||
{
|
||||
"open_time_ms": base + i * h1,
|
||||
@@ -241,11 +210,11 @@ class TestHubOhlcvLib(unittest.TestCase):
|
||||
"close": 1.5,
|
||||
"volume": 1.0,
|
||||
}
|
||||
for i in range(12)
|
||||
for i in range(4)
|
||||
]
|
||||
out = aggregate_ohlcv_bars(src, "12h")
|
||||
out = aggregate_ohlcv_bars(src, "4h")
|
||||
self.assertEqual(len(out), 1)
|
||||
self.assertEqual(out[0]["volume"], 12.0)
|
||||
self.assertEqual(out[0]["volume"], 4.0)
|
||||
self.assertEqual(out[0]["high"], 2.0)
|
||||
self.assertEqual(out[0]["low"], 0.5)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user