## Enum StubConvention

• All Implemented Interfaces:
Named, NamedEnum, Serializable, Comparable<StubConvention>

public enum StubConvention
extends Enum<StubConvention>
implements NamedEnum
A convention defining how to calculate stub periods.

A periodic schedule is determined using a periodic frequency. This splits the schedule into "regular" periods of a fixed length, such as every 3 months. Any remaining days are allocated to irregular "stubs" at the start and/or end.

The stub convention is provided as a simple declarative mechanism to define stubs. The convention handles the case of no stubs, or a single stub at the start or end. If there is a stub at both the start and end, then explicit stub dates must be used.

For example, dividing a 24 month (2 year) swap into 3 month periods is easy as it splits exactly. However, a 23 month swap cannot be split into even 3 month periods. Instead, there will be a 2 month "initial" stub at the start, a 2 month "final" stub at the end or both an initial and final stub with a combined length of 2 months.

The 'ShortInitial', 'LongInitial' or 'SmartInitial' convention causes the regular periods to be determined backwards from the end date of the schedule, with remaining days allocated to the stub.

The 'ShortFinal', 'LongFinal' or 'SmartFinal' convention causes the regular periods to be determined forwards from the start date of the schedule, with remaining days allocated to the stub.

The 'None' convention may be used to explicitly indicate there are no stubs.

The 'Both' convention may be used to explicitly indicate there is both an initial and final stub. In this case, dates must be used to identify the stubs.

• ### Enum Constant Summary

Enum Constants
Enum Constant Description
BOTH
Both ends of the schedule have a stub.
LONG_FINAL
A long final stub.
LONG_INITIAL
A long initial stub.
NONE
Explicitly states that there are no stubs.
SHORT_FINAL
A short final stub.
SHORT_INITIAL
A short initial stub.
SMART_FINAL
A smart final stub.
SMART_INITIAL
A smart initial stub.
• ### Method Summary

All Methods
Modifier and Type Method Description
boolean isCalculateBackwards()
Checks if the schedule is calculated backwards from the end date to the start date.
boolean isCalculateForwards()
Checks if the schedule is calculated forwards from the start date to the end date.
boolean isLong()
Checks if this convention tries to produce a long stub.
boolean isShort()
Checks if this convention tries to produce a short stub.
boolean isSmart()
Checks if this convention uses smart rules to create a stub.
static StubConvention of​(String name)
Obtains an instance from the specified name.
RollConvention toRollConvention​(LocalDate start, LocalDate end, Frequency frequency, boolean preferEndOfMonth)
Converts this stub convention to the appropriate roll convention.
String toString()
Returns the formatted name of the type.
static StubConvention valueOf​(String name)
Returns the enum constant of this type with the specified name.
static StubConvention[] values()
Returns an array containing the constants of this enum type, in the order they are declared.
• ### Methods inherited from class java.lang.Enum

clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
• ### Methods inherited from class java.lang.Object

getClass, notify, notifyAll, wait, wait, wait
• ### Methods inherited from interface com.opengamma.strata.collect.named.NamedEnum

getName
• ### Enum Constant Detail

• #### NONE

public static final StubConvention NONE
Explicitly states that there are no stubs.

This is used to indicate that the term of the schedule evenly divides by the periodic frequency leaving no stubs. For example, a 6 month trade can be exactly divided by a 3 month frequency.

If the term of the schedule is less than the frequency, then only one period exists. In this case, the period is not treated as a stub.

When creating a schedule, there must be no explicit stubs.

• #### SHORT_INITIAL

public static final StubConvention SHORT_INITIAL
A short initial stub.

The schedule periods will be determined backwards from the regular period end date. Any remaining period, shorter than the standard frequency, will be allocated at the start.

For example, an 8 month trade with a 3 month periodic frequency would result in a 2 month initial short stub followed by two periods of 3 months.

If there is no remaining period when calculating, then there is no stub. For example, a 6 month trade can be exactly divided by a 3 month frequency.

When creating a schedule, there must be no explicit final stub. If there is an explicit initial stub, then this convention is considered to be matched and the remaining period is calculated using the stub convention 'None'.

• #### LONG_INITIAL

public static final StubConvention LONG_INITIAL
A long initial stub.

The schedule periods will be determined backwards from the regular period end date. Any remaining period, shorter than the standard frequency, will be allocated at the start and combined with the next period, making a total period longer than the standard frequency.

For example, an 8 month trade with a 3 month periodic frequency would result in a 5 month initial long stub followed by one period of 3 months.

If there is no remaining period when calculating, then there is no stub. For example, a 6 month trade can be exactly divided by a 3 month frequency.

When creating a schedule, there must be no explicit final stub. If there is an explicit initial stub, then this convention is considered to be matched and the remaining period is calculated using the stub convention 'None'.

• #### SMART_INITIAL

public static final StubConvention SMART_INITIAL
A smart initial stub.

The schedule periods will be determined backwards from the regular period end date. Any remaining period, shorter than the standard frequency, will be allocated at the start. If this results in a stub of less than 7 days, the stub will be combined with the next period. If this results in a stub of 7 days or more, the stub will be retained. This is the equivalent of LONG_INITIAL up to 7 days and SHORT_INITIAL beyond that. The 7 days are calculated based on unadjusted dates. This convention appears to match that used by Bloomberg.

If there is no remaining period when calculating, then there is no stub. For example, a 6 month trade can be exactly divided by a 3 month frequency.

When creating a schedule, there must be no explicit final stub. If there is an explicit initial stub, then this convention is considered to be matched and the remaining period is calculated using the stub convention 'None'.

• #### SHORT_FINAL

public static final StubConvention SHORT_FINAL
A short final stub.

The schedule periods will be determined forwards from the regular period start date. Any remaining period, shorter than the standard frequency, will be allocated at the end.

For example, an 8 month trade with a 3 month periodic frequency would result in two periods of 3 months followed by a 2 month final short stub.

If there is no remaining period when calculating, then there is no stub. For example, a 6 month trade can be exactly divided by a 3 month frequency.

When creating a schedule, there must be no explicit initial stub. If there is an explicit final stub, then this convention is considered to be matched and the remaining period is calculated using the stub convention 'None'.

• #### LONG_FINAL

public static final StubConvention LONG_FINAL
A long final stub.

The schedule periods will be determined forwards from the regular period start date. Any remaining period, shorter than the standard frequency, will be allocated at the end and combined with the previous period, making a total period longer than the standard frequency.

For example, an 8 month trade with a 3 month periodic frequency would result in one period of 3 months followed by a 5 month final long stub.

If there is no remaining period when calculating, then there is no stub. For example, a 6 month trade can be exactly divided by a 3 month frequency.

When creating a schedule, there must be no explicit initial stub. If there is an explicit final stub, then this convention is considered to be matched and the remaining period is calculated using the stub convention 'None'.

• #### SMART_FINAL

public static final StubConvention SMART_FINAL
A smart final stub.

The schedule periods will be determined forwards from the regular period start date. Any remaining period, shorter than the standard frequency, will be allocated at the end. If this results in a stub of less than 7 days, the stub will be combined with the next period. If this results in a stub of 7 days or more, the stub will be retained. This is the equivalent of LONG_FINAL up to 7 days and SHORT_FINAL beyond that. The 7 days are calculated based on unadjusted dates. This convention appears to match that used by Bloomberg.

If there is no remaining period when calculating, then there is no stub. For example, a 6 month trade can be exactly divided by a 3 month frequency.

When creating a schedule, there must be no explicit initial stub. If there is an explicit final stub, then this convention is considered to be matched and the remaining period is calculated using the stub convention 'None'.

• #### BOTH

public static final StubConvention BOTH
Both ends of the schedule have a stub.

The schedule periods will be determined from two dates - the regular period start date and the regular period end date. Days before the first regular period start date form the initial stub. Days after the last regular period end date form the final stub.

When creating a schedule, there must be both an explicit initial and final stub.

• ### Method Detail

• #### values

public static StubConvention[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (StubConvention c : StubConvention.values())
System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared
• #### valueOf

public static StubConvention valueOf​(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null
• #### of

public static StubConvention of​(String name)
Obtains an instance from the specified name.

Parsing handles the mixed case form produced by toString() and the upper and lower case variants of the enum constant name.

Parameters:
name - the name to parse
Returns:
the type
Throws:
IllegalArgumentException - if the name is not known
• #### toRollConvention

public RollConvention toRollConvention​(LocalDate start,
LocalDate end,
Frequency frequency,
boolean preferEndOfMonth)
Converts this stub convention to the appropriate roll convention.

This converts a stub convention to a RollConvention based on the start date, end date, frequency and preference for end-of-month. The net result is to imply the roll convention from the schedule data.

The rules are as follows:

If the input frequency is month-based, then the implied convention is based on the day-of-month of the initial date, where the initial date is the start date if rolling forwards or the end date otherwise. If that date is on the 31st day, or if the 'preferEndOfMonth' flag is true and the relevant date is at the end of the month, then the implied convention is 'EOM'. For example, if the initial date of the sequence is 2014-06-20 and the periodic frequency is 'P3M' (month-based), then the implied convention is 'Day20'.

If the input frequency is week-based, then the implied convention is based on the day-of-week of the initial date, where the initial date is the start date if rolling forwards or the end date otherwise. For example, if the initial date of the sequence is 2014-06-20 and the periodic frequency is 'P2W' (week-based), then the implied convention is 'DayFri', because 2014-06-20 is a Friday.

In all other cases, the implied convention is 'None'.

Parameters:
start - the start date of the schedule
end - the end date of the schedule
frequency - the periodic frequency of the schedule
preferEndOfMonth - whether to prefer the end-of-month when rolling
Returns:
the derived roll convention
• #### isCalculateForwards

public boolean isCalculateForwards()
Checks if the schedule is calculated forwards from the start date to the end date.

If true, then there will typically be a stub at the end of the schedule.

The 'None', 'ShortFinal', 'LongFinal' and 'SmartFinal' conventions return true. Other conventions return false.

Returns:
true if calculation occurs forwards from the start date to the end date
• #### isCalculateBackwards

public boolean isCalculateBackwards()
Checks if the schedule is calculated backwards from the end date to the start date.

If true, then there will typically be a stub at the start of the schedule.

The 'ShortInitial', 'LongInitial' and 'SmartInitial' conventions return true. Other conventions return false.

Returns:
true if calculation occurs backwards from the end date to the start date
• #### isLong

public boolean isLong()
Checks if this convention tries to produce a long stub.

The 'LongInitial' and 'LongFinal' conventions return true. Other conventions return false.

Returns:
true if there may be a long stub
• #### isShort

public boolean isShort()
Checks if this convention tries to produce a short stub.

The 'ShortInitial' and 'ShortFinal' conventions return true. Other conventions return false.

Returns:
true if there may be a short stub
• #### isSmart

public boolean isSmart()
Checks if this convention uses smart rules to create a stub.

The 'SmartInitial' and 'SmartFinal' conventions return true. Other conventions return false.

Returns:
true if there may be a long stub
• #### toString

public String toString()
Returns the formatted name of the type.
Overrides:
toString in class Enum<StubConvention>
Returns:
the formatted string representing the type