public interface RollConvention extends Named
A periodic schedule is determined using a periodic frequency. When applying the frequency, the roll convention is used to fine tune the dates. This might involve selecting the last day of the month, or the third Wednesday.
To get the next date in the schedule, take the base date and the periodic frequency. Once this date is calculated, the roll convention is applied to produce the next schedule date.
The most common implementations are provided as constants on RollConventions.
Additional implementations may be added by implementing this interface.
All implementations of this interface must be immutable and thread-safe.
| Modifier and Type | Method and Description |
|---|---|
LocalDate |
adjust(LocalDate date)
Adjusts the date according to the rules of the roll convention.
|
static ExtendedEnum<RollConvention> |
extendedEnum()
Gets the extended enum helper.
|
default int |
getDayOfMonth()
Gets the day-of-month that the roll convention implies.
|
String |
getName()
Gets the name that uniquely identifies this convention.
|
default boolean |
matches(LocalDate date)
Checks if the date matches the rules of the roll convention.
|
default LocalDate |
next(LocalDate date,
Frequency periodicFrequency)
Calculates the next date in the sequence after the input date.
|
static RollConvention |
of(String uniqueName)
Obtains an instance from the specified unique name.
|
static RollConvention |
ofDayOfMonth(int dayOfMonth)
Obtains an instance from the day-of-month.
|
static RollConvention |
ofDayOfWeek(DayOfWeek dayOfWeek)
Obtains an instance from the day-of-week.
|
default LocalDate |
previous(LocalDate date,
Frequency periodicFrequency)
Calculates the previous date in the sequence after the input date.
|
static RollConvention of(String uniqueName)
uniqueName - the unique nameIllegalArgumentException - if the name is not knownstatic RollConvention ofDayOfMonth(int dayOfMonth)
This convention will adjust the input date to the specified day-of-month. The year and month of the result date will be the same as the input date. It is intended for use with periods that are a multiple of months.
If the month being adjusted has a length less than the requested day-of-month then the last valid day-of-month will be chosen. As such, passing 31 to this method is equivalent to selecting the end-of-month convention.
dayOfMonth - the day-of-month, from 1 to 31IllegalArgumentException - if the day-of-month is invalidstatic RollConvention ofDayOfWeek(DayOfWeek dayOfWeek)
This convention will adjust the input date to the specified day-of-week. It is intended for use with periods that are a multiple of weeks.
In adjust(), if the input date is not the required day-of-week,
then the next occurrence of the day-of-week is selected, up to 6 days later.
In next(), the day-of-week is selected after the frequency is added.
If the calculated date is not the required day-of-week, then the next occurrence
of the day-of-week is selected, up to 6 days later.
In previous(), the day-of-week is selected after the frequency is subtracted.
If the calculated date is not the required day-of-week, then the previous occurrence
of the day-of-week is selected, up to 6 days earlier.
dayOfWeek - the day-of-weekstatic ExtendedEnum<RollConvention> extendedEnum()
This helper allows instances of the convention to be looked up. It also provides the complete set of available instances.
LocalDate adjust(LocalDate date)
See the description of each roll convention to understand the rule applied.
It is recommended to use next() and previous() rather than
directly using this method.
date - the date to adjustdefault boolean matches(LocalDate date)
See the description of each roll convention to understand the rule applied.
date - the date to checkdefault LocalDate next(LocalDate date, Frequency periodicFrequency)
This takes the input date, adds the periodic frequency and adjusts the date as necessary to match the roll convention rules. The result will always be after the input date.
The default implementation is suitable for month-based conventions.
date - the date to adjustperiodicFrequency - the periodic frequency of the scheduledefault LocalDate previous(LocalDate date, Frequency periodicFrequency)
This takes the input date, subtracts the periodic frequency and adjusts the date as necessary to match the roll convention rules. The result will always be before the input date.
The default implementation is suitable for month-based conventions.
date - the date to adjustperiodicFrequency - the periodic frequency of the scheduledefault int getDayOfMonth()
This extracts the day-of-month for simple roll conventions. The numeric roll conventions will return their day-of-month. The 'EOM' convention will return 31. All other conventions will return zero.
String getName()
This name is used in serialization and can be parsed using of(String).
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.