uniVocity / univocity-trader

open-source trading framework for java, supports backtesting and live trading with exchanges
577 stars 140 forks source link

Cache indicator values #2

Closed jbax closed 4 years ago

jbax commented 4 years ago

As suggested in issue #1:

One thing you may want to add in the future for better performance is a caching mechanism for your indicators to reduce repeated computation time. Here's a Java TA library which does this as an example:

https://github.com/ta4j/ta4j

jbax commented 4 years ago

Closing as it may decrease overall performance and add complexity for negative gains. The code required to reuse the values adds a ton of complexity without major gains in performance (in fact, there's more potential of losing performance than gaining any). Indicators with the same time interval and parameters are almost never present. This is even less relevant when indicators that happen to use the same settings use longer intervals (> 5 minutes), as the calculations are pretty cheap. No work needed here at the moment until someone highlights an actual performance bottleneck.

SteveH2003 commented 4 years ago
Webpage not available

  body { margin-top: 0px; padding-top: 0px;  } /* Used for additional styles, e.g. direction */
  h2   { margin-top: 5px; padding-top: 0px; }

When I create an indicator in NinjaTrader, the caching code is auto-generated. I don't know if it's only useful in charting (for redrawing) or the way they cache is better than what ta4j is doing.  I can send you the C# code for a moving avg so you can make that determination. I doubt a professional package like that is willing to take a performance hit.Steve
jbax commented 4 years ago

This is CSS, and maybe what you see concerns charting. Not relevant to the calculation of the indicator value