Import stock prices
stocks <- tq_get(c("MU", "PANW", "CRWD"),
get = "stock.prices",
from = "2020-01-01")
stocks
## # A tibble: 5,034 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 MU 2020-01-02 54.8 55.5 54.5 55.4 20173200 54.0
## 2 MU 2020-01-03 54.2 55.3 54 54.5 16815800 53.2
## 3 MU 2020-01-06 53.8 54.1 53.2 53.6 18768700 52.2
## 4 MU 2020-01-07 55.4 58.4 55.4 58.3 49908200 56.8
## 5 MU 2020-01-08 58.1 58.4 57.1 57.5 29730800 56.1
## 6 MU 2020-01-09 58.3 58.5 56.5 57.3 22376100 55.9
## 7 MU 2020-01-10 57.5 57.5 56.3 56.7 19122800 55.3
## 8 MU 2020-01-13 57.0 57.8 56.9 57.5 16163000 56.0
## 9 MU 2020-01-14 57.8 58.3 56.5 57.5 26454300 56.1
## 10 MU 2020-01-15 57.0 57.1 55.8 56.2 21638600 54.8
## # ℹ 5,024 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
