Yahoo Finance Download Historical Data

I have used the following url to fetch the historical data from yahoo finance. From last 16th May, 2017 the url is not working.

Seems like they have changed the url and the new url is:

In the above changed URL has a session cookie which is crumb. Is there any idea how to get this cookie programmatically(in JAVA)?

SuvonkarSuvonkar

7 Answers

Got it to work, now I just have to parse the csv. Thought I'd share since I was having trouble with the syntax.

jakhtar4299jakhtar4299

If you have a direct link to the Yahoo Finance page of the stock you are looking for, open it in a separate browser window then proceed with the 'Download historical data' section. If you haven't found the wanted stock's direct link you can search for it by name or by ISIN code as described in the ' Searching for stocks on Yahoo! From YAHOO.com Historical Data, right clicked on “Download Data” and selected “Copy shortcut” to get the URL and crumb. I added this to my Excel download and I can build working URLs (that download the data when I manually copy the URL to my browser).

I recently wrote a simple python script to download the history of a single stock.
Here an example how to invoke it:
python get_quote_history.py --symbol=IBM --from=2017-01-01 --to=2017-05-25 -o IBM.csv
This will download IBM historical prices from 2017-01-01 to 2017-05-25 and save them in IBM.csv file.

Andrea GaleazziAndrea Galeazzi

Andrea Galeazzi's excellent answer; with added options for splits and dividends, and twisted for python 3.

Also changed so 'to:date' is included in the returned results, previously code returned up to but not including 'to:date'. Just different!

And be aware that Yahoo made minor changes in price rounding, column order, and split syntax.

Jack ThreadfinJack Threadfin

You can manually save the crumb/cookie pair in Chrome or you can use something like this to generate it. Then, just set the cookie header in java and pass the corresponding crumb in the URL

MarkMark

I have wrote a lightweight script that pulls together alot of the suggestions in this thread to fix this problem. https://github.com/AndrewRPorter/yahoo-historical

However, there are much better solutions such as, https://github.com/ranaroussi/fix-yahoo-finance

Yahoo

Hope these resources help!

APorter1031APorter1031

I developed the following solution for this issue in Excel/VBA. The key challenge was the creation of the Crumb / Cookie pair. Once that is created you can re-use it for calls to Yahoo for the historical prices.

See here the key code for the Crumb / Cookie

See the following Yahoo Historical Price Extract on my website for a Sample Excel workbook that demonstrates how to extract Yahoo Historical prices

scott56hannahscott56hannah

Great answer Andrea, I have added to your code to allow for downloads of multiple stocks. (python 2.7)

file1: down.py

file2: ticker.csvAAPLMSFT

Yahoo Finance Download Historical Data Center

file3: get_quote_history.py

Yahoo Finance Download Historical Data Calculator

hk'hk'

protected by CommunityJun 6 '17 at 16:37

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged cookiessession-cookiesfinanceyahoo-apiyahoo-finance or ask your own question.