Archive for the ‘finance’ Category

Euro foreign exchange reference rates + historical data

February 4, 2011 Leave a comment

If you want to know how foreign currencies relate to euro, you can use the database of the European Central Bank (ECB). The good thing is that they also offer historical data, for free.

Reference rates for today in HTML


Example: the line “Hungarian forint (HUF) = 270.35” means that 1 euro = 270.35 HUF.

Reference rates for today in XML

Visit Here, under Latest rates, check out the link

Historical reference rates in XML, for the last 90 days

Visit, then

Historical reference rates in XML, since 1999

Warning! This XML is quite big, don’t open it in your browser! :)

Visit, then

How to parse the XMLs

Under you will find some help.

Problem with the XMLs

The only problem that I noticed is that some days (like weekends) are missing. I think these are the dates when exchanges are closed. A possible solution is to step back one day (or more) until you find an existing day and use those values.

Example: Jan 2, 2011 is missing -> step back to Jan 1, 2011 -> missing, step back to Dec 31, 2010 -> OK, exists -> use these values for Jan 2, 2011.


I read about this ECB database in this thread.


Extract Yahoo stock list

December 17, 2010 6 comments

Use Case

In this post I explain how I managed to download the stock list of Yahoo.

Problem: I wanted to have a list of Yahoo stocks. More precisely, I only needed the stock IDs and the corresponding company names, e.g. “MSFT => Microsoft Corporation”. I was looking for such a list, but I didn’t find anything useful. So after a few hours I said to myself: “I will have to solve this problem by myself :(“.


Fortunately, Yahoo has a page that lists the industries. So the problem is actually extracting data from a bunch of HTML pages. Let’s see the steps that lead to the solution.
Read more…

Categories: finance, python Tags: , , ,

Currencies of Yahoo exchanges

December 17, 2010 Leave a comment


Using Yahoo! Finance, we can ask info about a given stock, e.g. MSFT. The current price is, for instance, 27.98. But it is given in what currency? USD, EUR, CAD? Unfortunately it’s not indicated…


As I figured it out, these values are given in local currencies. Thus, we need to know in which country the exchange is located. Using Yahoo! Finance, the exchanges are indicated with a suffix. See for a list of all suffixes.

Example: let’s take the stock name “UG.PA” with value 30.04. “.PA” stands for “Paris Stock Exchange”, thus 30.04 is given in euro (EUR).

To facilitate life, using the page, I collected all the necessary information in an array structure. I also added the currencies. So, using this structure, you can easily figure out the currency, once you have the suffix of the exchange. If there is no suffix, we can suppose it’s in USD.

# id  => description, country, currency
# source:
# collected by Jabba Laci (
$financeSymbolMoney = array(
".CBT" => array("Chicago Board of Trade", "United States of America", "USD"),
".CME" => array("Chicago Mercantile Exchange", "United States of America", "USD"),
".NYB" => array("New York Board of Trade", "United States of America", "USD"),
".CMX" => array("New York Commodities Exchange", "United States of America", "USD"),
".NYM" => array("New York Mercantile Exchange", "United States of America", "USD"),
".OB"  => array("OTC Bulletin Board Market", "United States of America", "USD"),
".PK"  => array("Pink Sheets", "United States of America", "USD"),
".BA"  => array("Buenos Aires Stock Exchange", "Argentina", "ARS"),
".VI"  => array("Vienna Stock Exchange", "Austria", "EUR"),
".AX"  => array("Australian Stock Exchange", "Australia", "AUD"),
".SA"  => array("BOVESPA - Sao Paolo Stock Exchange", "Brazil", "BRL"),
".TO"  => array("Toronto Stock Exchange", "Canada", "CAD"),
".V"   => array("TSX Venture Exchange", "Canada", "CAD"),
".SN"  => array("Santiago Stock Exchange", "Chile", "CLP"),
".SS"  => array("Shanghai Stock Exchange", "China", "CNY"),
".SZ"  => array("Shenzhen Stock Exchange", "China", "CNY"),
".CO"  => array("Copenhagen Stock Exchange", "Denmark", "DKK"),
".NX"  => array("Euronext", "France", "EUR"),
".PA"  => array("Paris Stock Exchange", "France", "EUR"),
".BE"  => array("Berlin Stock Exchange", "Germany", "EUR"),
".BM"  => array("Bremen Stock Exchange", "Germany", "EUR"),
".DU"  => array("Dusseldorf Stock Exchange", "Germany", "EUR"),
".F"   => array("Frankfurt Stock Exchange", "Germany", "EUR"),
".HM"  => array("Hamburg Stock Exchange", "Germany", "EUR"),
".HA"  => array("Hanover Stock Exchange", "Germany", "EUR"),
".MU"  => array("Munich Stock Exchange", "Germany", "EUR"),
".SG"  => array("Stuttgart Stock Exchange", "Germany", "EUR"),
".DE"  => array("XETRA Stock Exchange", "Germany", "EUR"),
".HK"  => array("Hong Kong Stock Exchange", "Hong Kong", "HKD"),
".BO"  => array("Bombay Stock Exchange", "India", "INR"),
".NS"  => array("National Stock Exchange of India", "India", "INR"),
".JK"  => array("Jakarta Stock Exchange", "Indonesia", "IDR"),
".TA"  => array("Tel Aviv Stock Exchange", "Israel", "ILS"),
".MI"  => array("Milan Stock Exchange", "Italy", "EUR"),
".MX"  => array("Mexico Stock Exchange", "Mexico", "MXN"),
".AS"  => array("Amsterdam Stock Exchange", "Netherlands", "EUR"),
".NZ"  => array("New Zealand Stock Exchange", "New Zealand", "NZD"),
".OL"  => array("Oslo Stock Exchange", "Norway", "NOK"),
".SI"  => array("Singapore Stock Exchange", "Singapore", "SGD"),
".KS"  => array("Korea Stock Exchange", "South Korea", "KRW"),
".KQ"  => array("KOSDAQ", "South Korea", "KRW"),
".BC"  => array("Barcelona Stock Exchange", "Spain", "EUR"),
".BI"  => array("Bilbao Stock Exchange", "Spain", "EUR"),
".MF"  => array("Madrid Fixed Income Market", "Spain", "EUR"),
".MC"  => array("Madrid SE C.A.T.S.", "Spain", "EUR"),
".MA"  => array("Madrid Stock Exchange", "Spain", "EUR"),
".ST"  => array("Stockholm Stock Exchange", "Sweden", "SEK"),
".SW"  => array("Swiss Exchange", "Switzerland", "CHF"),
".TWO" => array("Taiwan OTC Exchange", "Taiwan", "TWD"),
".TW"  => array("Taiwan Stock Exchange", "Taiwan", "TWD"),
".L"   => array("London Stock Exchange", "United Kingdom", "GBP"),
Categories: finance, php Tags: , ,

Download financial data using the Yahoo API

December 13, 2010 1 comment


If you want to consult financial information, Yahoo! Finance is a good site for that. For instance, to get info about Microsoft’s shares, just visit There, in the bottom right corner in the Toolbox section, you can find a link “Download Data”.

But is there another way to get financial data? Is there a Yahoo API for this?


The answer to the previous question is: yes, there is. Visit for a detailed presentation of the API.


Here we ask stock information about the shares of Microsoft. Their stock code is “MSFT”. We pass four parameters: n – stock name, l1 – current price, p – price at the previous close, x – stock exchange. The data is returned as a text file in .csv format:

"Microsoft Corpora",27.245,27.34,"NasdaqNM"

Special tags:

At, you can find a table with all the special tags. I collected them here, in a single link: copy link (see the link in the status bar).

This can help you to choose the parameters that you really need.

Categories: finance Tags: , , , ,

Currency names and codes [PHP]

December 3, 2010 Leave a comment


You want a combo box in your HTML page with all the currency names and codes.


The standard ISO codes can be found here. For collecting my list, I used this page. This latter page also provides the data in CSV format. I took this CSV data and transformed into PHP code:

 "UAE Dirham",
"AFN" => "Afghanistan Afghani",
"ALL" => "Albanian Lek",
"AMD" => "Armenian Dram",
"ANG" => "Netherlands Antillian Guilder",
"AOA" => "Angolan Kwanza",
"ARS" => "Argentine Peso",
"AUD" => "Australian Dollar",
"AWG" => "Aruban Guilder",
"AZM" => "Azerbaijanian Manat",
"BAM" => "Bosnia and Herzegovina Convertible Marks",
"BBD" => "Barbados Dollar",
"BDT" => "Bangladesh Taka",
"BGN" => "Bulgarian Lev",
"BHD" => "Bahraini Dinar",
"BIF" => "Burundi Franc",
"BMD" => "Bermudian Dollar",
"BND" => "Brunei Dollar",
"BOB" => "Bolivian Boliviano",
"BRL" => "Brazilian Real",
"BSD" => "Bahamian Dollar",
"BTN" => "Bhutan Ngultrum",
"BWP" => "Botswana Pula",
"BYR" => "Belarussian Ruble",
"BZD" => "Belize Dollar",
"CAD" => "Canadian Dollar",
"CDF" => "Franc Congolais",
"CHF" => "Swiss Franc",
"CLP" => "Chilean Peso",
"CNY" => "Chinese Yuan Renminbi",
"COP" => "Colombian Peso",
"CRC" => "Costa Rican Colon",
"CSD" => "Serbian Dinar",
"CUP" => "Cuban Peso",
"CVE" => "Cape Verde Escudo",
"CYP" => "Cyprus Pound",
"CZK" => "Czech Koruna",
"DJF" => "Djibouti Franc",
"DKK" => "Danish Krone",
"DOP" => "Dominican Peso",
"DZD" => "Algerian Dinar",
"EEK" => "Estonian Kroon",
"EGP" => "Egyptian Pound",
"ERN" => "Eritrea Nafka",
"ETB" => "Ethiopian Birr",
"EUR" => "euro",
"FJD" => "Fiji Dollar",
"FKP" => "Falkland Islands Pound",
"GBP" => "Pound Sterling",
"GEL" => "Georgian Lari",
"GHC" => "Ghana Cedi",
"GIP" => "Gibraltar Pound",
"GMD" => "Gambian Dalasi",
"GNF" => "Guinea Franc",
"GTQ" => "Guatemala Quetzal",
"GYD" => "Guyana Dollar",
"HKD" => "Hong Kong Dollar",
"HNL" => "Honduras Lempira",
"HRK" => "Croatian Kuna",
"HTG" => "Haiti Gourde",
"HUF" => "Hungarian Forint",
"IDR" => "Indonesian Rupiah",
"ILS" => "New Israeli Shekel",
"INR" => "Indian Rupee",
"IQD" => "Iraqi Dinar",
"IRR" => "Iranian Rial",
"ISK" => "Iceland Krona",
"JMD" => "Jamaican Dollar",
"JOD" => "Jordanian Dinar",
"JPY" => "Japanese Yen",
"KES" => "Kenyan Shilling",
"KGS" => "Kyrgyzstan Som",
"KHR" => "Cambodia Riel",
"KMF" => "Comoro Franc",
"KPW" => "North Korean Won",
"KRW" => "Korean Won",
"KWD" => "Kuwaiti Dinar",
"KYD" => "Cayman Islands Dollar",
"KZT" => "Kazakhstan Tenge",
"LAK" => "Lao Kip",
"LBP" => "Lebanese Pound",
"LKR" => "Sri Lanka Rupee",
"LRD" => "Liberian Dollar",
"LSL" => "Lesotho Loti",
"LTL" => "Lithuanian Litas",
"LVL" => "Latvian Lats",
"LYD" => "Libyan Dinar",
"MAD" => "Moroccan Dirham",
"MDL" => "Moldovan Leu",
"MGA" => "Malagasy Ariary",
"MKD" => "Macedonian Denar",
"MMK" => "Myanmar Kyat",
"MNT" => "Mongolian Tugrik",
"MOP" => "Macau Pataca",
"MRO" => "Mauritania Ouguiya",
"MTL" => "Maltese Lira",
"MUR" => "Mauritius Rupee",
"MVR" => "Maldives Rufiyaa",
"MWK" => "Malawi Kwacha",
"MXN" => "Mexican Peso",
"MYR" => "Malaysian Ringgit",
"MZM" => "Mozambique Metical",
"NAD" => "Namibia Dollar",
"NGN" => "Nigerian Naira",
"NIO" => "Nicaragua Cordoba Oro",
"NOK" => "Norwegian Krone",
"NPR" => "Nepalese Rupee",
"NZD" => "New Zealand Dollar",
"OMR" => "Rial Omani",
"PAB" => "Panama Balboa",
"PEN" => "Peruvian Nuevo Sol",
"PGK" => "Papua New Guinea Kina",
"PHP" => "Philippine Peso",
"PKR" => "Pakistan Rupee",
"PLN" => "Polish Zloty",
"PYG" => "Paraguayan Guarani",
"QAR" => "Qatari Rial",
"RON" => "Romanian Leu",
"RUB" => "Russian Ruble",
"RWF" => "Rwanda Franc",
"SAR" => "Saudi Riyal",
"SBD" => "Solomon Islands Dollar",
"SCR" => "Seychelles Rupee",
"SDD" => "Sudanese Dinar",
"SEK" => "Swedish Krona",
"SGD" => "Singapore Dollar",
"SHP" => "St Helena Pound",
"SIT" => "Slovenian Tolar",
"SKK" => "Slovak Koruna",
"SLL" => "Sierra Leone Leone",
"SOS" => "Somali Shilling",
"SRD" => "Surinam Dollar",
"STD" => "São Tome and Principe Dobra",
"SVC" => "El Salvador Colon",
"SYP" => "Syrian Pound",
"SZL" => "Swaziland Lilangeni",
"THB" => "Thai Baht",
"TJS" => "Tajik Somoni",
"TMM" => "Turkmenistan Manat",
"TND" => "Tunisian Dinar",
"TOP" => "Tonga Pa'anga",
"TRY" => "Turkish Lira",
"TTD" => "Trinidad and Tobago Dollar",
"TWD" => "New Taiwan Dollar",
"TZS" => "Tanzanian Shilling",
"UAH" => "Ukraine Hryvnia",
"UGX" => "Uganda Shilling",
"USD" => "US Dollar",
"UYU" => "Peso Uruguayo",
"UZS" => "Uzbekistan Sum",
"VEB" => "Venezuelan Bolivar",
"VND" => "Vietnamese Dong",
"VUV" => "Vanuatu Vatu",
"WST" => "Samoa Tala",
"XAF" => "CFA Franc BEAC",
"XCD" => "East Caribbean Dollar",
"XDR" => "SDR (Special Drawing Rights)",
"XOF" => "CFA Franc BCEAO",
"XPF" => "CFP Franc",
"YER" => "Yemeni Rial",
"ZAR" => "South African Rand",
"ZMK" => "Zambian Kwacha",
"ZWD" => "Zimbabwe Dollar",


The page contains some additional information. It’s very useful to find out the local currency of a given country.


Country; Co. Code; Currency; Curr. Code
Hungary; HU;       Forint;   HUF

Categories: finance, html, php Tags: ,