fix(api): keep candle open continuity
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user