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

System.InvalidOperationException: Result has no value. #34

Open
twestosaurus opened this issue Sep 11, 2024 · 10 comments
Open

System.InvalidOperationException: Result has no value. #34

twestosaurus opened this issue Sep 11, 2024 · 10 comments

Comments

@twestosaurus
Copy link

Hello,

there seems to be no data returned since yesterday and I'm getting this error

System.InvalidOperationException: Result has no value.
   at YahooQuotesApi.Result`1.get_Value() in C:\projects\yahooquotesapi\YahooQuotesApi\Utilities\Result.cs:line 23

since yesterday (from EU) - it doesn't look like another cookie & crumb issue. I tried it with version 6.0.0. and 5.5.8.. Anyone has an idea what might be the cause?

@zeabee
Copy link

zeabee commented Sep 11, 2024

I have the same issue (UK). It looks like the field PriceHistory cannot be retrieved. Looking at the error (in Visual Studio) it says:

PriceHistory {Error: ErrorResult { Message = Response status code does not indicate success: 401 (Unauthorized)., Exception = System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at YahooQuotesApi.YahooHistory.Produce[T](Uri uri, CancellationToken ct) in C:\projects\yahooquotesapi\YahooQuotesApi\History\YahooHistory.cs:line 73 }} YahooQuotesApi.Result<YahooQuotesApi.PriceTick[]>

No idea what is causing it but VPNing into the US did not solve the problem.

@drakovic23
Copy link

I have the same issue, other packages like the yfinance python package also have reports of similar issues. Hopefully Yahoo hasn't pulled the plug.

@sachatomey
Copy link

Issue persists. Some top level data (name, current price etc) is returned but price history is missing.

@drakovic23
Copy link

I tested the Python yFinance package and it works now, not sure if the previous issue was related to the issue with this package.
I think the issue is that this package uses the https://query2.finance.yahoo.com/v7/finance/download/{ticker} url whereas the Python yFinance package uses the JSON returned from https://query2.finance.yahoo.com/v8/finance/chart/{ticker} as an example.

If I try to download a csv of historical data from Yahoo Finance it now requires me to login which it didn't before.

Here's another example of calling historical data on AAPL using the yFinance method:

https://query2.finance.yahoo.com/v8/finance/chart/AAPL?period1=345448861&period2=1726203661&interval=1d&events=div,splits

The above returns JSON data which can be used to construct the price ticks.

@twestosaurus
Copy link
Author

@drakovic23 thanks for the addtitional info - so if I see correctly it should be possible to change the url in this package, right? I just quickly tried the url from the python package with c# and no matter what headers I added to the httpclient I always got a error "429 - too many requests".

@drakovic23
Copy link

drakovic23 commented Sep 18, 2024

I think the only header I had to adjust was the text/json to text/csv. The real issue is that the tickparser parses CSV data whereas the other URL returns JSON so if you adjust the URL you'd have to adjust the tickparser as well.

I created a fork here: https://github.com/drakovic23/YahooQuotesApiFork that currently pulls price history correctly however it fails 2 tests, one is a rounding error to do with history in a different base currency that I am stuck on and I'm not sure about the other test that is failing at the moment. I'll try to get the tests to pass and then cleanup the code a bit as it's a mess right now. I also didn't add any other dependencies but it may be better to use a different JSON parsing mechanism possibly from the Newtonsoft package.

EDIT:
Also I'm new to this so if anyone has any better ideas or comments please let me know. Idk if the authors are maintaining this package and I had to fix the history issue quickly for a separate project, my fork should not be used in production.

@twestosaurus
Copy link
Author

@drakovic23 thanks for your effort! - i will try your package when I have time and maybe also have a look at the tickerparser (and in the meantime hope that maybe @dshe reappears)

@rwb196884
Copy link

Ta @drakovic23 ; that's got me up and running again.

@dshe
Copy link
Owner

dshe commented Oct 30, 2024

The new version now provides price history. Sorry for the delay!

@ymilad
Copy link

ymilad commented Nov 2, 2024

The new version now provides price history. Sorry for the delay!

it works, thank you

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