Translating between Currencies

[1]:
from salamanca.currency import Translator

Translating between currencies requires a number of different choices

Which to use can be very context or use case dependent. salamanca offers all options with data supplied by the World Bank. Below are a few examples.

Basics

Let’s start by getting to know the trusty Translator and its primary weapon exchange()

[2]:
xltr = Translator()

Every translation is based on countries and years. By default, the Translator assumes you want the USD value of a currency in a year based on market exchange rates using GDP deflators.

So, for example, translating 20 Euros (the currency of Austria) in 2010 would net you 26.5 US Dollars.

[3]:
xltr.exchange(20, iso='AUT', yr=2010)
[3]:
26.514333333333386
[4]:
xltr.exchange(20, fromiso='AUT', toiso='USA', yr=2010) # equivalent to the above defaults
[4]:
26.514333333333386

You can further translate 20 2010 Euros into 2015 US Dollars as

[5]:
xltr.exchange(20, fromiso='AUT', toiso='USA',
              fromyr=2010, toyr=2015)
[5]:
28.88848849954665

Additional Options

You can specify options such as using CPI rather than GDP Deflators

[6]:
xltr.exchange(20, fromiso='AUT', toiso='USA',
              fromyr=2010, toyr=2015,
              inflation_method='cpi')
[6]:
28.819946039731406

Similarly, you can use Purchasing Power Parity rather than Market Exchange Rates

[7]:
xltr.exchange(20, fromiso='AUT', toiso='USA',
              fromyr=2010, toyr=2015,
              units='PPP')
[7]:
25.919029469737964