public final class SchedulePeriod extends Object implements org.joda.beans.ImmutableBean, Comparable<SchedulePeriod>, Serializable
This consists of a single period (date range) within a schedule. This is typically used as the basis for financial calculations, such as accrual of interest.
Two pairs of dates are provided, start/end and unadjustedStart/unadjustedEnd.
The period itself runs from startDate to endDate.
The unadjustedStartDate and unadjustedEndDate are the dates used to
calculate the startDate and endDate when applying business day adjustment.
For example, consider a schedule that has periods every three months on the 10th of the month. From time to time, the scheduled date will be a weekend or holiday. In this case, a rule may apply moving the date to a valid business day. If this happens, then the "unadjusted" date is the original date in the periodic schedule and the "adjusted" date is the related valid business day. Note that not all schedules apply a business day adjustment.
| Modifier and Type | Class and Description |
|---|---|
static class |
SchedulePeriod.Builder
The bean-builder for
SchedulePeriod. |
static class |
SchedulePeriod.Meta
The meta-bean for
SchedulePeriod. |
| Modifier and Type | Method and Description |
|---|---|
static SchedulePeriod.Builder |
builder()
Returns a builder used to create an instance of the bean.
|
int |
compareTo(SchedulePeriod other)
Compares this period to another by unadjusted start date, then unadjusted end date.
|
boolean |
contains(LocalDate date)
Checks if this period contains the specified date.
|
boolean |
equals(Object obj) |
LocalDate |
getEndDate()
Gets the end date of this period, used for financial calculations such as interest accrual.
|
LocalDate |
getStartDate()
Gets the start date of this period, used for financial calculations such as interest accrual.
|
LocalDate |
getUnadjustedEndDate()
Gets the unadjusted end date.
|
LocalDate |
getUnadjustedStartDate()
Gets the unadjusted start date.
|
int |
hashCode() |
boolean |
isRegular(Frequency frequency,
RollConvention rollConvention)
Checks if this period is regular according to the specified frequency and roll convention.
|
Period |
length()
Returns the length of the period.
|
int |
lengthInDays()
Calculates the number of days in the period.
|
static SchedulePeriod.Meta |
meta()
The meta-bean for
SchedulePeriod. |
SchedulePeriod.Meta |
metaBean() |
static SchedulePeriod |
of(LocalDate startDate,
LocalDate endDate)
Obtains an instance from two dates.
|
static SchedulePeriod |
of(LocalDate startDate,
LocalDate endDate,
LocalDate unadjustedStartDate,
LocalDate unadjustedEndDate)
Obtains an instance from the adjusted and unadjusted dates.
|
PeriodicSchedule |
subSchedule(Frequency frequency,
RollConvention rollConvention,
StubConvention stubConvention,
BusinessDayAdjustment adjustment)
Creates a sub-schedule within this period.
|
SchedulePeriod |
toAdjusted(DateAdjuster adjuster)
Converts this period to one where the start and end dates are adjusted using the specified adjuster.
|
SchedulePeriod.Builder |
toBuilder()
Returns a builder that allows this bean to be mutated.
|
String |
toString() |
SchedulePeriod |
toUnadjusted()
Converts this period to one where the start and end dates are set to the unadjusted dates.
|
double |
yearFraction(DayCount dayCount,
Schedule schedule)
Calculates the year fraction using the specified day count.
|
public static SchedulePeriod of(LocalDate startDate, LocalDate endDate, LocalDate unadjustedStartDate, LocalDate unadjustedEndDate)
startDate - the start date, used for financial calculations such as interest accrualendDate - the end date, used for financial calculations such as interest accrualunadjustedStartDate - the unadjusted start dateunadjustedEndDate - the adjusted end datepublic static SchedulePeriod of(LocalDate startDate, LocalDate endDate)
This factory is used when there is no business day adjustment of schedule dates.
startDate - the start date, used for financial calculations such as interest accrualendDate - the end date, used for financial calculations such as interest accrualpublic Period length()
This returns the length of the period, considering the adjusted start and end dates.
The calculation does not involve a day count or holiday calendar.
The period is calculated using Period.between(LocalDate, LocalDate) and as
such includes the start date and excludes the end date.
public int lengthInDays()
This returns the actual number of days in the period, considering the adjusted start and end dates. The calculation does not involve a day count or holiday calendar. The length includes one date and excludes the other.
public double yearFraction(DayCount dayCount, Schedule schedule)
Additional information from the schedule is made available to the day count algorithm.
dayCount - the day count conventionschedule - the schedule that contains this periodpublic boolean isRegular(Frequency frequency, RollConvention rollConvention)
A schedule period is normally created from a frequency and roll convention. These can therefore be used to determine if the period is regular, which simply means that the period end date can be generated from the start date and vice versa.
frequency - the frequencyrollConvention - the roll conventionpublic boolean contains(LocalDate date)
The adjusted start and end dates are used in the comparison. The start date is included, the end date is excluded.
date - the date to checkpublic PeriodicSchedule subSchedule(Frequency frequency, RollConvention rollConvention, StubConvention stubConvention, BusinessDayAdjustment adjustment)
The sub-schedule will have the one or more periods. The schedule is bounded by the unadjusted start and end date of this period. The frequency and roll convention are used to build unadjusted schedule dates. The stub convention is used to handle any remaining time when the new frequency does not evenly divide into the period.
frequency - the frequency of the sub-schedulerollConvention - the roll convention to use for rollingstubConvention - the stub convention to use for any excessadjustment - the business day adjustment to apply to the sub-scheduleScheduleException - if the schedule cannot be createdpublic SchedulePeriod toAdjusted(DateAdjuster adjuster)
The start date of the result will be the start date of this period as altered by the specified adjuster. The end date of the result will be the end date of this period as altered by the specified adjuster. The unadjusted start date and unadjusted end date will be the same as in this period.
The adjuster will typically be obtained from BusinessDayAdjustment.resolve(ReferenceData).
adjuster - the adjuster to useIllegalArgumentException - if a period is invalid once adjustedpublic SchedulePeriod toUnadjusted()
The start date of the result will be the unadjusted start date of this period. The end date of the result will be the unadjusted end date of this period. The unadjusted start date and unadjusted end date will be the same as in this period.
public int compareTo(SchedulePeriod other)
compareTo in interface Comparable<SchedulePeriod>other - the other periodpublic static SchedulePeriod.Meta meta()
SchedulePeriod.public static SchedulePeriod.Builder builder()
public SchedulePeriod.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic LocalDate getStartDate()
The first date in the schedule period, typically treated as inclusive. If the schedule adjusts for business days, then this is the adjusted date.
public LocalDate getEndDate()
The last date in the schedule period, typically treated as exclusive. If the schedule adjusts for business days, then this is the adjusted date.
public LocalDate getUnadjustedStartDate()
The start date before any business day adjustment. If the schedule adjusts for business days, then this is typically the regular periodic date. If the schedule does not adjust for business days, then this is the same as the start date.
When building, this will default to the start date if not specified.
public LocalDate getUnadjustedEndDate()
The end date before any business day adjustment. If the schedule adjusts for business days, then this is typically the regular periodic date. If the schedule does not adjust for business days, then this is the same as the end date.
When building, this will default to the end date if not specified.
public SchedulePeriod.Builder toBuilder()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.