# \donttest{
data(sample_prices_weekly)
mom12 <- PortfolioTesteR::calc_momentum(sample_prices_weekly, lookback = 12)
sel5 <- PortfolioTesteR::filter_top_n(mom12, n = 5)
w_eq <- PortfolioTesteR::weight_equally(sel5)
pr <- PortfolioTesteR::portfolio_returns(w_eq, sample_prices_weekly)
val <- 1e5 * cumprod(1 + pr$portfolio_return)
out <- analyze_by_period(
dates = pr$Date,
returns = pr$portfolio_return,
values = val,
period = "monthly"
)
head(out)
# }
Run the code above in your browser using DataLab