Import stock prices
stocks <- tq_get(c("WMT", "F", "AAPL"),
get = "stock.prices",
from = "2016-01-01",
to = "2017-01-01")
stocks
## # A tibble: 756 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 WMT 2016-01-04 20.2 20.5 20.1 20.5 35967600 17.0
## 2 WMT 2016-01-05 20.7 21.0 20.6 21.0 39978000 17.4
## 3 WMT 2016-01-06 20.8 21.3 20.8 21.2 49693800 17.5
## 4 WMT 2016-01-07 21.0 21.7 21.0 21.7 79290000 18.0
## 5 WMT 2016-01-08 21.7 21.8 21.1 21.2 53303700 17.5
## 6 WMT 2016-01-11 21.3 21.5 21.2 21.4 37961400 17.7
## 7 WMT 2016-01-12 21.5 21.6 21.1 21.2 36587700 17.6
## 8 WMT 2016-01-13 21.2 21.2 20.6 20.6 41177100 17.1
## 9 WMT 2016-01-14 20.7 21.2 20.6 21.0 38804700 17.4
## 10 WMT 2016-01-15 20.5 20.8 20.4 20.6 45523200 17.1
## # ℹ 746 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
