fmdates v0.1.4

0

Monthly downloads

0th

Percentile

Financial Market Date Calculations

Implements common date calculations relevant for specifying the economic nature of financial market contracts that are typically defined by International Swap Dealer Association (ISDA, <http://www2.isda.org>) legal documentation. This includes methods to check whether dates are business days in certain locales, functions to adjust and shift dates and time length (or day counter) calculations.

Readme

fmdates

CRAN\_Status\_Badge License Travis build status Appveyor build status Coverage Status

Motivation

Over-the-counter (OTC) derivatives comprise a significant proportion of trading activity in global financial markets. Their general contractual conventions are specified in what are known as International Swap and Derivatives Association (ISDA) definitions. For example, FX and currency option transactions are governed by the 1998 FX and Currency Options Definitions and swap transactions are governed by the 2006 ISDA Definitions. They describe in meticulous detail, among other things, how the dates of certain financial events should be determined. This includes how dates are defined to be good or bad and how bad dates are to be adjusted to good dates. They also define how to determine the length of time between two dates.

This package implements calendars used to define locale specific business days, date adjusters and shifters, schedule generators and year fraction calculations defined by these standards.

Calendars

You can determine whether dates are business days in a specific locale or specific locales:

library("lubridate", warn.conflicts = FALSE)
library("fmdates")
ausy <- AUSYCalendar()
aume <- AUMECalendar()
syme <- c(ausy, aume) # handy JointCalendar construction approach
is_good(ymd(20140404), ausy)
#> [1] TRUE
is_good(ymd(20141104), syme) # Melbourne Cup holiday
#> [1] FALSE
syme$rule <- any
is_good(ymd(20141104), syme)
#> [1] TRUE

Adjusters and shifters

You can adjust (or roll) and shift dates using predefined business day conventions:

# Adjust using the modified following convention
adjust(ymd(20140404), 'mf', ausy)
#> [1] "2014-04-04"
# Shift dates
shift(ymd(20120229), months(1), 'u', ausy, FALSE) # one month
#> [1] "2012-03-29"
shift(ymd(20120229), months(1), 'mf', ausy, TRUE)  # one month with EOM rule
#> [1] "2012-03-30"
shift(ymd(20120229), years(1) + months(3), 'mf', ausy, TRUE)  # 1y3m
#> [1] "2013-05-31"

Schedules

The preceding methods are used to generate schedules of dates required to define common financial contracts events such as cash flow exchange dates:

generate_schedule(effective_date = ymd(20120103), termination_date = ymd(20130103), 
  tenor = months(3), calendar = ausy, bdc = "mf", stub = "short_front", 
  eom_rule = FALSE)
#> [1] 2012-01-03 UTC--2012-04-03 UTC 2012-04-03 UTC--2012-07-03 UTC
#> [3] 2012-07-03 UTC--2012-10-03 UTC 2012-10-03 UTC--2013-01-03 UTC

Year fractions

Time lengths then usually need to be computed for each interval of such a schedule according to some day basis convention:

# 30/360us convention
year_frac(ymd("2010-03-31"), ymd("2012-03-31"), "30/360us")
#> [1] 2
# act/365 convention
year_frac(ymd("2010-02-28"), ymd("2012-03-31"), "act/365")
#> [1] 2.087671

More details can be found in the associated help files and the vignette (vignette("dates", "fmdates")). If you would like to contribute to the package please see the CONTRIBUTING.md file for general as well as specific suggestions.

Functions in fmdates

Name Description
generate_schedule Generate a date schedule
is Calendar class checkers
actual_actual_isda The years between two dates using the Actual/Actual ISDA day basis convention
adjust Adjust to good dates
is_valid_bdc Business day conventions
is_valid_day_basis Day basis conventions
thirty_360_eu The years between two dates using the 30/360 (EU) day basis convention.
thirty_360_eu_isda The years between two dates using the 30E/360 ISDA day basis convention.
actual_365 The years between two dates using the actual/365 (fixed) day basis convention.
actual_360 The years between two dates using the actual/360 day basis convention.
is_eom Checks whether dates are last day of month
is_good Good date checker
thirty_360_eu_plus The years between two dates using the 30E+/360 day basis convention.
easter_monday Easter Monday day of year
eom The end of month date
julian_day_to_gregorian Determine Gregorian date from Julian day
locale Extract locale from calendars
tz Extract time zone from calendars
year_frac The years between two dates for a given day basis convention
thirty_360_us The years between two dates using the 30/360 (US) day basis convention.
equinox March and September equinox
fmdates fmdates
thirty_360 The years between two dates using the 30/360 day basis convention.
shift Shifting dates to good dates
Calendar Build a calendar
JointCalendar Joint calendars
No Results!

Vignettes of fmdates

Name
dates.Rmd
No Results!

Last month downloads

Details

Type Package
License GPL-2
URL https://github.com/imanuelcostigan/fmdates, https://imanuelcostigan.github.io/fmdates/
BugReports https://github.com/imanuelcostigan/fmdates/issues
VignetteBuilder knitr
Encoding UTF-8
LazyData true
RoxygenNote 6.0.1
NeedsCompilation no
Packaged 2018-01-04 22:33:58 UTC; imanuel
Repository CRAN
Date/Publication 2018-01-04 23:07:49 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/fmdates)](http://www.rdocumentation.org/packages/fmdates)