Archive

Posts Tagged ‘currency’

Currency exchange rates in CSV format

December 8, 2012 Leave a comment

See http://www.bankofcanada.ca/en/markets/csv/exchange_eng.csv.

From the header of the file:

The daily noon exchange rates for major foreign currencies are published
every business day at about 12:30 p.m. EST. They are obtained from
market or official sources around noon and show the rates for the various
currencies in Canadian dollars converted from US dollars. The rates are
nominal quotations – neither buying nor selling rates – and are intended
for statistical or analytical purposes. Rates available from financial
institutions will differ.

How to do the calculation?

Say, we want to convert 1 Euro (EUR) to Hungarian Forint (HUF). Content of the file:

Date, ISO4217, 2012-11-29, 2012-11-30, 2012-12-03, 2012-12-04, 2012-12-05, 2012-12-06, 2012-12-07
European Euro , EUR, 1.2863, 1.2921, 1.2972, 1.2986, 1.2962, 1.2850, 1.2799
Hungarian forint, HUF, 0.004596, 0.004598, 0.004586, 0.004584, 0.004574, 0.004540, 0.004517
...

The latest date here is 2012-12-07 (yyyy-mm-dd), which is in the last column. So the answer is: 1 EUR is 1.2799/0.004517 = 283.35 HUF.

Currencies of Yahoo exchanges

December 17, 2010 Leave a comment

Problem

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…

Solution

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 http://finance.yahoo.com/exchanges 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 http://finance.yahoo.com/exchanges, 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.

<?php
# id  => description, country, currency
# source: http://finance.yahoo.com/exchanges
# collected by Jabba Laci (http://ubuntuincident.wordpress.com/2010/12/17/currencies-of-yahoo-exchanges/)
$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: , ,

Currency converters

December 9, 2010 Leave a comment

Here I collect some links that are related to currency conversions.

In another post I will explain how to get conversion rates from PHP using the Yahoo API.

Currency names and codes [PHP]

December 3, 2010 Leave a comment

Problem

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

Solution

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",
);
?>

Links

The page http://www.jhall.demon.co.uk/currency/by_country.html contains some additional information. It’s very useful to find out the local currency of a given country.

Example:


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

Categories: finance, html, php Tags: ,
Follow

Get every new post delivered to your Inbox.

Join 62 other followers