ranaroussi / qtpylib

QTPyLib, Pythonic Algorithmic Trading
http://qtpylib.io
Apache License 2.0
2.16k stars 513 forks source link

[V2 Feature Request] Optimizing Rolling Window Indicators #137

Open G8XSU opened 5 years ago

G8XSU commented 5 years ago

Regarding most of the rolling window indicators for example SMA,

Why isn't the previously calculated SMA Indicator used as an optimization similar to dynamic programming?

For e.g in SMA we only need to exclude the oldest period value in average and include the latest period value to calculate one additional point in SMA.

I see that most of the indicators are like this. While we are running in "live" mode c-lib of ta-lib is excellent choice but during back-testing Performance gain by this will be huge by saving all the redundant computation. This is specifically important, if the model and strategy is ML-based and is already resource intensive.

Basically we need to implement a python lib for indicators which re-uses its previous computations. (I checked and couldn't find something existing like this)

For e.g Gekko uses all of its previously computed indicator results in SMA, EMA, MACD, RSI etc. Let me know your thoughts on this.