Repository navigation
fix: guard indicator params and WASM kernels - #110
Merged
Merged
Conversation
Clamp indicator params at the API, ignore non-finite indicator outputs when autoscaling, and return NaN from sma/ema when period is below 1 instead of trapping. visibleMinMax skips the SIMD kernel on non-finite windows. Co-authored-by: Joe Blau <joeblau@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #97
Closes #98
Closes #99
Closes #100
Behavior
addIndicator,updateIndicator, constructorconfig.indicators, andupdateConfig({ indicators })drop a non-finite param back to that input's default, then clamp to the declaredmin/maxand roundintegerinputs, the same way the indicators dialog does. Length helpers that usedMath.max(1, Math.floor(...))now uselengthParam, so aNaNlength is the default length instead ofNaN.seriesMinMaxusesNumber.isFinitewhere it used to skip onlyNaN, and non-finite levels are ignored. A custom indicator that emitsInfinityno longer collapses the main scale to 0–1.WasmKernels.smaandemareturn an all-NaNarray whenperiodfloors to below 1, includingNaNandInfinity. They no longer write before the destination and trap. The parity test no longer expects that trap.minmaxis documented: oneNaNmakes both resultsNaN.visibleMinMaxuses the kernel only when every high and low in the window is finite, and otherwise uses the scalar loop that skips non-finite prices. The chart render path still passesnulland does not scan.Tests
1916 tests passed. Coverage is 100% line, branch, and function.
bun run typecheck:tscpassed.Benchmarks
node bench/suite/run.mjs --samples=7 --sizes=100000, Node 24, median ms/op, back to back.Sorted
setDatais unchanged (0.6487 ms vs 0.6488 ms). The render medians move within the noise of this run; the 5000-bar redraw minimums were 5.69 ms before and 6.97 ms after.