Is there a way to automatically download historical prices of stocks from yahoo finance or google finance (csv format)? Preferably in Python.
Bulk Stock Data Series Download at Jason Strimpel Finance. It is no longer necessary to download historical price information from Yahoo! Finance for multiple. 10 New Ways to Download Historical Stock Quotes for Free Here is a list of websites that provide end of day historical data for US and international stock markets. All the quotes data provided by the websites listed here can be exported to CSV or Excel format. Mar 14, 2016 - Short answer: Yes. Use Python's urllib to pull the historical data pages for the stocks you want. Go with Yahoo! Finance; Google is both less reliable, has less. Search for ticker symbols for Stocks, Mutual Funds, ETFs, Indices and Futures on Yahoo! How to scrape Yahoo Finance and extract stock market data using Python & LXML Yahoo Finance is a good source for extracting financial data, be it – stock market data, trading prices or business-related news. Stock Quotes in Excel. Yahoo Finance publishes delayed stock quotes from over 60 world exchanges through the Yahoo YQL web service. Our product Market.rtd allows getting and refreshing these stock quotes in Microsoft Excel.
MaxU5 Answers
Short answer: Yes. Use Python's urllib to pull the historical data pages for the stocks you want. Go with Yahoo! Finance; Google is both less reliable, has less data coverage, and is more restrictive in how you can use it once you have it. Also, I believe Google specifically prohibits you from scraping the data in their ToS.
Longer answer: This is the script I use to pull all the historical data on a particular company. It pulls the historical data page for a particular ticker symbol, then saves it to a csv file named by that symbol. You'll have to provide your own list of ticker symbols that you want to pull.
When you're going to work with such time series in Python, pandas
is indispensable. And here's the good news: it comes with a historical data downloader for Yahoo: pandas.io.data.DataReader
.
![Finance Finance](https://ribon.ch/wp-content/uploads/2017/03/vba1_yahoo-finance.png)
Update for pandas >= 0.19:
The pandas.io.data
module has been removed from pandas>=0.19
onwards. Instead, you should use the separate pandas-datareader
package. Install with:
And then you can do this in Python:
Def_OsDef_OsExtending @Def_Os's answer with an actual demo...
As @Def_Os has already said - using Pandas Datareader makes this task a real fun
pulling all available historical data for AAPL
starting from 1980-01-01
Yahoo Finance Download Stock Data Sheet
first 5 rows
last 5 rows
save all data as CSV file
d:/temp/aapl_data.csv - 5 first rows
MaxUMaxUThere is already a library in Python called yahoo_finance so you'll need to download the library first using the following command line:
Then once you've installed the yahoo_finance library, here's a sample code that will download the data you need from Yahoo Finance:
This should do it. Let me know if it works.
UPDATE:The yahoo_finance library is no longer supported.
You can check out the yahoo_fin package. It was initially created after Yahoo Finance changed their API (documentation is here: http://theautomatic.net/yahoo_fin-documentation).
protected by Community♦Aug 3 '16 at 1:39
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?
Yahoo Finance Download Stock Data App
Not the answer you're looking for? Browse other questions tagged pandasfinanceyahoo-financegoogle-financestockquotes or ask your own question.
The tools finance professionals use to screen securities, gather statistics and analyze market intelligence are invaluable. Unfortunately they can be so expensive that the individual investor typically cannot access them; that’s where Yahoo! Finance can help. Yahoo has a set of tools that rival the professional ones so that individuals will not be at a disadvantage. To use these tools there is an enormous amount of data to go through, so we've provided a guide to help steer users to the top tools for investors.
Ranking of Top Tools
1. Stock Research Center: This tool is the most comprehensive, go-to page on Yahoo! Finance for investors. From here, investors can click on links to get information related to company earnings (dates, surprises, etc.), analysts’ research (company research, upgrade/downgrades, sector analysis), company reports (annual, quarterly, all SEC filings), financial calendars (stock splits, IPOs, M&A, economic data) and research tools (screeners, historical or real time quotes) for stocks, bonds, mutual funds and options.
Let's walk through the steps to get started. First you select the 'Market Data' link on the left side of the home page, then you scroll down 3/4 of the way till you see the 'More Market Stats' box on the right, then select the 'Stock Research Center'.
Once that page loads, you can select from among all the categories. For example, if seeing which companies are reporting earnings today, select 'Company Earnings' then 'Earnings Dates.' Or if you are looking for price trends, select the link for 'Historical Quotes' to get prices for a specific time frame.
2. My Portfolio (NOTE: You have to have a Yahoo account to access this, as it requires you to log it): After utilizing all the resources provided in the Stock Research Center, 'My Portfolio' is perhaps the next most useful tool. It allows investors to track portfolios or securities of interest, customize the screen view, choose fields based on investor interest, such as valuation metrics, estimates and price movements, among others. It even allows investors to input the number of shares purchased and the purchase price to track gains or losses. Not only can investors maintain current information, Yahoo! Finance turns that list of tickers into the news feeds for users, tailoring which news stories the user receives based on the tickers in the portfolios. Finally the tool allows users to sync up with other sites to their actual portfolios.
Let's go through an example. The following stocks are in a portfolio: American Airlines (AAL), General Electric (GE) and Apple (AAPL). To Track these names, first select 'My Portfolio' on the left side of the home page. From the 'My Portfolio' page select 'Create New.'
The page opens to allow input of a portfolio name, ticker symbols, market indices and allows for the selection of which stock characteristics are of interest to view (it is automatically set to 'default'). This screen also allows linkage to brokerage accounts.
As you can see the output screen provides an easy way to track all investments in the portfolio and at the bottom in the 'Recent News' section, the news stories are directly related to the stocks in the portfolio.
3. Market Data: This section covers every asset class and provides a quick glance of the current market - from performance of various indices, to stock movers, to an index decliner/advancer heat map - giving investors a complete overall picture of the trading day. To get to this page, select 'Market Data' on the left side of the home page. (We did this previously when accessing the Stock Research Center).
The Bottom Line
Professional investment tools are typically out of reach of the individual investor, but by using the tools hosted by Yahoo! Finance, individuals can intelligently research and track securities.