Import stock prices
stocks <- tq_get(c("VOOG", "NVDA"),
get = "stock.prices",
from = "2019-01-01",
to = "2022-01-01")
stocks
## # A tibble: 1,514 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 VOOG 2019-01-02 133. 135. 133. 135. 239200 129.
## 2 VOOG 2019-01-03 134. 134. 131. 131. 177400 126.
## 3 VOOG 2019-01-04 133. 137. 133. 136. 198400 130.
## 4 VOOG 2019-01-07 136. 138. 136. 137. 262000 131.
## 5 VOOG 2019-01-08 139. 139. 137. 139. 178600 133.
## 6 VOOG 2019-01-09 139. 140. 138. 139. 207000 133.
## 7 VOOG 2019-01-10 139. 140. 138. 140. 156200 134.
## 8 VOOG 2019-01-11 139. 140. 139. 140. 123400 134.
## 9 VOOG 2019-01-14 139. 139. 138. 139. 75500 133.
## 10 VOOG 2019-01-15 139. 141. 139. 141. 128500 135.
## # ℹ 1,504 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
