I would like to calculate rolling yearly differences based on a daily time series in R with a xts object. However, I see currently two issues:
- The number of trading days per year is not constant.
- There could be holes in the time series, e.g. one year could be missing in-between.
Are there functions available in the library to take such rolling differences without constant lags (e.g. a lag of 260 days could be off by 10 days sometimes)? Or would the correct approach here to search for each date the same date one year before (minus one or two days to account for weekends)?