dennislwy / yahoofinanceapi Goto Github PK
View Code? Open in Web Editor NEW.NET Yahoo Finance API (which uses cookie and crumb)
License: MIT License
.NET Yahoo Finance API (which uses cookie and crumb)
License: MIT License
HI,
First of all great work and it help me a lot, but i think that i found an issue.
You are only assuming that the decimal symbol is '.' but it can be also ',' (European countries use this symbol)
So in the method ParsePriceAsync, inside Historical class, when you call Convert.ToDouble it will raise an exception. Before the cycle 'For' you need to add this line to don't have any problem with the decimal symbol
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Hi Dennis,
Yesterday I tried your modified code for asynchronous operations.
First, the "csvData" is completely collected, but somehow the task "ParsePriceAsync" does not end. Am I doing something wrong? I can't get the final "List" with HistoryPrices. Im not so firm with asynchronous programming, can you please check that!?
Thank you very much.
I'm getting the following errors when trying to run the bat file. I've tried re-installing package using nugget but still no luck. In VS2017 the code seems fine and doesn't throw error.
YahooFinanceAPI\Utils\Json.cs(2,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
YahooFinanceAPI\Utils\Json.cs(3,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
YahooFinanceAPI\Utils\Json.cs(19,54): error CS0246: The type or namespace name 'JsonReader' could not be found (are you missing a using directive or an assembly reference?)
YahooFinanceAPI\Utils\Json.cs(24,54): error CS0246: The type or namespace name 'JToken' could not be found (are you missing a using directive or an assembly reference?)
YahooFinanceAPI\Utils\Json.cs(34,71): error CS0246: The type or namespace name 'Formatting' could not be found (are you missing a using directive or an assembly reference?)
YahooFinanceAPI\Utils\Json.cs(11,33): error CS0246: The type or namespace name 'JsonSerializerSettings' could not be found (are you missing a using directive or an assembly reference?)
YahooFinanceAPI\Utils\Json.cs(12,33): error CS0246: The type or namespace name 'JsonSerializer' could not be found (are you missing a using directive or an assembly reference?)```
Hi,
First of all, thanks for the work.
I'm currently using the project for a finance app of mine.
I'm facing an issue while using Mono : it loops without finding the cookie / crumb.
Work very well while using VS2017 CE.
Is it something you already came across ?
I tried using different versions of System.Net.Http, thinking that depending on the version, the web page could differ, but was not that...
Thks.
Hi there,
I got the following error:
FlurlHttpException: GET https://query1.finance.yahoo.com/v7/finance/quote?symbols=AAPL&fields=regularMarketOpen%2CregularMarketDayHigh%2CregularMarketDayLow%2CregularMarketPrice failed with status code 401 (Unauthorized).
Response body:
{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Cookie"}}}
It seems it requires cookies.
Could you pls help me?
Regards
LUCA
Apparently, something has changed in the last couple of days. The error seems to suggest that some user authentication is missing. Any Idea?
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 401 for URL: https://query1.finance.yahoo.com/v7/finance/download/GOOG?period1=1369346400&period2=1527112800&interval=1d&crumb=
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1889)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1884)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1883)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1456)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at yahoofinance.histquotes2.HistQuotes2Request.getResult(HistQuotes2Request.java:132)
at yahoofinance.Stock.getHistory(Stock.java:327)
Hi
I'm new to C# and Microsoft visual studio, but I have downloaded your program and tried to run it directly, but get the error - A project with an Output Type of Class Library cannot be started directly. What am I doing wrong?
Best regards
Hi Dennis,
Thanks for your work.
The only correction is needed in description (README). As I have selectively checked, OHLC prices are not adjusted for dividends (but still adjusted for splits). The field AdjClose in now not adjusted for dividends as it was earlier.
pip3 install -r requirements.txt
Requirement already satisfied: certifi==2019.6.16 in c:\python36\lib\site-packages (from -r requirements.txt (line 1)) (2019.6.16)
Requirement already satisfied: chardet==3.0.4 in c:\python36\lib\site-packages (from -r requirements.txt (line 2)) (3.0.4)
Requirement already satisfied: cycler==0.10.0 in c:\users\vincent\appdata\local\programs\python\python36\lib\site-packages (from -r requirements.txt (line 3)) (0.10.0)
Requirement already satisfied: DateTime==4.3 in c:\python36\lib\site-packages (from -r requirements.txt (line 4)) (4.3)
Requirement already satisfied: idna==2.8 in c:\python36\lib\site-packages (from -r requirements.txt (line 5)) (2.8)
ERROR: Could not find a version that satisfies the requirement joblib==1.2.0 (from versions: 0.3.2d.dev, 0.3.2e.dev, 0.3.2f.dev, 0.3.2g.dev, 0.7.0d, 0.1a0.dev0, 0.2a0.dev0, 0.3a0.dev0, 0.3.1a0.dev0, 0.3.2.dev0, 0.3.2a0.dev0, 0.3.2b0.dev0, 0.3.2rc0.dev0, 0.3.3a0.dev0, 0.3.3b0.dev0, 0.3.3rc0.dev0, 0.3.4.dev0, 0.3.5.dev0, 0.3.6.dev0, 0.3.7.dev0, 0.4.0.dev0, 0.4.1.dev0, 0.4.2.dev0, 0.4.3.dev0, 0.4.4.dev0, 0.4.5.dev0, 0.4.6.dev0, 0.5.0.dev0, 0.5.0a0.dev0, 0.5.1.dev0, 0.5.2.dev0, 0.5.3.dev0, 0.5.4.dev0, 0.5.5.dev0, 0.5.6.dev0, 0.5.7.dev0, 0.5.7a0.dev0, 0.5.7b0.dev0, 0.5.7, 0.6.0a0, 0.6.0b0, 0.6.0b2, 0.6.0b3, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.7.0a0, 0.7.0b0, 0.7.0rc0, 0.7.1, 0.8.0a0, 0.8.0a2, 0.8.0a3, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.3.post1, 0.8.4, 0.9.0b2, 0.9.0b3, 0.9.0b4, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.10.0, 0.10.2, 0.10.3, 0.11a3, 0.11, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.12.5, 0.13.0, 0.13.1, 0.13.2, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.17.0, 1.0.0, 1.0.1, 1.1.0a0, 1.1.0, 1.1.1)
ERROR: No matching distribution found for joblib==1.2.0
At first, I would like to thank you for the code!
The code was working perfectly till yesterday, now the code in Historical.cs loops forever because the value in the if statement is HttpStatusCode.Unauthorized. The code gets a cookie value! Has Yahoo changed something in the api or is something in the code.
Looking forward to hearing from you. Thanking you in advance.
Panos Kourtesis
Hi
I've got your coding working or rather I just pushed the right button;) anyway, I'm trying to download historical prices on a weekly interval back 365 days for several tickers at the same time, but after a couple of tickers, it will return and the following error
Is there some kind of limit to how many times you can download? And would it be possible to work around this, by renewing the crumb? And how would you do this?
Best regards
Any idea how i can download intradays data?
I used
http://chartapi.finance.yahoo.com/instrument/1.1/[TICKER]/chartdata;type=quote;range=5d/csv
Now i tried with
https://query1.finance.yahoo.com/v7/finance/download/{0}?range=5d&interval=5m&crumb={1}
but not working as expected
Hi there,
This is a question more than a bug, I'm wondering how I would detect when yahoo data is pretty much returning the wrong data, 0 for multiple stocks.
I.e. I recently noticed that I requested 100 stocks and the stock price was 0 on yahoo's end, is there something in the api that tells me if the data being requested isn't right? or do I just have to loop through each stock and check if the value is 0?
Wouldn't it be better and more effective to replace this line
csvData = wc.DownloadString(url);
with this:
csvData = await wc.DownloadStringAsync(url);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.