Open gucasbrg opened 1 year ago
Yes, for the indicators that have memory, giving them more past data points to look at result in a “more accurate” indicator. The streaming api looks at a minimal number to calculate, so it’s faster. I wonder if there is a way to tell it to use all available data points but only calculate one value, it was not able to do that when I looked at it before. On Jun 27, 2023, at 5:10 AM, gucasbrg @.***> wrote: import talib as ta from talib import stream as ta_stream close = np.random.random(100) output = ta.RSI(close, timeperiod=period) latest = ta_stream.RSI(close, timeperiod=period) print(output) print(latest) print(output[-1] - latest)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
In the simplest case (SMA) a (truly) streaming api keeps the intermediate value of the sum of the window. When a new value arrives, it subtracts the last element, and adds the new one and returns the mean. (PREV_SUM - tail + head) / length
.
This is why you need the intermediate state like in https://github.com/trufanov-nok/ta-lib-rt
All the indicators that use some kind of recursion need an intermediate state from which to compute the latest value, and this is not generalizable into an api, it needs adhoc implementations for each indicators
Once we start maintaining TA-Lib C library, this would be an interesting PR to work on.
On Jul 10, 2023, at 11:46 PM, Francesco Giannelli @.***> wrote:
In the simplest case (SMA) a (truly) streaming api keeps the intermediate value of the sum of the window. When a new value arrives, it subtracts the last element, and adds the new one and returns the mean. (PREV_SUM - tail + head) / length. This is why you need the intermediate state like in https://github.com/trufanov-nok/ta-lib-rt All the indicators that use some kind of recursion need an intermediate state from which to compute the latest value, and this is not generalizable into an api, it needs adhoc implementations for each indicators
— Reply to this email directly, view it on GitHub https://github.com/TA-Lib/ta-lib-python/issues/600#issuecomment-1630242299, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A6TOOBFHW43UA3WJELXPTZD3ANCNFSM6AAAAAAZVSTPLA. You are receiving this because you commented.