Import stock prices

stocks <- tq_get(c("AAPL", "NFLX"),
                 get = "stock.prices",
                 from = "2020-01-01",
                 to = "2021-01-01")
stocks
## # A tibble: 506 × 8
##    symbol date        open  high   low close    volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>
##  1 AAPL   2020-01-02  74.1  75.2  73.8  75.1 135480400     73.7
##  2 AAPL   2020-01-03  74.3  75.1  74.1  74.4 146322800     73.0
##  3 AAPL   2020-01-06  73.4  75.0  73.2  74.9 118387200     73.5
##  4 AAPL   2020-01-07  75.0  75.2  74.4  74.6 108872000     73.2
##  5 AAPL   2020-01-08  74.3  76.1  74.3  75.8 132079200     74.4
##  6 AAPL   2020-01-09  76.8  77.6  76.6  77.4 170108400     76.0
##  7 AAPL   2020-01-10  77.7  78.2  77.1  77.6 140644800     76.1
##  8 AAPL   2020-01-13  77.9  79.3  77.8  79.2 121532000     77.8
##  9 AAPL   2020-01-14  79.2  79.4  78.0  78.2 161954400     76.7
## 10 AAPL   2020-01-15  78.0  78.9  77.4  77.8 121923600     76.4
## # … with 496 more rows

Plot stock prices

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