fix(ClusterStatistic): correct max value calculations in visible-proportion mode#168
Open
AlbertoAmadorBelchistim wants to merge 2 commits into
Conversation
…n mode In CreateMaxValues, the VisibleProportion branch was accumulating maxBid from candle.Ask instead of candle.Bid. The non-VisibleProportion branch (_maxBid in OnCalculate) reads candle.Bid correctly, which confirms this is a copy-paste typo. When the user enables Visible Proportion on a market with imbalanced Ask/Bid distribution, the resulting rate fed to GetBrush produces incorrect color intensity for the Bid row, since the row is being normalised against Ask volumes.
…ion maxDelta In CreateMaxValues, the VisibleProportion branch was computing maxDelta from the signed candle.Delta. The non-VisibleProportion branch uses Math.Abs(candle.Delta) (see _maxDelta accumulation), and GetRate for DataType.Delta also feeds Math.Abs(candle.Delta) as the value to normalise. When every visible bar carries a negative delta, the signed Math.Max keeps maxDelta at its 0m initialiser. GetRate then hits the maxValue == 0 fallback and returns the constant 10, flattening the gradient on the Delta row. Switching to Math.Abs aligns the two branches and restores the gradient.
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.
Summary
Two copy-paste bugs in
CreateMaxValuesproduce incorrect color intensity on the cluster statistic table when the user enablesVisible Proportion. The non-VisibleProportion branch of the same method handles both cases correctly, which is what made these stand out.
Bugs fixed
1.
maxBidreads fromcandle.AskThe non-VisibleProportion path (
_maxBidinOnCalculate) readscandle.Bidcorrectly. With this typo, the Bid row's rate isnormalised against Ask volumes, so on instruments with imbalanced Ask/Bid distribution the Bid column shows the wrong gradient.
2.
maxDeltadoes not useMath.AbsThe non-VisibleProportion path uses
Math.Max(Math.Abs(candle.Delta), _maxDelta), andGetRate(DataType.Delta, …)feedsMath.Abs(candle.Delta)as the value to normalise. When every visible bar has a negative delta, the signedMath.MaxkeepsmaxDeltaat its0minitialiser;GetRatethen hits themaxValue == 0fallback (return 10) and flattens the gradient on the Delta row.Repro
Risk
Minimal. Both changes are localised to the VisibleProportion branch of
CreateMaxValuesand align it with the existing global-mode behaviour. No public API changes, no new allocations, no flavor impact.Not in this PR
While reviewing the file I spotted a handful of additional findings (missing
OnDispose, asymmetrici == 0guard in the same loop,Durationformatting withoutInvariantCulture, stale per-session last-alert values whenSessionCumModechanges, minor whitespace).None of them affect correctness in the same direct way as the two fixes above and they touch unrelated code paths, so I'm keeping this PR focused and will open a follow-up PR for the rest.