fix(api): keep candle open continuity

This commit is contained in:
u1
2026-02-03 10:27:54 +01:00
parent cd4cbec7e0
commit bd88eaa3c8

View File

@@ -786,6 +786,14 @@ function fillForwardCandles(candles, { bucketSeconds, limit, nowSec }) {
if (hit) {
const c = { ...hit };
c.volume = Number.isFinite(c.volume) ? c.volume : 0;
// Keep continuity: next candle opens where previous candle closed.
// This avoids visual "gaps" when ticks are sparse.
if (prev && Number.isFinite(prev.close)) {
const prevClose = Number(prev.close);
c.open = prevClose;
c.high = Math.max(Number(c.high), prevClose, Number(c.close));
c.low = Math.min(Number(c.low), prevClose, Number(c.close));
}
out[i] = c;
prev = c;
continue;