Get stock prices from different exchanges in C#

[stock prices]

The example Get stock prices from the internet in C# shows how to download stock prices from download.finance.yahoo.com. It builds a URL of the following form to get prices for MCI, DIS, COKE, and PEP:


http://download.finance.yahoo.com/d/quotes.csv?s=MCI+DIS+COKE+PEP&f=sl1d1t1c1

To get prices from a particular stock exchange, you simply add an exchange suffix after a stock’s symbol. For example, to get the price of DIS on the London exchange, use the symbol DIS.L.

The following table shows the exchange suffixes.

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

You can include suffixes for multiple exchanges in the same query. For example, you could look for DIS+DIS.L+DIS.TW+DIS.MI to get the prices of DIS on the New York, London, Taiwan, and Milan stock exchanges.

If you include the data specifier x, then the returned data includes the stock exchanges. That makes it easier to tell which data came from which source.

Note that if an exchange is closed due to the time of day or the day of the week, its data is returned as N/A. I’ve modified the example program so it displays a blank string if it cannot parse a value.

Finally the example considers all of the currencies to be dollars, although that won’t be the case for the non-American exchanges.

Download the example and give it a try. The downloaded program is the same as the previous version. All you need to do is enter stock symbols with exchange extensions.


Download Example   Follow me on Twitter   RSS feed   Donate




About RodStephens

Rod Stephens is a software consultant and author who has written more than 30 books and 250 magazine articles covering C#, Visual Basic, Visual Basic for Applications, Delphi, and Java.
This entry was posted in finance, internet, mathematics, web and tagged , , , , , , , , , , , , , . Bookmark the permalink.

One Response to Get stock prices from different exchanges in C#

  1. blaise says:

    too good

Leave a Reply

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