Import stock prices
stocks <- tq_get(c("TECH", "GOOG", "VZ", "NVDA"),
get = "stock.prices",
from = "2016-01-01",
)
stocks
## # A tibble: 6,728 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 TECH 2016-01-04 89.1 89.1 86.5 88.2 373900 84.0
## 2 TECH 2016-01-05 88.3 88.9 87 88.0 269000 83.7
## 3 TECH 2016-01-06 86.9 87.8 86.3 87.7 631600 83.5
## 4 TECH 2016-01-07 86.6 87.6 85.8 87.2 284700 82.9
## 5 TECH 2016-01-08 87.6 87.6 85.2 85.8 264600 81.6
## 6 TECH 2016-01-11 86.1 86.1 83.3 84.3 232200 80.2
## 7 TECH 2016-01-12 84.8 85.9 83.8 85.2 188500 81.1
## 8 TECH 2016-01-13 85.4 85.8 82.2 82.4 241000 78.4
## 9 TECH 2016-01-14 82.9 85.0 81.8 83.5 164300 79.5
## 10 TECH 2016-01-15 81.9 83.9 81.2 83.3 492000 79.3
## # … with 6,718 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
