Import stock prices

stocks <- tq_get(c("NKE", "TSLA"),
                 get = "stock.prices",
                 from = "2019-01-01",
                 to = "2023-01-01")
stocks
## # A tibble: 2,016 × 8
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 NKE    2019-01-02  72.8  74.6  72.2  74.1  6762700     70.6
##  2 NKE    2019-01-03  73.2  73.3  71.2  72.8  8007400     69.4
##  3 NKE    2019-01-04  73.4  75.1  73.1  74.7  7844200     71.2
##  4 NKE    2019-01-07  74.7  76.4  74.3  75.7  8184800     72.2
##  5 NKE    2019-01-08  76.8  77.4  76.2  76.7  8809000     73.2
##  6 NKE    2019-01-09  77.0  77.2  76.1  76.6  8591000     73.0
##  7 NKE    2019-01-10  75.6  77.3  75.5  76.4 11148600     72.9
##  8 NKE    2019-01-11  76.3  76.9  75.8  76.0 10689900     72.5
##  9 NKE    2019-01-14  75.5  76.8  75.5  76.1  5677400     72.5
## 10 NKE    2019-01-15  76.2  78.0  76.1  77.9  6212400     74.3
## # ℹ 2,006 more rows

Plot stock prices

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