diff --git a/R/av_get.R b/R/av_get.R index 0c9f71e..48e6fef 100644 --- a/R/av_get.R +++ b/R/av_get.R @@ -104,6 +104,12 @@ av_get <- function(symbol, av_fun, ...) { dots$to_symbol <- currencies[[2]] } + #symbol search + if(av_fun == "SYMBOL_SEARCH") { + dots$symbol <- NULL + dots$keywords <- symbol + } + # Generate URL url_params <- stringr::str_c(names(dots), dots, sep = "=", collapse = "&") url <- glue::glue("https://www.alphavantage.co/query?function={av_fun}&{url_params}") @@ -192,5 +198,3 @@ av_get <- function(symbol, av_fun, ...) { return(content) } - - diff --git a/tests/testthat/test_av_get.R b/tests/testthat/test_av_get.R index e6921b1..f9d2d00 100644 --- a/tests/testthat/test_av_get.R +++ b/tests/testthat/test_av_get.R @@ -81,6 +81,24 @@ test_that("call Technical Indicators", { }) + +# Symbol search +test_that("symbol search", { + skip_if_no_auth() + skip_on_cran() + + # SMA + symbol <- "MSFT" + av_fun <- "SYMBOL_SEARCH" + + delay_15_seconds() + resp <- av_get(symbol, av_fun = av_fun, symbol = symbol) + + expect_s3_class(resp, "tbl") + expect_gt(nrow(resp), 1) +}) + + # Bad Calls ------ test_that("call results in error", { @@ -115,3 +133,5 @@ test_that("call with no API key is stopped", { av_api_key(key) }) + +