Import stock prices

stocks <- tq_get(c("AAPL", "MSFT","META"),
                 get = "stock.prices",
                 from = "2018-01-01",
                 to = "2021-01-01")
stocks
## # A tibble: 2,268 × 8
##    symbol date        open  high   low close    volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>
##  1 AAPL   2018-01-02  42.5  43.1  42.3  43.1 102223600     41.0
##  2 AAPL   2018-01-03  43.1  43.6  43.0  43.1 118071600     41.0
##  3 AAPL   2018-01-04  43.1  43.4  43.0  43.3  89738400     41.2
##  4 AAPL   2018-01-05  43.4  43.8  43.3  43.8  94640000     41.7
##  5 AAPL   2018-01-08  43.6  43.9  43.5  43.6  82271200     41.5
##  6 AAPL   2018-01-09  43.6  43.8  43.4  43.6  86336000     41.5
##  7 AAPL   2018-01-10  43.3  43.6  43.2  43.6  95839600     41.5
##  8 AAPL   2018-01-11  43.6  43.9  43.6  43.8  74670800     41.7
##  9 AAPL   2018-01-12  44.0  44.3  43.9  44.3 101672400     42.2
## 10 AAPL   2018-01-16  44.5  44.8  44.0  44.0 118263600     42.0
## # … with 2,258 more rows

Plot stock prices

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