I am trying to create a dataset from Alpha Vantage using the tidyquant
package. I'm looking for a solution to specify the date range for my dataset (it appears that using a from
and to
argument does not work.
Any suggestions
my code is as follows
data <- c("EUR/USD", "EUR/ZAR") %>%
tq_get(from = '2019-01-01',to = '2019-12-01',get = "alphavantage", av_fun = "FX_WEEKLY")
You can not set a from
and to
option when using Alphavantage. Alphavantage will either return the first hunderd rows of data or the full available dataset. But alphavantager is defaulted to always returning the full dataset. You will have to filter the from and to dates after you get the data.
Basically when you have the data, use something like this:
library(dplyr )
data %>%
filter(between(timestamp, as.Date('2019-01-01'), as.Date('2019-12-01')))