-
Notifications
You must be signed in to change notification settings - Fork 693
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
Improve caching system #103
Comments
How can I prevent the StackOverflow-Error: when I use "RecursiveCachedIndicator" and call for example: " and do some other heavy math calculations, I will get a StackOverflow-Error each time and the calculation is very slow. So how can I implement a formula at least without this StackOverflow-Error. Is this because of BigDecimal under the hood? |
We shold also consider to enable a caching layer which can be disabled (disabled should be the default). |
Merging these three classes into one has some advantages and disadvantages. Pro Contra |
Some thoughts about caching: |
I have to take a deeper look into its logic. But I think it is not so easy to merge these
Why is every index calculated? At the moment nothing will be calculated if you initialize an indicator. Just for the index you call in the calculate function it will be computed (a Strategy runs over all indices, it is possible that the same index will be called many times). |
I have renamed this issue. Further informations about caching plans: |
@team172011 So if all these superclasses are merged and every indicator is derived from this common "recursive cached" superclass then indicator values would be computed from 0 (even if we want only value(1000)) I also think that current caching mechanism is quite simple and good - no hurry to change it. As I write earlier advantage of merging 3 superclasses would be simplicity and eliminating the risk of stack overflow. As a small improvement I proposed not to cache the last value. That's way it would be possible to replace the last value in underlying TimeSeries and recompute last value in indicator. It's also just an idea, not something very urgent. |
@abzif now i understand, you are right. I also agree in not caching the last value. It is a crucial requirement that should be implemented as soon as possible |
The whole caching layer is actually only needed because of low calculation performance of big decimal, or? |
I also think about to change the "setMaximumBar(int i)" concept of the time series. In the prototype implementation once can add an initial capacity to the time series during the initialization. If the bars size reach this capacity the lists will do a left shift (remove the oldest bar from beginning and insert the new bar to the end). If a shift happens, the indicators have to be notified and can also do this shift to update their cache. |
I agree that caching layer may be bottleneck for simple calculations. But it is necessary for "self-dependent" indicators (EMA, KAMA, ZLEMA etc) to avoid stack overflow. You also don't want to endlessly recompute all prior values if you want value(1000). So it cannot be completely eliminated. |
@team172011 Actually it is already working like this (although without notification). See: https://github.com/ta4j/ta4j/blob/master/ta4j-core/src/main/java/org/ta4j/core/indicators/CachedIndicator.java#L133 By the way, for |
I think the caching system is fine and do not know what to enhance, except
|
Maybe we should merge these abstract classes. I dont know exactly, when to use "RecursiveCachedIndicator" and when to use "CachedIndicator".
As described in recursiveCachedIndicator:
Looks for me like a workaround because of the caching layer..hence we should improve "CachedIndicator" to make the need for this "workaround" obsolete.
As the caching layer should also be improved, we could remove the "RecursiveCachedIndicator ". Maybe we can merge it all to one central point, so all indicators need to extend only one, call it "AbstractIndicator" or "BaseIndicator".
The text was updated successfully, but these errors were encountered: