New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented partial sum cache for SMAIndicator #1140
Conversation
Test on real data: After: |
ta4j-core/src/main/java/org/ta4j/core/indicators/SMAIndicator.java
Outdated
Show resolved
Hide resolved
Should provide a lot of value as this is one of the most commonly used indicators. Does this work as expected on a moving bar series? |
I will add edge case tests, to prove functionality. |
Umm, what is expected behavior for moving series? If I add following test: @Test
public void usingBarCount3UsingClosePriceMovingSerie() {
data.setMaximumBarCount(13);
data.addBar(new MockBar(5., numFunction));
Indicator<Num> indicator = getIndicator(new ClosePriceIndicator(data), 3);
assertNumEquals((0d + 0d + 2d) / 1, indicator.getValue(data.getBeginIndex() + 0));
assertNumEquals((0d + 2d + 3d) / 2, indicator.getValue(data.getBeginIndex() + 1));
assertNumEquals((2d + 3d + 4d) / 3, indicator.getValue(data.getBeginIndex() + 2));
assertNumEquals((3d + 4d + 3d) / 3, indicator.getValue(data.getBeginIndex() + 3));
} It fails on second assert (0d + 2d + 3d) / 2 even with previous implementation.
data.getBeginIndex() + 0 returns bar at index 0 because i - removedBars < 0; It seems unstable bars are really unstable and should not be tested? |
Discovered RunningTotalIndicator. I may use this indicator as partialSum and optimize RunningTotalIndicator. |
And now I have discovered PreviousValueIndicator. I think I may combine them too. |
Nope with indexes. |
Yes, you'll want to handle unstable indexes as unstable and assert accordingly. |
@sgflt please run the formatter ( |
@sgflt I recently cut the 0.16 release and started 0.17. Can you update your CHANGELOG entry accordingly? Thanks. |
- longer barSeries may benefit from reusage of precomputed partial sums - random access fallbacks to slowPath
0ab5eb6
to
f2213c6
Compare
Done |
Fixes #1139.
Performance of partial sums.
Changes proposed in this pull request:
longer barSeries benefits from reusage of precomputed partial sums
random access fallbacks to slowPath
added an entry with related ticket number(s) to the unreleased section of
CHANGES.md