Repository navigation
feat: add On-Balance Volume (OBV) (#32) - #209
Merged
Merged
Conversation
Owner
|
Please help to resolve the conflict. |
Contributor
Author
|
Conflicts fixed! Rebased onto latest master, all tests & lint pass cleanly. Plz lmk if any changes are needed |
Owner
|
Thanks for the contribution. |
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.
Resolves #32.
Summary
This PR adds support for On-Balance Volume (OBV) as a first-class technical indicator in
StockDataFrame.Features
On-Balance Volume (OBV):
df['obv']as a first-class indicator column.np.diff,np.sign,np.cumsum):OBV[0] = 0.0OBV[t] = OBV[t-1] + sign(Close[t] - Close[t-1]) * Volume[t]StockDataFrame.obv(close, volume).df['obv_10_sma'],df['obv_20_ema'],df['obv_xu_obv_20_ema']).Handler Registration:
("obv",): self._get_obvinself.handlerfor exact membership lookup and zero substring collision.Verification & Documentation
test.py:test_obv: Verified against 30-day stock data step-by-step benchmark and moving average calculation (obv_5_sma).test_obv_edge_cases: Verified edge cases (empty series, single-element, flat prices, hand-crafted benchmark verification).README.mdSummary table, Introduction list, and Volume section with formula and usage examples.flake8 stockstats.py test.pypassed with 0 errors.