business-science / riingo

An R interface to the Tiingo stock price API
https://business-science.github.io/riingo/
Other
51 stars 9 forks source link

riingo_iex_quote("QQQ") is not working #8

Closed rjvelasquezm closed 5 years ago

rjvelasquezm commented 5 years ago

At least for me the function isn't working. Possible a change on tiingo side could be the issue.

riingo_iex_quote("QQQ")

tiingo commented 5 years ago

Nothing changed on our side!

Did you use riingo_set_token() prior to making the request?

image

rjvelasquezm commented 5 years ago

Yep, I did. Think I found how to solve the issue.

riingo_iex_quote calls riingo_iex_quote_single (full function below).

By changing the line:
riingo_data <- clean_json_df(cont_df, type, endpoint) to: riingo_data <- clean_json_df(cont_df[[1]], type, endpoint)

it seems to get fixed. Seems the function was expecting cont_df to be a dataframe but instead it's a list of dataframe. Might be related to a warning given that glue::collapse is now a deprecated function.

function (ticker) 
{
    type <- "iex"
    endpoint <- "quote"
    riingo_url <- construct_url(type, endpoint, ticker)
    json_content <- content_downloader(riingo_url, ticker)
    json_content <- paste0("[", json_content, "]")
    cont_df <- jsonlite::fromJSON(json_content)
    riingo_data <- clean_json_df(cont_df, type, endpoint)
    riingo_data$ticker <- NULL
    riingo_data <- tibble::add_column(riingo_data, ticker = ticker, 
        .before = 1L)
    riingo_data
}
DavisVaughan commented 5 years ago

This should be fixed in the dev version (I should probably do a riingo release with this change). Back in july of 2018 I removed this line:

json_content <- paste0("[", json_content, "]")

which was the fix for this issue. Something changed in the tiingo api where we no longer needed to add that.

Can you try devtools::install_github("business-science/riingo"), restart R and try again?

DavisVaughan commented 5 years ago

Assuming this was fixed in the dev version. Should be able to get out a cran release soon