Import stock prices

stocks <- tq_get(c("GOOGL", "GM", "WMT"),
                 get = "stock.prices",
                 from = "2016-01-01")
stocks
## # A tibble: 7,443 × 8
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 GOOGL  2016-01-04  38.1  38.1  37.4  38.0 67382000     37.7
##  2 GOOGL  2016-01-05  38.2  38.5  37.8  38.1 45216000     37.8
##  3 GOOGL  2016-01-06  37.5  38.3  37.4  38.0 48206000     37.7
##  4 GOOGL  2016-01-07  37.3  37.8  36.8  37.0 63132000     36.8
##  5 GOOGL  2016-01-08  37.4  37.5  36.4  36.5 47506000     36.3
##  6 GOOGL  2016-01-11  36.6  36.8  36.0  36.7 50896000     36.4
##  7 GOOGL  2016-01-12  37.0  37.4  36.8  37.3 46816000     37.0
##  8 GOOGL  2016-01-13  37.5  37.7  35.8  36.0 51728000     35.7
##  9 GOOGL  2016-01-14  36.2  37.0  35.2  36.6 55558000     36.3
## 10 GOOGL  2016-01-15  35.5  36.2  35.1  35.5 76676000     35.3
## # ℹ 7,433 more rows

Plot stock prices

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