Import stock prices

stocks <- tq_get(c("CAT", "SITE", "DE"),
                 get = "stock.prices",
                 from = "2020-01-01",
                 to = "2024-01-01")
stocks
## # A tibble: 3,018 × 8
##    symbol date        open  high   low close  volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>   <dbl>    <dbl>
##  1 CAT    2020-01-02  149   151.  148.  151. 3311900     132.
##  2 CAT    2020-01-03  149.  150.  147.  148. 3100600     130.
##  3 CAT    2020-01-06  147.  149.  147.  148. 2549600     130.
##  4 CAT    2020-01-07  147.  148.  146.  146. 2841900     128.
##  5 CAT    2020-01-08  147.  149.  146.  148. 2153200     130.
##  6 CAT    2020-01-09  148.  148.  147.  147. 2272500     129.
##  7 CAT    2020-01-10  147.  148.  146.  146. 2393700     128.
##  8 CAT    2020-01-13  147.  147.  146.  147. 3355200     129.
##  9 CAT    2020-01-14  147.  148.  146.  147. 2742200     129.
## 10 CAT    2020-01-15  146.  147.  145.  146. 2640500     128.
## # ℹ 3,008 more rows

Plot stock prices

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