From a8e80e0a158ae7fd8c8d1746511ab874518aeab9 Mon Sep 17 00:00:00 2001 From: Mukan Erkin Date: Sat, 25 Apr 2026 12:29:29 +0300 Subject: [PATCH] fix(mse): chart price precision from actual data + kline limit 1000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - priceFormat precision derived from Binance kline close string decimal count instead of hardcoded 2 — DOGE shows 0.09849 not 0.10 - kline limit 200 → 1000 to show more history from bot start Co-Authored-By: Claude Sonnet 4.6 --- src/web/bot.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/web/bot.html b/src/web/bot.html index 390c34f..1ecb0d7 100644 --- a/src/web/bot.html +++ b/src/web/bot.html @@ -488,6 +488,7 @@ function initChart() { upColor: '#2ecc71', downColor: '#e74c3c', borderUpColor: '#2ecc71', borderDownColor: '#e74c3c', wickUpColor: '#2ecc71', wickDownColor: '#e74c3c', + priceFormat: { type: 'price', precision: 8, minMove: 0.00000001 }, }); chart.subscribeCrosshairMove(p => { if (!p.seriesData || !p.seriesData.size) return; @@ -508,9 +509,19 @@ function initChart() { async function loadKlines() { const interval = TF_MAP[bot.timeframe] || '5m'; try { - const res = await fetch(`https://api.binance.com/api/v3/klines?symbol=${bot.symbol}&interval=${interval}&limit=200`); + const res = await fetch(`https://api.binance.com/api/v3/klines?symbol=${bot.symbol}&interval=${interval}&limit=1000`); const data = await res.json(); const candles = data.map(k => ({ time: Math.floor(k[0]/1000), open: parseFloat(k[1]), high: parseFloat(k[2]), low: parseFloat(k[3]), close: parseFloat(k[4]) })); + + // fiyatın ondalık basamak sayısını ilk kapanış fiyatından türet + if (candles.length) { + const sample = data[data.length - 1][4]; // son kapanış string olarak + const dotIdx = sample.indexOf('.'); + const decimals = dotIdx >= 0 ? sample.length - dotIdx - 1 : 0; + const minMove = decimals > 0 ? parseFloat('0.' + '0'.repeat(decimals - 1) + '1') : 1; + candleSeries.applyOptions({ priceFormat: { type: 'price', precision: decimals, minMove } }); + } + candleSeries.setData(candles); chart.timeScale().scrollToRealTime(); chart.timeScale().setVisibleLogicalRange({ from: candles.length - 80, to: candles.length + 5 });