Exercise

Calculate EWMAs

We will now work towards creating some features to be able to predict our ideal portfolios. We will simply use the price movement as a feature for now. To do this we will create a daily exponentially-weighted moving average (EWMA), then resample that to the monthly timeframe. Finally, we'll shift the monthly moving average of price one month in the future, so we can use it as a feature for predicting future portfolios.

Instructions

100 XP
  • Use a span of 30 to calculate the daily exponentially-weighted moving average (ewma_daily).
  • Resample the daily ewma to the month by using the Business Monthly Start frequency (BMS) and the first day of the month (.first()).
  • Shift ewma_monthly by one month forward, so we can use the previous month's EWMA as a feature to predict the next month's ideal portfolio.