Skip to content

fix(indicators): preserve signed OBV integer contributions - #912

Open
JohnDReynolds wants to merge 1 commit into
polakowo:masterfrom
JohnDReynolds:fix/indicators/obv-integer-contributions
Open

JohnDReynolds wants to merge 1 commit into
polakowo:masterfrom
JohnDReynolds:fix/indicators/obv-integer-contributions

Conversation

@JohnDReynolds

Copy link
Copy Markdown
Contributor

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] and uint32 volumes [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

  • Focused OBV checks: 53 passed.
  • Core OBV regressions with Rust availability disabled: 31 passed.
  • Full Python suite: 1,947 passed, 2 skipped.
  • A 10,000-bar, 20-asset public workflow showed no material timing or peak-memory concern.

Notes

Output dtype rules and Rust input admission are unchanged. Existing cumulative-sum precision and range limits still apply.

AI use

  • Tools and models: OpenAI Codex, using GPT-6.1 Sol.
  • What AI did: Used proprietary workflows tailored to this repository to investigate the integer arithmetic, implement the correction and regression tests, verify affected modules and engine behavior, measure elapsed time and peak memory, and prepare this description.
  • Human review before submission: I personally reviewed all changes, weighing the benefits against complexity and maintenance burden. My review draws on 40 years of software development experience in the investment management industry.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant