Importing Historical Stock Prices from Yahoo into Excel
This Excel spreadsheet imports historical stock prices from Yahoo Finance (www.cronistalascolonias.com.ar). You dont need to manually import data with text files. You simply need to specify a ticker symbol, your start and end dates, and then click a button.
Once you click the button, Excel (after calling a VBA function) connects to Yahoo Finance and retrieves daily stock quotes, placing the data into a sheet called Data
Currently, the spreadsheet imports the date (in day/month/year format), opening price, daily high, daily low, closing price, trading volume and the adjusted close. All prices are in US dollars.
Youre free to manipulate and analyze the data once its in Excel. As an example of some trivial analysis, clicking a button in the spreadsheet gives the arithmetic mean, the variance and the standard deviation of the daily returns (based upon the daily closing price).
You could also perform far more advanced analyses (which Ill discuss in future blog posts). For example, Ive used this variations of this spreadsheet to calculate investment ratios (e.g. Sharpe, Sortino and Treynor Ratios), plot histograms of daily returns to check if theyre normally distributed, identified stocks with my desired risk characteristics, and calculate mean-variance optimal portfolios.
The VBA that retrieves the data from Yahoo was adapted from code found at www.cronistalascolonias.com.ar It can be modified to download other data found on the web.
Youll need to enable macros before you use the spreadsheet (Excel may warn you that youre importing a macro-enabled worksheet).
UPDATE July 17th Heres an Excel spreadsheet that downloads historical Forex rates for two currency pairs between two dates
UPDATE 18th August Heres a Mathcad worksheet to download stock quotes from Yahoo Finance
UPDATE 14th February Download historical quotes into Excel for multiple stock tickers here
UPDATE 5th January Ive just evaluated a financial data add-in for Excel MarketXLS. Its a rock-solid route to getting live stock data inside Excel. You just use one of 80 new functions together with your chosen ticker. Disclaimer: the link to MarketXLS is an affiliate link, but this has not influenced my opinion of the tool.
UPDATE July 6th The old Yahoo Finance API was discontinued, so the spreadsheet stopped working for a while. However, Ive now uploaded a new working version
Download Excel spreadsheet to import historical stock prices from Yahoo
-
-
-