Using the given code, answer the questions below.
library(tidyquant)
library(tidyverse)
stocks <- tq_get("AAPL", get = "stock.prices", from = "2018-08-18")
stocks
## # A tibble: 122 x 7
## date open high low close volume adjusted
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2018-08-20 218. 219. 215. 215. 30287700 214.
## 2 2018-08-21 217. 217. 214. 215. 26159800 213.
## 3 2018-08-22 214. 216. 214. 215. 19018100 213.
## 4 2018-08-23 215. 217. 215. 215. 18883200 214.
## 5 2018-08-24 217. 217. 215. 216. 18476400 214.
## 6 2018-08-27 217. 219. 216. 218. 20525100 216.
## 7 2018-08-28 219. 221. 219. 220. 22776800 218.
## 8 2018-08-29 220. 223. 219. 223. 27254800 221.
## 9 2018-08-30 223. 228. 222. 225. 48793800 223.
## 10 2018-08-31 227. 229. 226 228. 43340100 226.
## # ... with 112 more rows
There are seven columns.
date, open, high, low, close, volume, adjusted
Daily Apple stock data.
stocks <- tq_get(c("AAPL", "FB"), get = "stock.prices", from = "2016-01-01")
stocks
## # A tibble: 1,568 x 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 AAPL 2016-01-04 103. 105. 102 105. 67649400 99.5
## 2 AAPL 2016-01-05 106. 106. 102. 103. 55791000 97.0
## 3 AAPL 2016-01-06 101. 102. 99.9 101. 68457400 95.1
## 4 AAPL 2016-01-07 98.7 100. 96.4 96.4 81094400 91.1
## 5 AAPL 2016-01-08 98.6 99.1 96.8 97.0 70798000 91.6
## 6 AAPL 2016-01-11 99.0 99.1 97.3 98.5 49739400 93.1
## 7 AAPL 2016-01-12 101. 101. 98.8 100.0 49154200 94.4
## 8 AAPL 2016-01-13 100. 101. 97.3 97.4 62439600 92.0
## 9 AAPL 2016-01-14 98.0 100. 95.7 99.5 63170100 94.0
## 10 AAPL 2016-01-15 96.2 97.7 95.4 97.1 79010000 91.7
## # ... with 1,558 more rows
stocks %>%
filter(symbol == "FB") %>%
arrange(desc(close))
## # A tibble: 784 x 8
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 FB 2018-07-25 216. 219. 214. 218. 58954200 218.
## 2 FB 2018-07-24 215. 216. 213. 215. 28468700 215.
## 3 FB 2018-07-23 211. 212. 209. 211. 16732000 211.
## 4 FB 2018-07-17 205. 210. 205. 210. 15349900 210.
## 5 FB 2018-07-20 209. 212. 208. 210. 16163900 210.
## 6 FB 2018-07-18 210. 211. 208. 209. 15334900 209.
## 7 FB 2018-07-19 209. 210. 208. 208. 11350400 208.
## 8 FB 2018-07-13 208. 208. 206. 207. 11486800 207.
## 9 FB 2018-07-16 208. 209. 207. 207. 11078200 207.
## 10 FB 2018-07-12 203. 207. 203. 207. 15454700 207.
## # ... with 774 more rows
library(tidyquant)
library(tidyverse)
FX <- tq_get("USD/JPY", get = "exchange.rate", from = "2016-01-01")
FX
## # A tibble: 180 x 2
## date exchange.rate
## <date> <dbl>
## 1 2018-08-18 111.
## 2 2018-08-19 111.
## 3 2018-08-20 110.
## 4 2018-08-21 110.
## 5 2018-08-22 110.
## 6 2018-08-23 111.
## 7 2018-08-24 111.
## 8 2018-08-25 111.
## 9 2018-08-26 111.
## 10 2018-08-27 111.
## # ... with 170 more rows