A collection of methods related to currency pairs.

is_t1(x)

to_spot(dates, x)

to_spot_next(dates, x)

to_forward(dates, tenor, x)

to_today(dates, x)

to_tomorrow(dates, x)

to_fx_value(dates, tenor, x)

invert(x)

Arguments

x

a CurrencyPair object

dates

a vector of dates from which forward dates are calculated

tenor

the tenor of the value date which can be one of the following: "spot", "spot_next", "today", "tomorrow" and the usual "forward" dates (e.g. lubridate::months(3))

Details

The methods are summarised as follows:

  • is_t1: Returns TRUE if the currency pair settles one good day after trade. This includes the following currencies crossed with the USD: CAD, TRY, PHP, RUB, KZT and PKR

  • to_spot: The spot dates are usually two non-NY good day after today. is_t1() identifies the pairs whose spot dates are conventionally one good non-NYC day after today. In both cases, if those dates are not a good NYC day, they are rolled to good NYC and non-NYC days using the Following convention.

  • to_spot_next: The spot next dates are one good NYC and non-NYC day after spot rolled using the Following convention if necessary.

  • to_forward: Forward dates are determined using the calendar's shift() method rolling bad NYC and non-NYC days using the Following convention. The end-to-end convention applies.

  • to_today: Today is simply dates which are good NYC and non-NYC days. Otherwise today is undefined and returns NA.

  • to_tomorrow: Tomorrow is one good NYC and non-NYC day except where that is on or after spot. In that case, is is undefined and returns NA.

  • to_value: Determine common value dates. The supported value date tenors are: "spot", "spot_next", "today", "tomorrow" and the usual "forward" dates (e.g. lubridate::months(3)).

  • invert: Inverts the currency pair and returns new CurrencyPair object.

  • is.CurrencyPair: Returns TRUE if x inherits from the CurrencyPair class; otherwise FALSE

Examples

library(lubridate) is_t1(AUDUSD())
#> [1] FALSE
dts <- lubridate::ymd(20170101) + lubridate::days(0:30) to_spot(dts, AUDUSD())
#> [1] "2017-01-04" "2017-01-04" "2017-01-05" "2017-01-06" "2017-01-09" #> [6] "2017-01-10" "2017-01-10" "2017-01-10" "2017-01-11" "2017-01-12" #> [11] "2017-01-13" "2017-01-17" "2017-01-17" "2017-01-17" "2017-01-17" #> [16] "2017-01-18" "2017-01-19" "2017-01-20" "2017-01-23" "2017-01-24" #> [21] "2017-01-24" "2017-01-24" "2017-01-25" "2017-01-27" "2017-01-30" #> [26] "2017-01-30" "2017-01-31" "2017-01-31" "2017-01-31" "2017-02-01" #> [31] "2017-02-02"
to_spot_next(dts, AUDUSD())
#> [1] "2017-01-05" "2017-01-05" "2017-01-06" "2017-01-09" "2017-01-10" #> [6] "2017-01-11" "2017-01-11" "2017-01-11" "2017-01-12" "2017-01-13" #> [11] "2017-01-17" "2017-01-18" "2017-01-18" "2017-01-18" "2017-01-18" #> [16] "2017-01-19" "2017-01-20" "2017-01-23" "2017-01-24" "2017-01-25" #> [21] "2017-01-25" "2017-01-25" "2017-01-27" "2017-01-30" "2017-01-31" #> [26] "2017-01-31" "2017-02-01" "2017-02-01" "2017-02-01" "2017-02-02" #> [31] "2017-02-03"
to_today(dts, AUDUSD())
#> [1] NA NA "2017-01-03" "2017-01-04" "2017-01-05" #> [6] "2017-01-06" NA NA "2017-01-09" "2017-01-10" #> [11] "2017-01-11" "2017-01-12" "2017-01-13" NA NA #> [16] "2017-01-16" "2017-01-17" "2017-01-18" "2017-01-19" "2017-01-20" #> [21] NA NA "2017-01-23" "2017-01-24" "2017-01-25" #> [26] NA "2017-01-27" NA NA "2017-01-30" #> [31] "2017-01-31"
to_tomorrow(dts, AUDUSD())
#> [1] "2017-01-03" "2017-01-03" "2017-01-04" "2017-01-05" "2017-01-06" #> [6] "2017-01-09" "2017-01-09" "2017-01-09" "2017-01-10" "2017-01-11" #> [11] "2017-01-12" "2017-01-13" "2017-01-16" "2017-01-16" "2017-01-16" #> [16] "2017-01-17" "2017-01-18" "2017-01-19" "2017-01-20" "2017-01-23" #> [21] "2017-01-23" "2017-01-23" "2017-01-24" "2017-01-25" "2017-01-27" #> [26] "2017-01-27" "2017-01-30" "2017-01-30" "2017-01-30" "2017-01-31" #> [31] "2017-02-01"
to_fx_value(dts, months(3), AUDUSD())
#> [1] "2017-04-04" "2017-04-04" "2017-04-05" "2017-04-06" "2017-04-09" #> [6] "2017-04-10" "2017-04-10" "2017-04-10" "2017-04-11" "2017-04-12" #> [11] "2017-04-13" "2017-04-17" "2017-04-17" "2017-04-17" "2017-04-17" #> [16] "2017-04-18" "2017-04-19" "2017-04-20" "2017-04-23" "2017-04-24" #> [21] "2017-04-24" "2017-04-24" "2017-04-25" "2017-04-27" "2017-04-30" #> [26] "2017-04-30" "2017-04-30" "2017-04-30" "2017-04-30" "2017-05-01" #> [31] "2017-05-02"