business-science / tidyquant

Bringing financial analysis to the tidyverse

Home Page:https://business-science.github.io/tidyquant/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tq_exchange returning error message

mcfsalla opened this issue · comments

The tq_exchange function is returning the same error for any exchange:
Error: Can't rename columns that don't exist.
x Column 'Symbol' doesn't exist.

Here's the website. https://www.nasdaq.com/market-activity/stocks/screener?exchange=nyse

I can't find the link that will download the CSV from it. Seems like they don't want people getting the CSV via CURL.

I ran into the same issue. I found when you click on the download CSV button there is an API call made that returns a JSON envelope back with the info. No authorization header required.

https://api.nasdaq.com/api/screener/stocks?tableonly=true&limit=25&offset=0&exchange=nyse&download=true

The exchange can be tweaked, the limit=25 doesn't seem to matter.

Awesome! This could be the solution.

Ran into the same problem:

tq_exchange("NASDAQ")
Error: Can't rename columns that don't exist.
x Column `Symbol` doesn't exist.

Looking for guidance from the team, It seems like this is the path to a solution:
https://stackoverflow.com/questions/37996827/convert-json-file-to-a-csv-file-using-r

Agree?

I ended up using httr's GET() function which can do json parsing. It produces a data frame with the column headers and a list of rows, each being a list of values.

Solution seems straightforward. I'm tied up and won't be able to tackle for a bit. If someone can make a pull request, it would be much appreciated. Otherwise I'll tackle once I get some free time.

I tried to fix it, works for me: #194

Hey everyone, #194 has just been merged. Thanks @mgei for helping with integrating. It works very fast. Give him a 👏

Until this fix gets to CRAN please install using:

remotes::install_github("business-science/tidyquant")