fix(hub): 修复币安行情区 unexpected base 价格精度
normalize_price_tick 对齐 tick 为 10^-n;chart.js 使用整数 base 并在 applyOptions 失败时回退安全 priceFormat。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -7,6 +7,7 @@ from hub_ohlcv_lib import (
|
||||
aggregate_ohlcv_bars,
|
||||
bars_spacing_matches_timeframe,
|
||||
fetch_ohlcv_for_hub,
|
||||
normalize_price_tick,
|
||||
)
|
||||
|
||||
|
||||
@@ -30,6 +31,11 @@ class _FakeExchange:
|
||||
|
||||
|
||||
class TestHubOhlcvLib(unittest.TestCase):
|
||||
def test_normalize_price_tick_snaps_powers_of_ten(self):
|
||||
self.assertAlmostEqual(normalize_price_tick(0.00001), 0.00001)
|
||||
self.assertAlmostEqual(normalize_price_tick(0.001), 0.001)
|
||||
self.assertIsNone(normalize_price_tick(0))
|
||||
|
||||
def test_price_tick_from_decimal_precision(self):
|
||||
class _Ex:
|
||||
markets = {"BTC/USDT:USDT": {"precision": {"price": 2}, "info": {}, "limits": {}}}
|
||||
|
||||
Reference in New Issue
Block a user