Skip to content

fix: validate candles at ingestion - #106

Merged
cursor[bot] merged 1 commit into
mainfrom
cursor/candle-ingestion-0692
Nov 10, 2026
Merged

cursor[bot] merged 1 commit into
mainfrom
cursor/candle-ingestion-0692

Conversation

@joeblau

@joeblau joeblau commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #88
Closes #89
Closes #90
Closes #91
Closes #92

Behavior

Validation runs only when data enters the chart: setData, appendData, prependData, constructor config.data, and updateConfig({ data }). The datafeed's normalizeCandles uses the same rules. Nothing in the frame loop changed.

Tests

1905 tests passed. scripts/check-coverage.mjs reports 100% line, branch, and function coverage. bun run typecheck:tsc and bun run check:invariants passed.

Benchmarks

node bench/suite/run.mjs --samples=7 --sizes=100000, Node 24, median ms/op.

The first cut scanned and copied, so sorted setData went from 0.8122 ms to 0.9959 ms. #108 stores a valid array by reference after one pass:

Case Before This PR #108
100000 setData sorted 1.0430 1.2069 0.6442

Valid setData is faster than before the validation (0.6442 vs 1.0430 in the same back-to-back run; minimums 0.7880 ms and 0.6145 ms). Overhead on valid data is under 5%.

Open in Web Open in Cursor 

Drop non-finite OHLC, keep the last row for each time, expand high/low to cover the body, clamp negative volume, and warn once when a timestamp looks like milliseconds.

Co-authored-by: Joe Blau <joeblau@users.noreply.github.com>
@cursor
cursor Bot merged commit 0bb2506 into main Nov 10, 2026
8 checks passed
@cursor
cursor Bot deleted the cursor/candle-ingestion-0692 branch November 10, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants