Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All Tests from Class HistoricalTests are failing #75

Open
Sputniko opened this issue Sep 7, 2024 · 10 comments
Open

All Tests from Class HistoricalTests are failing #75

Sputniko opened this issue Sep 7, 2024 · 10 comments

Comments

@Sputniko
Copy link

Sputniko commented Sep 7, 2024

All tests are throwing this exception:

Flurl.Http.FlurlHttpException : Call failed with status code 401 (Unauthorized):

Also in my app where I use your package - same error. One week ago it worked fine for me.

@pdcuevas
Copy link

pdcuevas commented Sep 9, 2024

I have the same problem in a .net core 8 application. Thanks!

@jabacrack
Copy link

I found out what happened – Yahoo has closed access to downloading CSV files with historical data. Another method to get the data, using charts, is still working. I might implement it, but I can't guarantee it.

@irigopou
Copy link

irigopou commented Sep 9, 2024

Using charts, more exactly the url https://query2.finance.yahoo.com/v8/finance/chart, I get the following exception:
The remote server returned an error: (429) Too Many Requests.

@gyantal
Copy link

gyantal commented Sep 10, 2024

Correct.
The https://query1.finance.yahoo.com/v7/finance/download API doesn't work now. And this is the way how it is implemented now.
However, the https://query2.finance.yahoo.com/v8/finance/chart way still works.
The Python YF API (https://github.com/ranaroussi/yfinance) guys were lucky.
Because they built their code on the 'chart' way. So, if somebody uses it in Python, that still works.

Interestingly, the 'chart' way works without crumbs. You can try it in an Incognito browser tab:
https://query2.finance.yahoo.com/v8/finance/chart/VXX?events=div%2Csplits%2CcapitalGains&includePrePost=False&interval=1d&period1=631274400&period2=1726007649
But it is a very different format than the previous one.
The advantage is that with 1 query, it is possible to get all 3 data: price, split, and dividend.

Also, I found the warning in the Python API here:
https://github.com/ranaroussi/yfinance/blob/main/tests/test_ticker.py
"Make sure calling history to get price data has not introduced more calls to Yahoo than absolutely necessary.
As doing other type of scraping calls than "query2.finance.yahoo.com/v8/finance/chart" to yahoo website
will quickly trigger spam-block when doing bulk download of history data."

That explains the 'The remote server returned an error: (429) Too Many Requests" exception.
So, we have to use the 'chart' API carefully. I guess 1 query per second or something like that. Experience will tell.

@jabacrack
Copy link

I switch to new api, and create new pull request (#77). Unfortunately looks like author abandon this project. Probably, later, I'll create independent fork.

@jabacrack
Copy link

Also, Yahoo Finance often returns error 401 now. It looks like it depends on the time of day, often in the morning, and almost never in the evening or at night.

@jabacrack
Copy link

jabacrack commented Sep 11, 2024

I guess 1 query per second or something like that. Experience will tell.

In my code, I use a 1-second timeout between each request, which successfully works for more than 500 requests.

@yarmoliq
Copy link

Thank you @jabacrack for the fix. It helped me a lot!

@joslat
Copy link

joslat commented Sep 27, 2024

Do you have an example on how is this implemented? or a test to work it out? just getting started with this cool api and hit this issue right away...

@jabacrack
Copy link

@joslat You can look at my merge request or my fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants