Emit equity candles on schedule to avoid stalled charts

This commit is contained in:
dirtydishes 2026-01-10 16:08:23 -05:00
parent 980bb4f1b1
commit 9edf8fcbc5
3 changed files with 41 additions and 0 deletions

View file

@ -233,6 +233,18 @@ export class CandleAggregator {
return { emitted, droppedLate };
}
flushExpired(now: number): EquityCandle[] {
const watermark = Math.max(0, Math.floor(now) - this.maxLateMs);
const emitted: EquityCandle[] = [];
for (const state of this.stateByKey.values()) {
state.lastTsSeen = Math.max(state.lastTsSeen, watermark);
emitted.push(...flushState(state, watermark));
}
return emitted;
}
drain(): EquityCandle[] {
const emitted: EquityCandle[] = [];