Import stock prices

stocks <- tq_get(c("AAPL", "MSFT", "GOOG"),
                 get = "stock.prices",
                 from = "2016-01-01",
                 to = "2024-01-01")
stocks
## # A tibble: 6,036 × 8
##    symbol date        open  high   low close    volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>
##  1 AAPL   2016-01-04  25.7  26.3  25.5  26.3 270597600     23.9
##  2 AAPL   2016-01-05  26.4  26.5  25.6  25.7 223164000     23.3
##  3 AAPL   2016-01-06  25.1  25.6  25.0  25.2 273829600     22.8
##  4 AAPL   2016-01-07  24.7  25.0  24.1  24.1 324377600     21.9
##  5 AAPL   2016-01-08  24.6  24.8  24.2  24.2 283192000     22.0
##  6 AAPL   2016-01-11  24.7  24.8  24.3  24.6 198957600     22.3
##  7 AAPL   2016-01-12  25.1  25.2  24.7  25.0 196616800     22.7
##  8 AAPL   2016-01-13  25.1  25.3  24.3  24.3 249758400     22.1
##  9 AAPL   2016-01-14  24.5  25.1  23.9  24.9 252680400     22.6
## 10 AAPL   2016-01-15  24.0  24.4  23.8  24.3 319335600     22.0
## # ℹ 6,026 more rows

Plot stock prices

stocks %>%
    
    ggplot(aes(x = date, y = adjusted, color = symbol)) +
    geom_line()