Repository navigation
fix(indicators): preserve signed OBV integer contributions - #912
Open
JohnDReynolds wants to merge 1 commit into
Open
JohnDReynolds wants to merge 1 commit into
JohnDReynolds wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Currently, on-balance volume (OBV) can add a large positive contribution when an unsigned volume should be subtracted. Large integer closes can also lose their direction when shifted through floating point.
This PR fixes that by preparing signed contributions before negation and comparing adjacent closes in their original dtype. Floating-point volumes retain their native accumulation behavior.
Benefit and scope: Corrects OBV values and negative threshold crossings through the Numba path, including automatic engine fallback. The change is confined to OBV preparation and regression coverage.
Validation
Regression evidence
With prices
[100, 90, 110]anduint32volumes[10, 20, 30], OBV now returns[10, -10, 20]rather than[10, 4294967286, 4294967316]. Tests also verify that large integer closes retain a real decline, alongside flat bars, output dtypes, input preservation, automatic fallback and existing floating-point parity.Checks
Notes
Output dtype rules and Rust input admission are unchanged. Existing cumulative-sum precision and range limits still apply.
AI use