stefan-jansen / machine-learning-for-trading

Code for Machine Learning for Algorithmic Trading, 2nd edition.
https://ml4trading.io
12.57k stars 4.03k forks source link

Ch 7 - 07_logistic_regression_macro_data.ipynb - process/analysis #273

Closed cconw closed 1 year ago

cconw commented 1 year ago

Ch. 7, script #07_logistic_regression_macro_data.ipynb - process/analysis

The 'target' of the regression is whether or not the current moving average calculation for a 20 day period. Shouldn't the regression exclude the first 20 observations, because it's not possible to have a 1? (i.e. can't have 1 until observation 21)

Thanks

stefan-jansen commented 1 year ago

The default for min_period in rolling is None which implies 1 period is sufficient to compute a rolling average.

So I wouldn't say it's impossible to have an outcome of 1, but you may still want to exclude the first 19 periods because the rolling average would include fewer values than latter periods. Fair point.