Import stock prices
stocks <- tq_get(c("SOFI", "BBWI", "CORZ"),
get = "stock.prices",
from = "2016-01-01",
to = "2017-01-01")
## Warning: There were 2 warnings in `dplyr::mutate()`.
## The first warning was:
## ℹ In argument: `data.. = purrr::map(...)`.
## Caused by warning:
## ! x = 'SOFI', get = 'stock.prices': Error in getSymbols.yahoo(Symbols = "SOFI", env = <environment>, verbose = FALSE, : Unable to import "SOFI".
## HTTP error 400.
## Removing SOFI.
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 1 remaining warning.
stocks
## # A tibble: 252 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 BBWI 2016-01-04 76.5 76.6 75.4 76.0 2558116 56.3
## 2 BBWI 2016-01-05 76.3 78.3 76.0 78.0 2637655 57.8
## 3 BBWI 2016-01-06 77.1 77.9 75.7 76.5 3177482 56.7
## 4 BBWI 2016-01-07 76.0 78.7 75.9 78.0 4782118 57.8
## 5 BBWI 2016-01-08 78.4 78.7 75.1 75.4 3160040 55.8
## 6 BBWI 2016-01-11 75.7 76.5 74.6 75.2 1938874 55.7
## 7 BBWI 2016-01-12 76.2 78.3 75.9 76.9 2403367 57.0
## 8 BBWI 2016-01-13 77.1 77.4 74.4 74.6 2190727 55.3
## 9 BBWI 2016-01-14 74.5 76.6 73.3 76.2 2476227 56.4
## 10 BBWI 2016-01-15 74.7 75.7 73.5 74.6 3259742 55.3
## # ℹ 242 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
