Import stock prices
stocks <- tq_get(c("GM", "TSLA", "HMC", "VWAGY", "F"),
get = "stock.prices",
from = "2020-01-01")
stocks
## # A tibble: 3,875 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 GM 2020-01-02 37 37.4 36.5 37.4 7454400 36.8
## 2 GM 2020-01-03 36.7 36.9 36.1 36.3 9173000 35.7
## 3 GM 2020-01-06 36.0 36.2 35.8 35.8 8408200 35.2
## 4 GM 2020-01-07 35.8 35.8 34.7 35.2 17556800 34.6
## 5 GM 2020-01-08 35.0 35.2 34.4 34.7 13229400 34.1
## 6 GM 2020-01-09 35.0 35.1 34.5 35.1 9610400 34.5
## 7 GM 2020-01-10 35.2 36.5 34.5 34.7 9644900 34.1
## 8 GM 2020-01-13 34.7 35 34.5 35.0 7465700 34.4
## 9 GM 2020-01-14 35 35.3 35.0 35.2 6827100 34.6
## 10 GM 2020-01-15 35 35.3 34.9 35.2 7173900 34.6
## # … with 3,865 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
