Skip to content

Fix Aroon to count bars since the highest high and lowest low - #539

Open
jayhemnani9910 wants to merge 3 commits into
cinar:masterfrom
jayhemnani9910:fix/aroon-definition
Open

jayhemnani9910 wants to merge 3 commits into
cinar:masterfrom
jayhemnani9910:fix/aroon-definition

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Nov 12, 2026 •

Copy link
Copy Markdown

Fixes #520.

Aroon now looks for the highest high and lowest low in the last Period + 1 bars, straight from high and low. On ties it counts from the most recent bar, as TA-Lib does. Aroon is built on MaxSince and MinSince, 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 skips Period bars and IdlePeriod() is now Period. The Aroon strategy shifts its actions and report columns by IdlePeriod() to match.

  • internal/talibcompat: the Aroon skip is removed. It matches TA-Lib on both the walk and the ticks datasets.
  • trend/testdata/aroon.csv and examples/trend/testdata/aroon_strategy.csv are regenerated from TA-Lib 0.8.3 AROON(high, low, 25) on each file's own inputs. The High and Low columns are unchanged.
  • The stop loss and cost basis decorator data wrap the Aroon strategy, so they are regenerated by running those decorators on the new actions.
  • TestAroonValidateDefinition now uses repeated highs and lows, so it checks the tie rule. With the old tie handling the first bar gives 33 instead of 100.
  • TestAroonCompareRust compared nothing at period 25 with 15 rows, and the aroon-rs values disagree with TA-Lib on most bars. It is replaced by TestAroonCompareTaLib: the same rows at period 5, with TA-Lib's values.
  • trend/README.md is regenerated with gomarkdoc.

Testing

The new and updated tests fail on master and pass with the change. go test -race over trend, examples and internal/talibcompat, go vet, revive and gomarkdoc all pass. Coverage of aroon.go is 100%. staticcheck v0.5.1 doesn't build with my Go version, so I didn't run it.

AI tools assisted with this contribution.

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
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@jayhemnani9910

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 12, 2026
cinar and others added 2 commits November 12, 2026 21:14
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-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.79%. Comparing base (5c05d1e) to head (3b0e28d).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Aroon counts bars since the rolling max changed, not since the highest high

3 participants