You are on page 1of 6

How to Import Share Price Data into Excel - Market Index

1 of 6

http://www.marketindex.com.au/yahoo-finance-api

Yahoo Finance API

How to Import Share Price Data into Excel (with Yahoo! Finance)
Last Updated: 23 September 2015
Editor's Note: This software is non-commercial and for personal use only. No support is available.

Yahoo! and Google both unofficially provide a free way to download stock quotes using an API.
Yahoo! Finance
Financial data can be downloaded in a CSV, imported into an existing Excel Spreadsheet, or downloaded in XML / JSON
formatted data to display on a website using the Yahoo! Query Language (YQL) API.
Google Finance
Share price data can be imported into an existing Excel spreadsheet or downloaded in a JSON string for use on a website.
This article will cover two uses of the Yahoo! Finance API.
1. How to download Share Price Data in a CSV
2. How to Import Share Price Data into an Excel Spreadsheet

Disclaimer
Displaying share price data on a website (even delayed data) usually requires a license from
the relevant stock exchange/s.
The Google Finance API was officially deprecated in June 2011. It may cease to work at any
time.
The Yahoo Finance API is not officially supported and prone to glitches and inaccurate
data. Use for commercial reasons may result in a breach of Yahoo!s T&Cs.

How to Download Share Price Data in a CSV


Yahoo! Finance provides the simplest way to import financial data into a spreadsheet. The data (including stock prices, indices
and company fundamentals) can be automatically downloaded in a CSV by simply entering a URL into your browsers address
bar. The CSV can then be opened in Excel and manipulated as required.
Real-time data is limited to a few US exchanges and most countries have a 10-30min delay due to licensing restrictions.

Step 1: Call the Yahoo! Finance API


Start with the base URL: http://finance.yahoo.com/d/quotes.csv

Step 2: Add stock codes


Add ?s= to your base URL followed by the stock symbols you want to download.
To download multiple companies at once, simply use the + sign in between the company codes.
http://finance.yahoo.com/d/quotes.csv?s=^AORD+BHP.AX+BLT.L+AAPL
The above URL will call:
Australian All Ordinaries Index
BHP Billiton Ltd in Australia
BHP Billiton Ltd in UK
Apple Inc. in USA.

How to Find the Correct Stock Code


All listed companies have a stock ticker between 1 and 4 characters. E.g. Apple has the stock ticker AAPL.

As there are multiple exchanges around the world, you must specify which exchange your code relates to
by adding a suffix.
Australian listed companies require the suffix .AX to be added to the companies

11/12/2015 8:19 PM

How to Import Share Price Data into Excel - Market Index

2 of 6

http://www.marketindex.com.au/yahoo-finance-api

stock code (e.g. BHP.AX).


UK listed companies require the suffix .L to be added to the companies stock code
(e.g. BLT.L).
Note: Most US listed companies do not require a suffix

Most stock indices use a ^" prefix prior to the index code along with a country identifier.
The Australian All Ordinaries index has the prefix ^A (e.g. ^AORD).
The NASDAQ Composite uses the code ^IXIC.

To find the correct suffix for a company or prefix for an index, visit http://finance.yahoo.com and
start typing the name of the company into the Look Up box.

Step 3: Specify the information you want to download using "Tags"


Add &f= to your URL string followed by the Yahoo! Tags for the data you want to download.
http://finance.yahoo.com/d/quotes.csv?s=^AORD+BHP.AX+BLT.L+AAPL&f=nd1l1v
The above URL will fetch:
Name
Last Trade Date
Last Trade Price
Volume

Yahoo! Tags

Company Details

Name

Stock Exchange

j1

Market Capitalisation

f6

Float Shares

b4

Book Value

Trading Data

Applicable to the most recent trading

Bid

day (including today).

a5

Ask Size

b6

Bid Size

d1

Last trade Date

t1

Last trade Time

l1

Last trade Price

k3

Last trade Size

c1

Change

p2

Change in Percent

Open

Day's High

Ask

11/12/2015 8:19 PM

How to Import Share Price Data into Excel - Market Index

3 of 6

http://www.marketindex.com.au/yahoo-finance-api

Day's Low

Day's Range

Volume

a2

Average Daily Volume

Previous Close

Historical Performance

52-week Range

52-week data only.

52-week High

52-week Low

k4

Change From 52-week High

j5

Change From 52-week Low

k5

% Change From 52-week High

j6

% Change From 52-week Low

Fundamental Analysis

Earnings/Share

Dividend and Target Price data are

j4

EBITDA

not always available and often

P/E Ratio

restricted to US listed companies.

r5

PEG Ratio

Dividend/Share

Ex-Dividend Date

r1

Dividend Pay Date

Dividend Yield

t8

1 yr Target Price

Technical Analysis

m3

50-day Moving Average

The 50 and 200 day moving

m4

200-day Moving Average

averages are two of the most

m5

Change From 200-day Moving Average

commonly used indicators in the

m6

Percent Change From 200-day Moving Average

finance industry.

m7

Change From 50-day Moving Average

m8

Percent Change From 50-day Moving Average

Step 4: Download the CSV


Enter the above URL strong into your browsers address bar and hit return/enter. The CSV will be automatically downloaded to
your computer.

How to Import Share Price Data into an Excel Spreadsheet


Excel provides a simple way to download financial data into a preconfigured spreadsheet at the click of a button.
Only advanced users can create a spreadsheet as Macros are required to download the data. For the less tech-savvy, here's
a spreadsheet that will do the hard work for you.

Click to download
Yahoo! Share Price Spreadsheet (XLS)

You will get two warnings when you open the file:
1. The workbook contains Marcos (to process the data)
2. The workbook requires a data connection (to download data from the internet - duh!)
You must accept/enable both for the spreadsheet to work. The Macros are not password protected so you are free to view
and manipulate all code anyway you like.

11/12/2015 8:19 PM

How to Import Share Price Data into Excel - Market Index

4 of 6

http://www.marketindex.com.au/yahoo-finance-api

STEP 1: Open the Spreadsheet


The Spreadsheet is in XLS so its backwards compatible to MS Excel 97. Saving it as an .XLSX will break the spreadsheet.

STEP 2: Enter Stock Codes into Column A


Dont forget to add the correct suffix or prefix as detailed above.

STEP 3: Click the Download Data Button

A few caveats:
Dow Jones data will not import due to licensing restrictions.
Financial data (e.g. dividends, ratios and target prices) are often only available for US listed
companies.
Most exchanges have a delay on their data of 10 - 30mins.
Youre limited to calling 200 codes at a time.

Want to select your own column headers?


No problem.
Enter the Yahoo! Tags for the information you want to download into cell C2. The data will be displayed in the order you

11/12/2015 8:19 PM

How to Import Share Price Data into Excel - Market Index

5 of 6

http://www.marketindex.com.au/yahoo-finance-api

specify in the Yahoo! Tag string. You will need to rename the column headers to match the order of the tags you specified in
C2.

Using Google Docs (Sheets)?


You can use the Yahoo Finance API to import data into Google Docs (Sheets) by using the =IMPORTDATA
function. For example:
=IMPORTDATA("http://finance.yahoo.com/d/quotes.csv?s=AAPL&f=nd1l1")

Video Instructions

Related Links
Yahoo! Query Language
https://developer.yahoo.com/yql/
Yahoo Finance APIs
https://code.google.com/p/yahoo-finance-managed/wiki/YahooFinanceAPIs
How to import Yahoo stock data into a website
https://developer.yahoo.com/yql/console/
How to display a Yahoo stock chart on a web page
https://code.google.com/p/yahoo-finance-managed/wiki/miscapiImageDownload
How to pull stock quotes from Google Finance for a website
http://digitalpbk.com/stock/google-finance-get-stock-quote-realtime

ADVERTISE WITH US

Editor's Picks

Indices

Resources

ASX Analysis

11/12/2015 8:19 PM

How to Import Share Price Data into Excel - Market Index

6 of 6

http://www.marketindex.com.au/yahoo-finance-api

1. How to Buy Shares in Australia (for beginners)

ASX 20

Homepage

Market Outlook

2. How to Import Share Price Data into Excel

ASX 50

Trading Hours

Stock Tips

3. ASX Filter - Reduce Risk & Limit Losses

ASX 100

Index Methodology

Dividend Yield

4. Top 10 Finance Movies & Documentaries

ASX 200

History of the ASX

Consensus Data

5. Basics of Dividend Yield Investing

ASX 300

RBA Interest Rate

6. Five Classic Books (Free Download)

All Ordinaries

ASX Short Selling

Follow Us

7. My Favourite Apps for Smartphone & Tablet Users

About Us

Advertise with Us

T&Cs

Privacy

Contact Us

MarketIndex.com.au and its data suppliers accept no responsibility for any claim, loss or damage as a result of information on this website.
All website content is provided "as is" and not for trading purposes. No information should be considered financial advice or used to make an investment decision.
Copyright 2015 Market Index. All rights reserved.

11/12/2015 8:19 PM

You might also like