ta-lib-python icon indicating copy to clipboard operation
ta-lib-python copied to clipboard

SMA producing NaNs

Open Jark5455 opened this issue 2 years ago • 2 comments

Hello, it appears that with SMA, even if only a few input values are NaNs, ta-libs entire output comes out as NaN. I don't believe this is intended behavior, because even where there is a valid series of values where the SMA can be calculated, NaN values are being returned.

Jark5455 avatar Jun 27 '23 22:06 Jark5455

Intended behavior that’s how the underlying library works. Maybe not desired but many libraries like pandas provide a fillna() method that you can determine how to deal with NaNs in your data set. On Jun 27, 2023, at 2:37 PM, Jark @.***> wrote: Hello, it appears that with SMA, even if only a few input values are NaNs, ta-libs entire output comes out as NaN. I don't believe this is intended behavior, because even where there is a valid series of values where the SMA can be calculated, NaN values are being returned.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

mrjbq7 avatar Jun 27 '23 22:06 mrjbq7

Is it possible to have TA-Lib just ignore NaNs in calculations? For example, if a period was [Nan, 0, 1, 2, 3] it would just remove Nan from the calculation and return 6 / 5. Or is there some sort of SIMD / Vectorization limitation that is preventing this?

Jark5455 avatar Jun 27 '23 23:06 Jark5455