Skip to contents

Get the corresponding maturity date for the three characters string that represent maturity of futures contracts.

Usage

maturity2date(x, expr = "first day", refdate = NULL)

Arguments

x

a character vector with three letters string that represent maturity of futures contracts.

expr

a string which indicates the day to use in maturity date. See bizdays::getdate for more details on this argument.

refdate

reference date to be passed. It is necessary to convert old maturities like JAN0, that can be Jan/2000 or Jan/2010. If refdate is greater that 2001-01-01 JAN0 is converted to Jan/2010, otherwise, Jan/2000.

Value

a Date vector with maturity dates

Examples

maturity2date(c("F22", "F23", "G23", "H23", "F45"), "first day")
#> [1] "2022-01-01" "2023-01-01" "2023-02-01" "2023-03-01" "2045-01-01"
maturity2date(c("F23", "K35"), "15th day")
#> [1] "2023-01-15" "2035-05-15"
maturity2date(c("AGO2", "SET2"), "first day")
#> [1] "2002-08-01" "2002-09-01"