Hi, is it possible/easy to implement expanding window?
Currently, indicators output null until "timeperiod" observations are reached:
import polars as pl
import polars_talib as plta
# Sample multi-ticker data
df = pl.DataFrame({
"ticker": ["AAPL", "AAPL", "AAPL", "AAPL", "AAPL", "AAPL",
"GOOG", "GOOG", "GOOG", "GOOG", "GOOG", "GOOG"],
"close": [150.0, 152.0, 151.0, 153.0, 155.0, 154.0,
2800.0, 2820.0, 2810.0, 2830.0, 2850.0, 2840.0],
})
# The actual answer - use over() for per-group computation
result = df.with_columns(
plta.sma(pl.col("close"), timeperiod=5).over("ticker").alias("sma_5")
)
print(result)
But i'd rather prefer them to use less observations and output something meaningful instead of null.
I.e., run computations over expanding window up to "timeperiod" observations, rather than waiting for strictly "timeperiod" observations.
Hi, is it possible/easy to implement expanding window?
Currently, indicators output null until "timeperiod" observations are reached:
But i'd rather prefer them to use less observations and output something meaningful instead of null.
I.e., run computations over expanding window up to "timeperiod" observations, rather than waiting for strictly "timeperiod" observations.