Introduction

This report analyzes the daily stock prices and daily returns of six stocks: Apple (AAPL), Microsoft (MSFT), Alphabet (GOOG), Amazon (AMZN), Taiwan Semiconductor Manufacturing Company (TSM), and NVIDIA (NVDA).

The observation period starts from January 1, 2024 and continues to the most recent available trading day.

The stock price data are obtained from Yahoo Finance using the tidyquant package in R.

library(tidyquant)
library(dplyr)
library(knitr)
stocks <- c("AAPL", "MSFT", "GOOG", "AMZN", "TSM", "NVDA")


stock_data <- tq_get(
  stocks,
  get = "stock.prices",
  from = "2024-01-01",
  to = Sys.Date()
)
head(stock_data)
## # A tibble: 6 × 8
##   symbol date        open  high   low close   volume adjusted
##   <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
## 1 AAPL   2024-01-02  187.  188.  184.  186. 82488700     183.
## 2 AAPL   2024-01-03  184.  186.  183.  184. 58414500     182.
## 3 AAPL   2024-01-04  182.  183.  181.  182. 71983600     180.
## 4 AAPL   2024-01-05  182.  183.  180.  181. 62379700     179.
## 5 AAPL   2024-01-08  182.  186.  182.  186. 59144500     183.
## 6 AAPL   2024-01-09  184.  185.  183.  185. 42841800     183.
daily_returns <- stock_data %>%
  group_by(symbol) %>%
  arrange(date, .by_group = TRUE) %>%
  mutate(
    daily_return = adjusted / lag(adjusted) - 1
  ) %>%
  filter(!is.na(daily_return))
first_returns <- daily_returns %>%
  group_by(symbol) %>%
  slice_head(n = 5) %>%
  select(symbol, date, adjusted, daily_return) %>%
  mutate(
    adjusted = round(adjusted, 2),
    daily_return = round(daily_return * 100, 2)
  )

kable(
  first_returns,
  col.names = c(
    "Stock",
    "Date",
    "Adjusted Price",
    "Daily Return (%)"
  ),
  caption = "First Five Daily Returns for Each Stock"
)
First Five Daily Returns for Each Stock
Stock Date Adjusted Price Daily Return (%)
AAPL 2024-01-03 182.03 -0.75
AAPL 2024-01-04 179.72 -1.27
AAPL 2024-01-05 179.00 -0.40
AAPL 2024-01-08 183.32 2.42
AAPL 2024-01-09 182.91 -0.23
AMZN 2024-01-03 148.47 -0.97
AMZN 2024-01-04 144.57 -2.63
AMZN 2024-01-05 145.24 0.46
AMZN 2024-01-08 149.10 2.66
AMZN 2024-01-09 151.37 1.52
GOOG 2024-01-03 139.04 0.57
GOOG 2024-01-04 136.74 -1.65
GOOG 2024-01-05 136.10 -0.47
GOOG 2024-01-08 139.21 2.29
GOOG 2024-01-09 141.22 1.44
MSFT 2024-01-03 362.85 -0.07
MSFT 2024-01-04 360.25 -0.72
MSFT 2024-01-05 360.06 -0.05
MSFT 2024-01-08 366.86 1.89
MSFT 2024-01-09 367.94 0.29
NVDA 2024-01-03 47.43 -1.24
NVDA 2024-01-04 47.86 0.90
NVDA 2024-01-05 48.96 2.29
NVDA 2024-01-08 52.10 6.43
NVDA 2024-01-09 52.99 1.70
TSM 2024-01-03 96.96 -1.34
TSM 2024-01-04 95.95 -1.04
TSM 2024-01-05 96.42 0.48
TSM 2024-01-08 98.96 2.64
TSM 2024-01-09 98.62 -0.34