Currencies, currency pairs and interest rate indices are key building blocks to a coherent financial mathematics library. As currencies are the basis for transactions, they bring together different conventions in a unique manner. Currency pairs are required to define the terms of FX transactions while interest rate indices define the payoffs of the largest over-the-counter derivatives asset class.

Currencies

The fmbasics package supplies implementations of the following key currencies: AUD, EUR, GBP, JPY, NZD and USD. The 2006 ISDA definitions map these currencies to financial centres for the purposes of determining whether banks and FX markets settle payments on a given date.

library("fmbasics")
(aud <- AUD())
#> <Currency> AUD
#> [1] "AUD"
#> <JointCalendar> AUSY
#>    TZ: Australia/Sydney
#>    Join rule: all

You can create other currencies by calling Currency(). However, you will need to define the currency’s associated fmdates::Calendar first (along with its associated fmdates::is_good() method).

Currency pairs

It is also possible to create currency pairs and calculate value dates:

#> <CurrencyPair> AUDUSD
dates <- as.Date(c("2014-04-16", "2014-04-19"))
to_fx_value(dates, 'today', audusd)
#> [1] "2014-04-16" NA
to_fx_value(dates, 'spot', audusd)
#> [1] "2014-04-22" "2014-04-23"
to_fx_value(dates, 'spot_next', audusd)
#> [1] "2014-04-23" "2014-04-24"
to_fx_value(dates, 'tomorrow', audusd)
#> [1] "2014-04-17" "2014-04-22"
to_fx_value(dates, months(3), audusd)
#> [1] "2014-07-22" "2014-07-23"

You can create other currency pairs by calling CurrencyPair():

#> <CurrencyPair> USDAUD

Interest rate indices

Interest rate indices are key to defining the payoffs on interest rate derivatives such as interest rate swaps, swaptions, etc. The fmbasics package provides implementations of the most important indices for the currencies that it supports including “xIBOR” and “xONIA” indices such as USDLIBOR and EONIA.

library("lubridate")
AONIA()
#> <CashIndex> AONIA
#> <CashIndex> FedFunds
#> <IborIndex> 3m AUD BBSW
#> <IborIndex> 3m USD LIBOR

You can use determine key dates associated with these indices relative to supplied dates such as the reset dates, value date and maturity date:

to_reset(ymd(20170105) + days(0:2), USDLIBOR(months(3)))
#> [1] "2017-01-03" "2017-01-04" "2017-01-05"
to_value(ymd(20170105) + days(0:2), USDLIBOR(months(3)))
#> [1] "2017-01-09" "2017-01-10" "2017-01-10"
to_maturity(ymd(20170105) + days(0:2), USDLIBOR(months(3)))
#> [1] "2017-04-05" "2017-04-06" "2017-04-07"