C# Code, Tutorials and Full Visual Studio Projects

Using the Yahoo Finance API for CSV

Posted by on Feb 25, 2012 in API, Code Snippets, Featured, Financial | 135 comments

Using the Yahoo Finance API for CSV

How the Free Yahoo Finance API Works

Yahoo finance provides a great and simple way to download free stock quotes. This service returns stock data in a CSV. (comma delimited format, you can just open it in Excel if you like)

The service Yahoo finance provides for free stock quotes is REST based. (love REST based stuff) So all you need to do is assemble the URL you want and it will give you the data your looking for.

The API lets you specify multiple symbols to download with a maximum of 200 per call. (You can make multiple calls, but if you call too fast it will lock your IP so be warned)

How to call the free Yahoo Finance API

The base url your going to call is http://finance.yahoo.com/d/quotes.csv

Then you add a ?s= and the stock symbols your interested in such as APPL, GOOG and MSFT like so


Then you specify the info you want. There is a large list of stuff you can specify, just look at the list below for more info.


This will get the name of the stock, the ask price and bid price (the “nab” = name,ask and bid)

Financial Data you can Download

Pricing Dividends
a: Ask y: Dividend Yield
b: Bid d: Dividend per Share
b2: Ask (Realtime) r1: Dividend Pay Date
b3: Bid (Realtime) q: Ex-Dividend Date
p: Previous Close
o: Open
c1: Change d1: Last Trade Date
c: Change & Percent Change d2: Trade Date
c6: Change (Realtime) t1: Last Trade Time
k2: Change Percent (Realtime)
p2: Change in Percent
c8: After Hours Change (Realtime) m5: Change From 200 Day Moving Average
c3: Commission m6: Percent Change From 200 Day Moving Average
g: Day’s Low m7: Change From 50 Day Moving Average
h: Day’s High m8: Percent Change From 50 Day Moving Average
k1: Last Trade (Realtime) With Time m3: 50 Day Moving Average
l: Last Trade (With Time) m4: 200 Day Moving Average
l1: Last Trade (Price Only)
t8: 1 yr Target Price
w1: Day’s Value Change g1: Holdings Gain Percent
w4: Day’s Value Change (Realtime) g3: Annualized Gain
p1: Price Paid g4: Holdings Gain
m: Day’s Range g5: Holdings Gain Percent (Realtime)
m2: Day’s Range (Realtime) g6: Holdings Gain (Realtime)
52 Week Pricing Symbol Info
k: 52 Week High v: More Info
j: 52 week Low j1: Market Capitalization
j5: Change From 52 Week Low j3: Market Cap (Realtime)
k4: Change From 52 week High f6: Float Shares
j6: Percent Change From 52 week Low n: Name
k5: Percent Change From 52 week High n4: Notes
w: 52 week Range s: Symbol
s1: Shares Owned
x: Stock Exchange
j2: Shares Outstanding
v: Volume
a5: Ask Size
b6: Bid Size Misc
k3: Last Trade Size t7: Ticker Trend
a2: Average Daily Volume t6: Trade Links
i5: Order Book (Realtime)
Ratios l2: High Limit
e: Earnings per Share l3: Low Limit
e7: EPS Estimate Current Year v1: Holdings Value
e8: EPS Estimate Next Year v7: Holdings Value (Realtime)
e9: EPS Estimate Next Quarter s6 Revenue
b4: Book Value
p5: Price / Sales
p6: Price / Book
r: P/E Ratio
r2: P/E Ratio (Realtime)
r5: PEG Ratio
r6: Price / EPS Estimate Current Year
r7: Price / EPS Estimate Next Year
s7: Short Ratio

Getting Stock Data in C#

Since this is a REST based finance API, to get the data using C# is easy. You can simply use a WebClient.DownloadString(myurl) to get the data. Once you get the data, it’s also easy to parse being a simple CSV format.

Download Source Code

Here is a quick example of how you can use the free Yahoo Finance API in your C# code.

Application Entry Point (main)

using System;
using System.Collections.Generic;
using System.Net;
using jarloo;

namespace Jarloo
    internal class Program
        private static void Main(string[] args)
            string csvData;

            using (WebClient web = new WebClient())
                csvData = web.DownloadString("http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT&f=snbaopl1");

            List<Price> prices = YahooFinance.Parse(csvData);

            foreach (Price price in prices)
                Console.WriteLine(string.Format("{0} ({1})  Bid:{2} Offer:{3} Last:{4} Open: {5} PreviousClose:{6}",price.Name,price.Symbol,price.Bid,price.Ask,price.Last,price.Open,price.PreviousClose));



Parsing Class and State Bag

using System;
using System.Collections.Generic;

namespace jarloo
    public static class YahooFinance
        public static List<Price> Parse(string csvData)
            List<Price> prices = new List<Price>();

            string[] rows = csvData.Replace("\r", "").Split('\n');

            foreach (string row in rows)
                if (string.IsNullOrEmpty(row)) continue;

                string[] cols = row.Split(',');

                Price p = new Price();
                p.Symbol = cols[0];
                p.Name = cols[1];
                p.Bid = Convert.ToDecimal(cols[2]);
                p.Ask = Convert.ToDecimal(cols[3]);
                p.Open = Convert.ToDecimal(cols[4]);
                p.PreviousClose = Convert.ToDecimal(cols[5]);
                p.Last = Convert.ToDecimal(cols[6]);


            return prices;

    public class Price
        public string Symbol { get; set; }
        public string Name { get; set; }
        public decimal Bid { get; set; }
        public decimal Ask { get; set; }
        public decimal Open { get; set; }
        public decimal PreviousClose { get; set; }
        public decimal Last { get; set; }

Exchanges and Yahoo

Had lots of people asking how to get stuff from Non-US exchanges. Being a good Canadian myself I’ve been looking into it, and here is the master Yahoo Exhcange List for all your data scraping goodness!

Country Exchange Suffix Delay Data Provider
United States of America American Stock Exchange N/A 15 min Direct from Exchange
United States of America BATS Exchange N/A Real-time Direct from Exchange
United States of America Chicago Board of Trade .CBT 10 min Interactive Data Real-Time Services
United States of America Chicago Mercantile Exchange .CME 10 min Interactive Data Real-Time Services
United States of America Dow Jones Indexes N/A Real-time Interactive Data Real-Time Services
United States of America NASDAQ Stock Exchange N/A 15 min Direct from Exchange
United States of America New York Board of Trade .NYB 30 min Interactive Data Real-Time Services
United States of America New York Commodities Exchange .CMX 30 min Interactive Data Real-Time Services
United States of America New York Mercantile Exchange .NYM 30 min Interactive Data Real-Time Services
United States of America New York Stock Exchange N/A 15 min Direct from Exchange
United States of America OTC Bulletin Board Market .OB 20 min Direct from Exchange
United States of America Pink Sheets .PK 15 min Direct from Exchange
United States of America S & P Indices N/A Real-time Interactive Data Real-Time Services
Argentina Buenos Aires Stock Exchange .BA 30 min Interactive Data Real-Time Services
Austria Vienna Stock Exchange .VI 15 min Telekurs
Australia Australian Stock Exchange .AX 20 min Interactive Data Real-Time Services
Belgium Brussels Stocks .BR 15 min
Brazil BOVESPA – Sao Paolo Stock Exchange .SA 15 min Interactive Data Real-Time Services
Canada Toronto Stock Exchange .TO 15 min Interactive Data Real-Time Services
Canada TSX Venture Exchange .V 15 min Interactive Data Real-Time Services
Chile Santiago Stock Exchange .SN 15 min Interactive Data Real-Time Services
China Shanghai Stock Exchange .SS 30 min Interactive Data Real-Time Services
China Shenzhen Stock Exchange .SZ 30 min Interactive Data Real-Time Services
Denmark Copenhagen Stock Exchange .CO 15 min Telekurs
France Euronext .NX 15 min Telekurs
France Paris Stock Exchange .PA 15 min Telekurs
Germany Berlin Stock Exchange .BE 15 min Telekurs
Germany Bremen Stock Exchange .BM 15 min Telekurs
Germany Dusseldorf Stock Exchange .DU 15 min Telekurs
Germany Frankfurt Stock Exchange .F 15 min Telekurs
Germany Hamburg Stock Exchange .HM 15 min Telekurs
Germany Hanover Stock Exchange .HA 15 min Telekurs
Germany Munich Stock Exchange .MU 15 min Telekurs
Germany Stuttgart Stock Exchange .SG 15 min Telekurs
Germany XETRA Stock Exchange .DE 15 min Telekurs
Hong Kong Hong Kong Stock Exchange .HK 15 min Interactive Data Real-Time Services
India Bombay Stock Exchange .BO 15 min Interactive Data Real-Time Services
India National Stock Exchange of India .NS 15 min National Stock Exchange of India
Indonesia Jakarta Stock Exchange .JK 10 min Interactive Data Real-Time Services
Israel Tel Aviv Stock Exchange .TA 20 min Telekurs
Italy Milan Stock Exchange .MI 20 min Telekurs
Japan Nikkei Indices N/A 30 min Interactive Data Real-Time Services
Mexico Mexico Stock Exchange .MX 20 min Telekurs
Netherlands Amsterdam Stock Exchange .AS 15 min Telekurs
New Zealand New Zealand Stock Exchange .NZ 20 min Interactive Data Real-Time Services
Norway Oslo Stock Exchange .OL 15 min Telekurs
Portugal Lisbon Stocks .LS 15 min
Singapore Singapore Stock Exchange .SI 20 min Interactive Data Real-Time Services
South Korea Korea Stock Exchange .KS 20 min Interactive Data Real-Time Services
South Korea KOSDAQ .KQ 20 min Interactive Data Real-Time Services
Spain Barcelona Stock Exchange .BC 15 min Telekurs
Spain Bilbao Stock Exchange .BI 15 min Telekurs
Spain Madrid Fixed Income Market .MF 15 min Telekurs
Spain Madrid SE C.A.T.S. .MC 15 min Telekurs
Spain Madrid Stock Exchange .MA 15 min Telekurs
Sweden Stockholm Stock Exchange .ST 15 min Telekurs
Switzerland Swiss Exchange .SW 30 min Telekurs
Taiwan Taiwan OTC Exchange .TWO 20 min Interactive Data Real-Time Services
Taiwan Taiwan Stock Exchange .TW 20 min Interactive Data Real-Time Services
United Kingdom FTSE Indices N/A 15 min Telekurs
United Kingdom London Stock Exchange .L 20 min Telekurs


Join the conversation and post a comment.

  1. sebastian

    Great article! One thing I come to think off is how to use this to compare different stocks and how they are valued to each other. I was thinking about getting a list of stocks with it short names. Do u know where to find such lists?

    Keep up the good work :)


  2. admin

    EODData has a good list of stock tickers if that is what you looking for. You need to sign up but it’s free and then you can download the lists. http://www.eoddata.com/download.aspx

    BATS Also has a great list you can use, I have a quick article on how to get that data here http://www.jarloo.com/download-stock-symbols/

  3. lalas

    Would it possible to make the source code for this project available for download? If i do a simple copy and paste, i would be get an error for using Jarloo.

    Sorry if that is a trivial request, but i am kinda new to C# and i would like to use your website to help me learn.

    Thank you

  4. admin

    @LALAS I posted the Visual Studio project, you can download from the big green button above.

  5. lalas

    Cheers.. :)

  6. Uri G

    Is there anyway to retrieve the stocks Beta (risk) in a specific date?

  7. Tom Peirce

    Is there any way to specify a certain stock market? Some stocks codes overlap with another on a different exchange, (e.g TSCO is Tesco in UK and a tractor company in US, and this always returns the US one.)


  8. Hugh Brown

    TSCO.L is the ticker Yahoo uses for Tesco in London. In general, you’ll have to look up the suffixes for the exchanges.

  9. kevin

    May I know how to retrieve stock option detail quotes ?

  10. DARSH

    Hi, I would like to know whether this method is actually using yahoo finance api or Yahoo Query Language ? I’m a bit confused. Could you please give some clarification regarding the same?

  11. admin

    This uses an API and does NOT use YQL. The API has been around for years and works quite well.

  12. Thomas

    Can monthly and weekly prices be downloaded through this api? If so how is it done?

  13. admin

    As far as I am aware only dailies are available.

  14. Sam

    How do you get these information, can you share with us where is the Yahoo official documentation so we can always access the latest info from Yahoo? nevertheless this is still the best website in showing how to access Yahoo finance API. Thank.

  15. Sam

    I really like to retrieve the stock info via csv compare to YQL. Not so sure how to use YQL, but why I can’t find any documentation from Yahoo in how to use csv?

  16. admin

    As far as I am aware there is no official documentation. This information I’ve gathered from others and trial and error by working with the API.



    I’m using


    to try to get the Dow jones and I’m not getting the data as I was in the past. Any ideas?


  18. graemeb

    The Yahoo data described above appears to be current day downloads – am i wrong?
    I was looking for a way to download 5 years of daily data, so that i can then make 5 year charts. Please advise.

  19. Charles

    Here’s some more tags:
    s6 – Revenue
    j2 – Shares Outstanding

  20. Sylvain

    I want simulate Real time to create a demo of a Trading game.
    Do you know about how many call my IP is locked ?
    Do you have a solution to simulate real time for a demo (realtime or dealayed data), there isn’t real streaming quotes for free since the dead of opentick :(


  21. Yared

    Any idea how to get the information from the Yahoo Finance Analysts Estimates table? Here is an example:



  22. Kelly Elias

    As far as I am aware there is no API but you can always scrape the data. Just use WebClient.DownloadString() to get the page and then use something the the HTML Agility Pack or even Regex to parse the data.

  23. Yared

    Thanks Kelly! Will do.

  24. Joe

    Just wanted to bring it to your attention that symbol “v” is used for both “Volume” & “More Info”.

    Thanks for this post, it’s very helpful.

  25. sajjad

    Anyway symbol to download BETA for a stock?

  26. Fabvon

    Hi Kelly! I have an Excel Macro to import around 15 stocks automatically, but when moving the XLS to Google Drive, they don’t support VBA, only Javascript (which I don’t know).

    Any way to import Yahoo Finance data to Google Drive?

  27. Kelly Elias

    I don’t have much experience with using Google drive, but if you use Google Spreadsheets you can get Google Finance data directly into your sheet, and Google will keep it up to date. Use the formula: GoogleFinance(symbol, attribute)

    More info: https://support.google.com/drive/bin/answer.py?hl=en&answer=155178

  28. rajkumar

    The Yahoo API that I’m currently referring so as to get the stock rates returns ZERO or ‘N/A’ for Canara Bank (CODE : CANARABANK.BO) but I can see the correct value for this stock on your site http://in.finance.yahoo.com… May I know why I cannot see the correct value while using the API that you provide. I think there is a problem with the API. Please do reply as soon as possible. Awaiting your response….

  29. ehsan

    Plz any one help me. I want to get Full compny name like for SODA the Full name is SodaStream International Ltd. I am waiating plz.

  30. Kelly Elias


    That should give you what you want. The last parameter “f” sets the fields to show. The table on this page shows each of them (that I know about anyway) and you can see that “n” is the flag you want to display the full name.

  31. Alijohn

    Is there a way to get commodities from yahoo finance with csv ?

  32. Kelly Elias

    Not that I’m aware of.

  33. JefB

    I am getting the stock price using the formula:
    (“C2″ is the cell with the stock symbol)

    However, I cannot figure out how to convert the result into a numeric so that I can use it in a formula. (Excel 2013 360) on Windows 8)

    Any suggestions?

  34. Ed

    You can get commodity futures if you know the future, exchange, and month codes-
    I don’t know how to get spot prices yet.

    Gold=GC, Month=June, Year=13, exchange=CMX (metals)

    % curl -s ‘http://download.finance.yahoo.com/d/quotes.csv?s=GCM13.CMX&f=snl1′
    “GCM13.CMX”,”Gold Jun 13″,1469.60

    Month Codes – (“F”,”G”,”H”,”J”,”K”,”M”,”N”,”Q”,”U”,”V”,”X”,”Z”)
    Energy exchange is NYM
    You can look up the future codes on the exchange web site.

    Good Luck!

  35. Anthony Wilson

    OK so when I use the API to generate a CSV it cuts the company name off after 17 characters…. Is there a workaround to this????

    Ex. MSFT comes through as Microsoft Corpora instead of Microsoft Corporation

  36. joku

    anyone can halp me couz i have one project about yahoo financ?

  37. Shivaji

    Following update of the code can be helpful in my opinion. Please check if it helps.

    public static List Parse(string csvData)
    List prices = new List();

    string[] rows = csvData.Replace(“\r”, “”).Split(‘\n’);

    foreach (string row in rows)
    if (string.IsNullOrEmpty(row)) continue;

    string rgPattern = “[\\*\\?\”‘|]”;
    Regex objRegEx = new Regex(rgPattern.ToString(), RegexOptions.None);
    string nrow = objRegEx.Replace(row, string.Empty);

    string[] cols = nrow.Split(‘,’);

    Price p = new Price();
    p.Symbol = cols[0];
    p.Name = cols[1];
    p.Bid = Convert.ToDecimal(cols[2]);
    p.Ask = Convert.ToDecimal(cols[3]);
    p.Open = Convert.ToDecimal(cols[4]);
    p.PreviousClose = Convert.ToDecimal(cols[5]);
    p.Last = Convert.ToDecimal(cols[6]);


    return prices;

  38. Kelly Elias

    I just updated the article with the Yahoo Exchange codes for every exchange, so you can use those to tell the difference.

  39. David

    Hello Kelly,
    Do you know how the d2 flag is utilized? Can it work to retrieve a stock’s price at close on a given date? For example, can it pull the closing price for stock X on 06/14/2013? If so how, if not, then what is the d2 flag for?

  40. sandro giangrandi

    hallo kelly, here sandro, from Italy.
    I am in the test phase of both API, for downloading historic data and daily data.
    the project is to download, once, the historic data of a stock, and on a daily basis the daily quotes, put them togheter and make them accessible to Tradestation.
    everything ok, except tha date, that have different format in historic and daily data.
    can you please give me some advice on how to get them readable without problems by TS?
    the best would be to maintain the format of the date in the historical download, and adapt the dayly one.
    any suggestion?
    thank in advance.

  41. Shahid Maqsood


    Is there a way to fetch “Revenue Estimates” data from http://finance.yahoo.com/q/ae?s=IBM+Analyst+Estimates ?


  42. Bill

    The Yahoo finance quotes are great — but the m4 function brings in a value for a moving average based on 200 calendar days. If you use the technical indicators dropdown box and show the 200 day MA on a stock chart, it proves a value based on 200 trading days (not 200 calendar days). What is the function in need to use to bring into my spreadsheet the 200 trading days information?

    Thanks for the help!

  43. Jonathan

    Is there a tag to retrieve the Growth Estimates for next 5 years. This is under Analyst Estimates component of the stock quote.



  44. Jarrod Elmes

    Has anybody noticed a problem with ask/bid prices. I’m sure my app was showing them all a week ago and now it seems very few (90% of them are now N/A). This is unfortunate as of course my spreads are all 0 now as well. I tried the other variants but they give same result of N/A. (I think I’ve at least worked out AIM stocks don’t seem to have them recorded).

    Any of you gurus knowledge on this front would be much appreciated.
    Here’s a few examples of stocks with issue: LAD.L ABB.L MONY.L DIA.L PRV.L
    Test link showing they are N/A: http://finance.yahoo.com/d/quotes.csv?s=DIA.L&f=nsab

  45. Jarrod Elmes

    Ah, All the Ask/Bids are populated now, so the issue must have been resolved. My query (above) is now redundant and can be ignored. Thanks…

  46. Ray Johnson


    When downloading data of multiple stocks in a row, so using multiple lines like this:
    … etc.
    What is the minimum time to leave between each line? Has anybody experienced his IP being locked by Yahoo because of too frequent calls?
    I want to download data of hundreds of stocks once or twice a day, but I’m afraid that Yahoo will lock me out.
    And IF I am locked out, is that only temporarily?

    Thanks already for any input.

    Kind regards

  47. Kelly Elias

    There is definitely a daily limit although I am unsure exactly what it is. Keep in mind you can ask for multiple stocks per request instead of doing 1 request per stock.

  48. Ray Johnson

    Thanks, Kelly.
    If I run into trouble I will try the multiple stock download.

  49. Ray Johnson

    The Yahoo YQL interface has some well-described limits:
    These seem very reasonable. But for the API interface as Kelly described above, I can not find any published limits. From what I read on some (older) forums, these limits seem to vary in time. Yahoo probably changes them on the fly as server loads vary.
    I am writing some software to download stock data for multiple stocks, so I can start experimenting in a few days.
    PS. Kelly, I forgot to say thanks for publishing this useful information. So thank you! :-)

  50. Jarrod Elmes

    Hi Ray, I have written a Share monitoring app (for Windows) using interface above and haven’t yet experienced any blocking of data since I started around 8 months ago. I download quite a lot of Share data and also historical chart data. Yahoo have been good to me so far fingers crossed.

  51. Ray Johnson

    Jarrod, that’s reassuring to hear. Thanks!!

  52. Daia Alexandru

    Hy , i was wondering how cand i retrieve historical data between a start date and an end date ? Tnks

  53. Jarrod Elmes

    From URL – http://ichart.finance.yahoo.com

    a = From Month
    b = From Day
    c = From Year
    d = To Month
    e = To Day
    f = To Year

    Eg: 6 months data for Taylor Wimpey:


    I have a problem in order to obtain data from exchange .MC (Madrid)

    For example:


    p: Previous Close
    s: Symbol

    Ii returns a file (.csv) with this line: “SAN.MC, N/A” where SAN.MC is the symbol and N/A is Previous Close.

    This problem is the same with other symbols from exchange with suffix .MC

    In this link


    it exists Previous Close !!!!!

    Why does this exchange .MC not work when download csv file?

  55. sandro giangrandi

    I understand that ALL stock quotes from the spanish exchange are not available.
    my feeling is that spanish quotes are available on payment, so Yahoo cannot make them available free of charge.
    if you get the historical prices, no problem at all.
    I am not sure to have solved your problem, but it is the same problem I faced some time ago.


  56. Jarrod Elmes

    I guess you tried with no prefix? eg: SAN
    It seems to work there but not much info is returned.

  57. Jarrod Elmes

    Sorry, I meant suffix :-)

  58. Maciek

    Is it possible to get detailed options quotas from yahoo to a CSV? Has anyone tried it? If so could you give me some directions?


  59. Jarrod Elmes

    Hi Maciek.
    I was going to let someone else answer you as I was unsure about your question.
    What do you mean by ‘detailed options quotas ‘?
    Can you give an example?

  60. Maciek

    Thank you very much for your response! I’m extremely sorry for this form… I’m working on CRR valuation and variations. I’d like to use all US options, and after expiration date check effectiveness of my valuation. In order to do so I need to set up a database with options quotas over time, underlying assets, and risk free interest. As I would like to make it as fast as possible daily importing all quotas is necessary, and parsing each site would be too long. Due to universities’ limits I cannot access pay-per download data. Importing selected options (name, strike, price, vol) to a CSV would be perfect. Do you maybe know how to modify parameters in this code to access options quotas?

  61. Carissa

    Is there a way to retrieve the earning date? I don’t see the earning date on the API list.


  62. Jarrod Elmes

    Hi, just for those asking about limits before…

    I’ve just discovered yahoo will only allow data for 200 stocks max in any 1 call (sorry if already mentioned). If you have more, you can do it in chunks of 200 at a time.

    PS. Ray, I just re-read your post where you said you had hundreds of stocks and were getting them 1 at a time.
    If I were you I wouldn’t call API once for each stock as I guess you may have a greater chance of getting on yahoo’s nerves. Instead call the API once with a number of stocks e.g.:
    Apart from that it would speed up your code immensly, as you’ll only be making 1 internet request.


  63. Mark

    When I download stock dividend data, there appear to be some errors as the dividend data does not match the Yahoo Finance page for the stock or current dividend information. Can someone explain?

  64. Ray J.

    My posts are not published here anymore .. Why ..?
    Kind regards

  65. Jarrod Elmes

    Hi Mark, can you give an example stock symbol. I have looked at a few shares and the yahoo finance page seems to match. If we had an example we could maybe look into your issue better.

    Carissa, do you really mean ‘earning date’. There isn’t a earning date to my understanding, only earnings per share, dividend, dividend yield, divi/exdivi dates as described above in the API?

    Maciek, you blew my mind and I don’t understand your query, sorry. I’m sure there are people on here tho that totally get what you mean and can help you.


  66. Ray J

    You can get the next earnings date from FinViz:
    Parsing the page code, you should be able to extract the earnings date (and much more).

    For example, in the page code, look for:
    Right after it, you find the next earnings date.

    Kind regards

  67. Jarrod Elmes

    Sorry Carissa, I was dead wrong re your question (thanks Ray for correcting me).
    Interestingly, I just saw on this site the info you may be after (could be wrong again tho lol) using the YQL API.

  68. Alex

    If I just want to display the latest price and change, and use historical info to create a chart for the company website, is this OK under Yahoo’s TOS?

    Thanks, Alex

  69. balaji

    Whenever i try to fetch .csv file for NSE or BSE stock list i’m NOT getting (retrieving any values- displayed as “N/A”), or most of the times i’m getting ‘Missing Format Variable.’

    Do i need to pass any arguments for NSE or BSE stocks . apart from NS or BO – example Infy.BO Thanks, BS

  70. Marek

    How to download quotes indices of the LSE?

  71. Jean

    Two other stock exchanges you can add to your nice final table! Thanks ;)
    Belgium Brussels Stocks .BR
    Portugal Lisbon Stocks .LS

  72. Kelly Elias

    Great, I’ve added them to the list. Thanks!

  73. Jean

    Happy to help ;)
    In the table you added “.LS” instead of “.BR” for Brussel stocks.

  74. Kelly Elias

    Copy and paste is both a blessing and curse. It’s fixed, thanks again for pointing that out.

  75. Saurabh

    Nice article, How do I get data for a certain exchange only? For example, I need a csv with all data for the BATS exchange. Is there a way to specify this?


  76. hari

    Can you please let us know if there a way to get Beta information for a stock?

  77. Kelly Elias

    While Yahoo provides Beta on there site I haven’t seen a way to easily get it.

  78. sneha

    How can i get gold rates from yahoo finance?

  79. sneha

    How can i get gold price data from yahoo finance?

  80. Hari

    Excellent article. Very informative, especially the part on non-US exchanges.
    The links in “Stuff you might like” are also great

    Thanks a lot Kelly !!

  81. Pavel

    Hi, am i the only one for whom the api is not working? I keep getting 404 errors for links like http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG+MSFT

  82. sandro giangrandi

    can you try?
    it should work.



  83. Jarrod

    Pavel, In your example, you haven’t specified what data you want returned ie. the format.
    Try appending &f=nab to the end of your query which would in this example give the name,ask and bid price, as described at start of the article.

  84. Doc

    Is there anyway to get enterprise value into excel using this?

  85. Kelly Elias

    I’ve done similar projects to send data to excel in many large companies. The best way to do it is using An RTD server. Google excel rtd server and you should find plenty of examples.

  86. Alex

    I’ve searched a bit for how to find out the currency, here it is:

    c4 = currency


  87. Gato


    I’m very impressed by this code, thanks a lot :)

    I’ve 2 questions :

    1) how can I get the figures of a market ? eg CAC40, whose symbol is PX1.

    When I use the code below, I get no results :(

    csvData = web.DownloadString(“http://finance.yahoo.com/d/quotes.csv?s=PX1+&f=snhg”);

    2) is it possible to get the ISIN code ? I can get the symbol but not the ISIN so far

    Thanks for reading this =)

  88. Gato

    My bad, I wasn’t using the good symbol for CAC40.. It was in fact ^FCHI !

    But question 2 is still standing : how can I get the ISIN code?

  89. kii

    Greate article! I’ve learned a lot.
    Do you know how to get history of earnings or EPS?

  90. nuttijay

    a question on the chart api…

    i am getting data like
    symbol : timestamp : vol : high : low : open : close
    dbk.de;2014-04-09 09:00:50+02;81.400;32,2150;32,2150;32,2150;32,2150
    dbk.de;2014-04-09 09:01:15+02;4.600;32,2500;32,2500;32,2500;32,2500
    dbk.de;2014-04-09 09:02:37+02;34.300;32,2100;32,2550;32,2550;32,2100
    dbk.de;2014-04-09 09:03:11+02;2.900;32,2200;32,2200;32,2200;32,2200
    dbk.de;2014-04-09 09:04:41+02;18.900;32,2200;32,2250;32,2200;32,2250
    dbk.de;2014-04-09 09:05:40+02;14.500;32,2400;32,2700;32,2400;32,2700
    dbk.de;2014-04-09 09:06:24+02;6.600;32,2300;32,2350;32,2350;32,2300
    dbk.de;2014-04-09 09:07:57+02;12.300;32,1350;32,2000;32,2000;32,1350
    dbk.de;2014-04-09 09:08:14+02;500;32,1200;32,1200;32,1200;32,1200

    it is parsed from xml… but i realized, that the volumes have no plus or minus or something similar which i would expect…

    nor in the returned xml

    So hwo would I calculate the volume… a simple minus wouldnt work, see second data row…

  91. Chandra Munukutla

    Using the info provided here and a little bit of ruby scripting (with text-table gem installed), here is something folks can use to get a neat table for each of the stock of their interest.

  92. Kathleen

    Anyone else having problems with exchanges? I have been getting crude oil prices using


    Was working great – now all of a sudden, I just get N/A and zeroes…

  93. Vinnie Russo

    Every time I go to download a spreadsheet in .csv form, the Microsoft Office default appears. I want to use Microsoft Works instead. How do I change the default from Office to Works?

  94. Pete

    Anybody know how to download historic, or at least last 4 qtrs of EPS via Yahoo URL? Thanks!

  95. Jerry

    Great info for stocks data. How about options data? I want to download a CSV of the option chain.

  96. Roger dailey

    When using s1 shares owned I’m getting additional columns. Not sure what going on here all others work fine.


  97. Jakob

    I found that you can get the full company name (not cut off after 17 or so characters) through the Yahoo! Finance charting API: http://chartapi.finance.yahoo.com/instrument/1.0/msft/chartdata;type=quote;range=1d/csv/

    Slightly different format, but dead easy to parse.

  98. Roger dailey

    When I run f6 = float shares only I get 3 columns when I expect only one. What am I doing wrong?

  99. Roger dailey

    Would it be possible to remove the comma’s in Shares Outstanding, Float Shares and Last Trade Size? Other numerical fields are this way, like average daily volume for example.


  100. Dudz Artiaga

    Hi – I am wondering it I can get qoutes from Philippine Stock Exchange Index (PSEI). I can get just the summary here http://finance.yahoo.com/q?s=PSEI.PS. I was hoping to see stock qoute from a particluar company like ‘BDO’,’BPI’ and so on..

    Do you know how can I get it?


  101. ab

    Just tried to get ex-dividend date for a stock. Using the following URL
    I get “AVGO”,”Mar 18″,”Jun 30″
    but the ex-dividend date is wrong; it should be 6/17/2014, I believe.

    Is yahoo wrong, or is “q” the wrong code for latest ex-dividend date?

  102. xzone0

    Concerning poster Kathleen
    April 14, 2014 at 4:29 pm

    I am having the same problem with stock futures, etc no longer displaying properly.

  103. Deepak

    Thanks for this great post! This is exactly what I was looking for since ages…..

    I am just wondering why this won’t work for India Exchanges like BSE and NSE even when I use .BO and .NS as suffix. It just throws csv with N/A values.


    finance.yahoo.com/d/quotes.csv?s=RELIANCE.NS&f=nab returns


    Highly appreciate your response.

    Thanks again for this great Post!!!!!

  104. Kimahri

    Any idea how to get the information from the Business Summary area?


  105. Senthil

    DEEPAK, login to Yahoo finance and try finance.yahoo.com/d/quotes.csv?s=RELIANCE.NS&f=nab

    you will get the data

  106. Chidambaram

    i’m still getting only 17 characters for a stocks name, the rest are being truncated. Is there any solution available for this?

  107. Kelly Elias

    I don’t know of one, that is simply how they choose to return the data unfortunately. You could always use the ticker to look up the full name elsewhere though.

  108. DJunqueira

    Wrong letter in More info = i NOT v

  109. Bhaskar Rabha

    I am trying to get data from url – http://finance.yahoo.com/d/quotes.csv?s=CRAVATEX.BO&f=nab
    but it is returning N/A. Same is showing perfect on yahoo finance URL – https://in.finance.yahoo.com/q?s=CRAVATEX.BO&f=nl1c1&e=.csv. Please help me where i am doing wrong or it is API issue.

  110. Ray

    How can I get stock prices by minute (can I specify the time?) for 6 months back?

  111. Bans

    I know this has been asked previously, but..

    Does anyone know how to download historical EPS numbers?

    Is this possible with the Yahoo API, or can this be acquired elsewhere?


  112. Hugh

    I have found that some of the Yahoo data fields return values that have commas within their data in addition to the expected commas. They aren’t wrapping the data with quotes so this causes Excel to interpret them as belonging to multiple cells. The NAME field does get returned with quotes so that doesn’t cause a problem. I suspect that several of the questions about broken data returns are related to this problem.

    For these fields I have to download their data individually and wrap them with quotes before saving them. So far, these are the ones that I’ve found:

    For example, if you use the following URL, Excel displays this as 6 columns instead of the four that you asked for.

  113. Nick

    Is there a known way to get the sector info from yahoo? I know you can look it up in another api but it would be nice to get it straight from yahoo

  114. Jake

    Yahoo API that calls stock data seems to be stuck on the closing price of Nov 20. Would be nice if Yahoo fixed this. Don’t know how to alert them.

  115. Dave S.

    As of 2-3 days ago, the API access to current stock prices still appears to be working, but there appears to have been no updating of prices since then.

    For example, here is the data I get today (Nov 21, 2014) for a several gold-related stocks:

    [ticker, curr. price, change, % change, volume]


    These data are 2-3 days old.

    Has anyone else noticed this?

    If there is a limit to use of the API download service, and my API has been locked, would this be what such a lock would look like, or would there be no download allowed at all?


  116. Dave S.

    ;-) I meant “my IP has been locked..”

  117. Dave S.

    And wouldn’t you know it…20 minutes after posting the above (after 2-3 DAYS of no price updates) the current price data is suddenly available again. Relief.

    Still, I’d be interested to hear if anyone else saw the above gap in availability.

  118. Jake

    Use a dash instead of a period in the stock symbol.

  119. Glenn

    Is anyone successfully using this to get option quotes? Is there a simple format directly using finance.yahoo.com? The only Yahoo REST API for option quotes seems to be a messy call to YQL embedded in a URL. Regardless, that worked. At least it did until recently. Is anyone getting option data anymore through YQL?


    select option
    from yahoo.finance.options
    where symbol = “COH”
    and expiration = “2015-05″
    and option.symbol = “COH150220C00039000″



    No luck.

    Update – The only table that seems to be returning anything on options is yahoo.finance.oquotes – should I just send the YQL in a URL, or does anyone know of a simpler format that will get me the same results (similar to the URL that returns quotes in CSV format for stocks…)

    Any suggestions much appreciated!

  120. Nick

    is there any way to get UK fund prices?

  121. GERRY

    Wonderfully useful insights, Kelly. Thank you.

    I am interested in TSX listed equities.

    I can get info for Alaris Royalty Corp using AD.TO.

    I am having no luck with investment trusts. An example: If I try Richards Packaging (RPI.UN) as RPI.UN.TO, I get nothing. Is there a trick to formatting this?

    Many Thanks

  122. Brian

    I was able to get the last trade quotes for a group of stocks using the EXCEL 2013 WEBSERVICE function, but they do not automatically update. I cannot find a “refresh” function and even closing/reopening the EXCEL workbook does not refresh the quote. Any ideas?

  123. Chris

    All I want to be able to do is fetch a REAL TIME PRICE of the security. Please advise what symbol that is?. Last price is no good.

  124. Gary

    I know nothing about C#, nevertheless, I was able to get this running in Microsoft Visual C# 2010. I even edited the program to get only bid, ask, and last of the S&P emini, and put in a ‘do loop’ along with ‘Thread.Sleep(1800);’ to keep my calls under 2000 per hour (the call limit). Now, where do I put code to process the data? I tried declaring variables before the ‘do loop’ and dropping in ‘if’ statements, but it says my variables are undeclared. WTF?

  125. Daniel

    Hi, I tried to retrieve the Japan stock price but to no avail. Appreciate if you could advise me on that. Thanks a lot.

  126. Peter Watling

    It seems the trading date/time isn’t right for international quotes. The date element seems to be from the server, and the time the trade time in local timezone.

  127. Tom

    I would just go to http://www.dailystockdata.com as they send a data file each trading day for over 35 global stock exchanges. They also have a nice FastMoney and CEOPicks section.

  128. Gerry

    Assuming you are using Excel functions in the form of


    It doesn’t update automatically, and simple F9 doesn’t do it.

    The only way I can get Excel to update quotes using this facility is ctrl-shift-alt-F9.

    Good Luck!

  129. Dave S.

    >>I am having no luck with investment trusts. An example: If I try Richards Packaging (RPI.UN) as RPI.UN.TO, I get nothing. Is there a trick to formatting this?<<

    Go to finance.yahoo.com and in the search EF at the top, start typing in the name of the company. The drop-down that usually results, if it contains the desired company, will also show yahoo’s ticker for the company, in this case RPI-UN.TO

  130. Gerry

    You need to use a dash
    So for RPI.UN it is RPI-UN.TO
    And for Convertible debentures, say EIF.DB.D is EIF-DBD.TO


  131. Tim

    I have been using this in a spreadsheet for about a year, however approximately 1 month ago W1 and W4 stopped working (% change), and the data field only displays N/A. Has anyone else noticed this? Have these tags been replaced with something else? Thanks.

  132. Dave S.

    I don’t use w1 and w4, but I can verify that they are returning N/A right now.

    How do these differ from c1 and c6? c1 (change) is still working and c6 (Change (real-time)) is not working at the moment (N/A), perhaps because we’re after hours…?

  133. Dave S.

    It looks like c6 is not working either.

  134. Petr V.

    Hi guys, I am not able to get historical data for commodities, could you please help me out? Could you provide me with a URL to get eg. prices for each day in the date range of 30 days (for example in January) of eg. Corn Jul 15 (CN15.CBT)? I just need to know a way to specify date range for various commodities. Thanks a lot. Petr.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>