Repository navigation
Fix Aroon to count bars since the highest high and lowest low - #539
Open
jayhemnani9910 wants to merge 3 commits into
Open
jayhemnani9910 wants to merge 3 commits into
jayhemnani9910 wants to merge 3 commits into
Conversation
Aroon fed MovingMax(high) and MovingMin(low) into MaxSince and MinSince, so it counted how long the rolling value had been unchanged rather than how many bars ago the extreme was. It now looks for the highest high and lowest low in the last Period + 1 bars, counting from the most recent one on ties, as TA-Lib does. IdlePeriod becomes Period. The expected Aroon values and the Aroon strategy actions come from TA-Lib 0.8.3; the stop loss and cost basis decorator data are regenerated from those actions. The talibcompat skip for Aroon is removed. Fixes cinar#520
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
When the maximum or minimum occurs more than once in the window, the most recent one now counts, as in TA-Lib. NaN values are never taken as the extreme, and a window of only NaN values yields NaN. The position of the extreme is kept between values, and the window is scanned again only when that position leaves it, so each value costs amortized O(1) instead of O(w). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Aroon now uses the shared MaxSince and MinSince helpers instead of its own window scan. Its lines are no longer rounded to whole numbers, and they are computed as (Period - Bars Since) * (100 / Period), in the same order as TA-Lib. A Period below 1 produces no output, as it did before. - internal/talibcompat: adds AROON(high, low, 14), a period where 100 / period is not a whole number. - TestAroonValidateDefinition expects 66.67 and 33.33 at period 3, and no longer names aroon-rs as its source. - TestAroonInvalidPeriod and TestAroonNaN are added. - The doc comment states the formula in terms of Period and the Period + 1 bar window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #539 +/- ##
==========================================
- Coverage 91.83% 91.79% -0.05%
==========================================
Files 240 241 +1
Lines 7843 7857 +14
==========================================
+ Hits 7203 7212 +9
- Misses 548 551 +3
- Partials 92 94 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #520.
Aroon now looks for the highest high and lowest low in the last
Period + 1bars, straight from high and low. On ties it counts from the most recent bar, as TA-Lib does. Aroon is built onMaxSinceandMinSince, so they now use the same tie rule (and skip NaN); their tests and the decorator strategy test data that depend on them are updated. If you'd rather keep the helpers as they were, I can move the tie handling into Aroon. The window emits while it fills, so the output skipsPeriodbars andIdlePeriod()is nowPeriod. The Aroon strategy shifts its actions and report columns byIdlePeriod()to match.internal/talibcompat: the Aroon skip is removed. It matches TA-Lib on both the walk and the ticks datasets.trend/testdata/aroon.csvandexamples/trend/testdata/aroon_strategy.csvare regenerated from TA-Lib 0.8.3AROON(high, low, 25)on each file's own inputs. The High and Low columns are unchanged.TestAroonValidateDefinitionnow uses repeated highs and lows, so it checks the tie rule. With the old tie handling the first bar gives 33 instead of 100.TestAroonCompareRustcompared nothing at period 25 with 15 rows, and the aroon-rs values disagree with TA-Lib on most bars. It is replaced byTestAroonCompareTaLib: the same rows at period 5, with TA-Lib's values.trend/README.mdis regenerated with gomarkdoc.Testing
The new and updated tests fail on master and pass with the change.
go test -raceover trend, examples and internal/talibcompat,go vet, revive and gomarkdoc all pass. Coverage ofaroon.gois 100%. staticcheck v0.5.1 doesn't build with my Go version, so I didn't run it.AI tools assisted with this contribution.