test_that("exchanges can be queried", {
apikey(api_key = Sys.getenv("IEXAPIKEYPUBLIC"),
secret_key = Sys.getenv("IEXAPIKEYSECRET"),
sandbox = TRUE)
expect_true(all(c("exchange","region","mic") %in% names(exchanges())))
expect_true(nrow(exchanges())>1)
})
test_that("credit usage can be queried", {
apikey(api_key = Sys.getenv("IEXAPIKEYPUBLIC"),
secret_key = Sys.getenv("IEXAPIKEYSECRET"),
sandbox = TRUE)
expect_gt(credit_usage(),1)
})
test_that("we find symbols per isin", {
apikey(api_key = Sys.getenv("IEXAPIKEYPUBLIC"),
secret_key = Sys.getenv("IEXAPIKEYSECRET"),
sandbox = TRUE)
expect_gt( nrow(symbols_by_isin("US67066G1040")),1)
})
test_that("we find symbols per exchange", {
apikey(api_key = Sys.getenv("IEXAPIKEYPUBLIC"),
secret_key = Sys.getenv("IEXAPIKEYSECRET"),
sandbox = TRUE)
expect_gte( nrow(symbols_by_exchange("ETR")),100)
})
test_that("batch price download works", {
apikey(api_key = Sys.getenv("IEXAPIKEYPUBLIC"),
secret_key = Sys.getenv("IEXAPIKEYSECRET"),
sandbox = TRUE)
x <- prices_batch("ALV-GY")
expect_true(all(c("symbol","date","open","high","low","close","aClose","fClose","volume") %in% names(x)))
expect_gt(nrow(x),19)
x <- prices_batch(c("ALV-GY","AAPL","AMZN"),start_date = "2020-01-02",TRUE)
expect_true(all(x %>% dplyr::distinct(symbol) %$% symbol %in% c("ALV-GY","AAPL","AMZN")))
expect_equal(nrow(x),3)
})
test_that("granular batch price download works", {
apikey(api_key = Sys.getenv("IEXAPIKEYPUBLIC"),
secret_key = Sys.getenv("IEXAPIKEYSECRET"),
sandbox = TRUE)
x <- prices("ALV-GY")
expect_true(all(c("symbol","date","open","high","low","close","aClose","fClose","volume") %in% names(x)))
expect_gt(nrow(x),19)
x <- prices(c("ALV-GY","AAPL","AMZN"),start_date = "2020-01-02",end_date = "2020-01-02")
expect_true(all(x %>% dplyr::distinct(symbol) %$% symbol %in% c("ALV-GY","AAPL","AMZN")))
expect_equal(nrow(x),3)
})
test_that("can obtain company info", {
apikey(api_key = Sys.getenv("IEXAPIKEYPUBLIC"),
secret_key = Sys.getenv("IEXAPIKEYSECRET"),
sandbox = TRUE)
x <- company_info("ALV-GY")
expect_true(all(c("companyName","industry","primarySicCode","tags","sector") %in% names(x)))
})
test_that("get historical FX rates", {
apikey(api_key = Sys.getenv("IEXAPIKEYPUBLIC"),
secret_key = Sys.getenv("IEXAPIKEYSECRET"),
sandbox = TRUE)
x <- exchange_rates("EURUSD")
y <- exchange_rates("EURUSD",start_date=Sys.Date()-30,end_date = Sys.Date())
expect_true(nrow(x)==1)
expect_true(nrow(y)>=1 && nrow(y)<=30)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.