# \donttest{
data(sample_prices_weekly)
mom12 <- PortfolioTesteR::calc_momentum(sample_prices_weekly, lookback = 12)
sel10 <- PortfolioTesteR::filter_top_n(mom12, n = 5)
w_eq <- PortfolioTesteR::weight_equally(sel10)
pr <- PortfolioTesteR::portfolio_returns(w_eq, sample_prices_weekly)
# Use SPY as the benchmark
bench <- sample_prices_weekly[, c("Date", "SPY")]
res <- analyze_vs_benchmark(
pr$portfolio_return,
bench,
dates = pr$Date,
benchmark_symbol = "SPY"
)
res
# }
Run the code above in your browser using DataLab