library(quantmod) library(PerformanceAnalytics) library(knitr) # Define tickers tickers <- c(“AAPL”, “MSFT”, “GOOG”, “AMZN”, “TSM”, “NVDA”)
getSymbols(tickers, src = “yahoo”, from = “2024-01-01”, auto.assign = TRUE)
prices <- do.call(merge, lapply(tickers, function(x) Ad(get(x)))) head(prices) # show first few prices # Compute daily returns returns <- na.omit(Return.calculate(prices))
head(returns) # Nicely formatted table kable(head(returns), caption = “First Few Daily Returns (2024–Present)”)