business-science / pytimetk

Time series easier, faster, more fun. Pytimetk.
https://business-science.github.io/pytimetk/
MIT License
696 stars 60 forks source link

Change sort for rolling calcs or enable calcs to work on forward periods #288

Closed DataStrategyPro closed 4 months ago

DataStrategyPro commented 9 months ago

Currently it's only possible to apply rolling calcs to prior periods and not forward periods. A scenario where it's useful to have both is applying a rolling calc to a prior period to generate a trade entry signal, and then apply a rolling calc to the forward period to see what the outcome of that entry signal would have been.

mdancho84 commented 4 months ago

Hey Jonathan, Can you provide an example of what you'd expect to see? I'm working on Pytimetk next version now. So if you have a good change, I'd be happy to review it. But I want to make sure I get the functionality correct.

Thanks, Matt

DataStrategyPro commented 4 months ago

Thanks Matt, Sorry I should have put together a reproducible example when I first raised this.

When testing again I don't seem to have any problems in using timetk to generate forward lags.

I think I might have made the mistake of creating a negative window size as opposed to a negative lag.

pytimetk is a really great package. Thanks so much for all of your work on this.

`import pytimetk as tk

df = tk.load_dataset('stocks_daily', parse_dates=['date']) df.groupby('symbol').augment_lags(date_column='date', value_column='close', lags=[-1,-30], engine='polars') `

mdancho84 commented 4 months ago

Ok I'll close for now. Thanks!