Uses to get latest currency exchange rates
Updated 18 Jul 2014

View License

This function returns exchange rates obtained from
using their API. To work correctly, one must be connected to the
Internet. The default app_id is from a free account to, which has a limit of 1000 API requests/month. For
more flexibility, sign up for your own free or paid account and replace
the app_id value with your own id number.

1) base: a string denoting the base currency, which is set to have a
value of 1. If an empty string '' is provided, the default 'USD' is used.
See list of valid currency abbreviations below.
2) curr: a string or cell array of strings denoting the currency
abbreviation to compare with the base currency. If 'all' or '' is
provided as input, then all available currencies are returned. See list
of valid currency abbreviations below.
3) date: an optional string containing the date desired for the exchange
rate (historical data may not always be available). The input should be
in the form 'YYYY-MM-DD'. To get the latest exchange rate data, use date
= 'latest' or '', which is the default value. Historical data from 1999
and onward

1) rates: a number or vector indicating the exchange rate(s) between the
desired currency (currencies), curr, and the base currency, base.
2) currencies: a cell array of the corresponding currency abbreviations
in rates.
3) rate_struct: a structure with field names equal to the currency
abbreviations and associated values being the rates. This output just
combines rates and currencies for convenience.

1) Get the latest exchange rate between Bitcoin and the US Dollar
[rates,currencies,rates_struct] = exchangerate('USD','BTC');
>> rates = 1.614e-3
>> currencies = 'BTC'
>> rates_struct =
BTC: 1.614e-3

2) gets latest exchange rates for all available currencies
[rates,currencies,rates_struct] = exchangerate();

3) Obtain exchange rates for Bitcoin, Indian rupee, and Euro using the US
Dollar as base currency on June 5, 2013
[rates,currencies,rates_struct] = exchangerate('USD',{'BTC','INR','EUR'},'2013-06-05');
>> rates = [8.246e-3; 5.672e1; 7.642e-1]
>> currencies = {'BTC';'INR';'EUR'}
>> rates_struct =
BTC: 8.246e-3
INR: 5.672e1
EUR: 7.642e-1

4) Obtain exchange rates for all available currencies on June 14, 2014
[rates,currencies,rates_struct] = exchangerate('USD','all','2014-07-14');

List of Currency Abbreviations (as of 7-16-2014)
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
"ALL": "Albanian Lek",
"AMD": "Armenian Dram",
"ANG": "Netherlands Antillean Guilder",
"AOA": "Angolan Kwanza",
"ARS": "Argentine Peso",
"AUD": "Australian Dollar",
"AWG": "Aruban Florin",
"AZN": "Azerbaijani Manat",
"BAM": "Bosnia-Herzegovina Convertible Mark",
"BBD": "Barbadian Dollar",
"BDT": "Bangladeshi Taka",
"BGN": "Bulgarian Lev",
"BHD": "Bahraini Dinar",
"BIF": "Burundian Franc",
"BMD": "Bermudan Dollar",
"BND": "Brunei Dollar",
"BOB": "Bolivian Boliviano",
"BRL": "Brazilian Real",
"BSD": "Bahamian Dollar",
"BTC": "Bitcoin",
(see rest of list in m-file)

Cite As

Steven Shimizu (2024). exchangerate.m (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Trading Technologies in Help Center and MATLAB Answers

Inspired by: JSON Parser

Inspired: finalfinalfinal(varargin), audio

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes