ExchangeRates

Stable Dev Build Status Aqua QA

Purpose

The purpose of this package is to provide a convenient interface to working with exchange rates.

Data

The data is downloaded from the European Central Bank, when the package is loaded.

It uses this link: https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml.

Barewords

The simplest interface looks like this:

julia> 100EUR/DKK
745.08

This shows that you need 745.08 DKK to have 100 EUR.

This is done by defining and exporting variables EUR, USD, DKK etc (using the cool metraprogramming tools of julia).

Each variable is the exchange rate of EUR, so USD is the value of 1 USD in EUR. This means that 100USD is the value of 100 USD in EUR.

Note that this uses the juxtaposition syntax of julia, so the can not be a whitespace between the number and the currency without an explicit multiplication:

julia> 100 DKK
ERROR: syntax: extra token "DKK" after end of expression

julia> 100 * DKK
13.421377570193805

Function interface

The package exports a single function fromto. It converts from the first argument to the second argument.

julia> fromto(:EUR,:DKK)*100
745.08

Unicode

The package knows a few unicode currencies:

  • (EUR)
  • £ (GBP)
  • ¥ (JPY)

but NOT $, as $ has syntactic meaning in julia (string interpolation).

julia> 100€/£
86.706

julia> fromto(:EUR,:GBP)*100
86.706

Updating data

Exchange rates are fetched when the module is loaded. To refresh that data, run ExchangeRates.refresh().

TODO

Integrate with