Import stock prices
stocks <- tq_get(c("TAL", "EDU"),
get = "stock.prices",
from = "2021-01-01",
to = "2022-08-07")
stocks
## # A tibble: 802 × 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 TAL 2021-01-04 71.6 72.0 68.6 69.2 2963500 69.2
## 2 TAL 2021-01-05 67.5 68.9 65.3 68.9 3889900 68.9
## 3 TAL 2021-01-06 69 69.5 66.5 66.8 3777100 66.8
## 4 TAL 2021-01-07 67.1 67.9 64.9 65.1 4898300 65.1
## 5 TAL 2021-01-08 65.5 67.9 65.3 67.8 4539600 67.8
## 6 TAL 2021-01-11 67.7 68.5 66.2 66.5 1904800 66.5
## 7 TAL 2021-01-12 67.5 67.5 65.0 65.5 2591200 65.5
## 8 TAL 2021-01-13 65.3 66 64.8 65.8 3303400 65.8
## 9 TAL 2021-01-14 66.2 67.1 65.1 65.1 2596300 65.1
## 10 TAL 2021-01-15 65.5 66.3 64.8 65.6 2199700 65.6
## # … with 792 more rows
Plot stock prices
stocks %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line()
