Class RatePeriodSwapLeg
- java.lang.Object
-
- com.opengamma.strata.product.swap.RatePeriodSwapLeg
-
- All Implemented Interfaces:
Resolvable<ResolvedSwapLeg>
,SwapLeg
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class RatePeriodSwapLeg extends Object implements SwapLeg, org.joda.beans.ImmutableBean, Serializable
A rate swap leg defined using payment and accrual periods.This defines a single swap leg paying a rate, such as an interest rate. The rate may be fixed or floating, for examples see
FixedRateComputation
,IborRateComputation
andOvernightCompoundedRateComputation
.The swap is built up of one or more payment periods, each of which produces a single payment. Each payment period is made up of one or more accrual periods. If there is more than one accrual period in a payment period then compounding may apply. See
RatePaymentPeriod
andRateAccrualPeriod
for more details.This class allows the entire structure of the payment and accrual periods to be defined. This permits weird and wonderful swaps to be created, however it is important to note that there is no ability to adjust the accrual period dates if the holiday calendar changes. Provision is provided to adjust the payment dates if the holiday calendar changes. Note however that it is intended that the dates on
RatePaymentPeriod
andRateAccrualPeriod
are already adjusted to be valid business days.In general, it is recommended to use the parameterized
RateCalculationSwapLeg
instead of this class.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RatePeriodSwapLeg.Builder
The bean-builder forRatePeriodSwapLeg
.static class
RatePeriodSwapLeg.Meta
The meta-bean forRatePeriodSwapLeg
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RatePeriodSwapLeg.Builder
builder()
Returns a builder used to create an instance of the bean.void
collectCurrencies(ImmutableSet.Builder<Currency> builder)
Collects all the currencies referred to by this leg.void
collectIndices(ImmutableSet.Builder<Index> builder)
Collects all the indices referred to by this leg.boolean
equals(Object obj)
Currency
getCurrency()
Gets the payment currency of the leg.AdjustableDate
getEndDate()
Gets the accrual end date of the leg.BusinessDayAdjustment
getPaymentBusinessDayAdjustment()
Gets the business day date adjustment to be applied to each payment date, default is to apply no adjustment.ImmutableList<SwapPaymentEvent>
getPaymentEvents()
Gets the additional payment events that are associated with the swap leg.ImmutableList<RatePaymentPeriod>
getPaymentPeriods()
Gets the payment periods that combine to form the swap leg.PayReceive
getPayReceive()
Gets whether the leg is pay or receive.AdjustableDate
getStartDate()
Gets the accrual start date of the leg.SwapLegType
getType()
Gets the type of the leg, such as Fixed or Ibor.int
hashCode()
boolean
isFinalExchange()
Gets the flag indicating whether to exchange the final notional.boolean
isInitialExchange()
Gets the flag indicating whether to exchange the initial notional.boolean
isIntermediateExchange()
Gets the flag indicating whether to exchange the differences in the notional during the lifetime of the swap.static RatePeriodSwapLeg.Meta
meta()
The meta-bean forRatePeriodSwapLeg
.RatePeriodSwapLeg.Meta
metaBean()
RatePeriodSwapLeg
replaceStartDate(LocalDate adjustedStartDate)
Returns an instance based on this leg with a different start date.ResolvedSwapLeg
resolve(ReferenceData refData)
Converts this swap leg to the equivalentResolvedSwapLeg
.RatePeriodSwapLeg.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.product.swap.SwapLeg
allCurrencies, allIndices
-
-
-
-
Method Detail
-
getStartDate
public AdjustableDate getStartDate()
Description copied from interface:SwapLeg
Gets the accrual start date of the leg.This is the first accrual date in the leg, often known as the effective date.
Defined as the effective date by the 2006 ISDA definitions article 3.2.
- Specified by:
getStartDate
in interfaceSwapLeg
- Returns:
- the start date of the leg
-
getEndDate
public AdjustableDate getEndDate()
Description copied from interface:SwapLeg
Gets the accrual end date of the leg.This is the last accrual date in the leg, often known as the termination date.
Defined as the termination date by the 2006 ISDA definitions article 3.3.
- Specified by:
getEndDate
in interfaceSwapLeg
- Returns:
- the end date of the leg
-
getCurrency
public Currency getCurrency()
Description copied from interface:SwapLeg
Gets the payment currency of the leg.A swap leg has a single payment currency.
- Specified by:
getCurrency
in interfaceSwapLeg
- Returns:
- the payment currency of the leg
-
collectCurrencies
public void collectCurrencies(ImmutableSet.Builder<Currency> builder)
Description copied from interface:SwapLeg
Collects all the currencies referred to by this leg.This collects the complete set of currencies for the leg, not just the payment currencies.
- Specified by:
collectCurrencies
in interfaceSwapLeg
- Parameters:
builder
- the builder to populate
-
collectIndices
public void collectIndices(ImmutableSet.Builder<Index> builder)
Description copied from interface:SwapLeg
Collects all the indices referred to by this leg.A swap leg will typically refer to at least one index, such as 'GBP-LIBOR-3M'. Each index that is referred to must be added to the specified builder.
- Specified by:
collectIndices
in interfaceSwapLeg
- Parameters:
builder
- the builder to populate
-
replaceStartDate
public RatePeriodSwapLeg replaceStartDate(LocalDate adjustedStartDate)
Returns an instance based on this leg with a different start date.The proposed start date must exactly match the start date of one of the existing periods.
- Specified by:
replaceStartDate
in interfaceSwapLeg
- Parameters:
adjustedStartDate
- the new adjusted start date- Returns:
- the updated leg
- Throws:
IllegalArgumentException
- if the start date cannot be replaced with the proposed start date
-
resolve
public ResolvedSwapLeg resolve(ReferenceData refData)
Converts this swap leg to the equivalentResolvedSwapLeg
.An
ResolvedSwapLeg
represents the same data as this leg, but with the schedules resolved to beSwapPaymentPeriod
instances.- Specified by:
resolve
in interfaceResolvable<ResolvedSwapLeg>
- Specified by:
resolve
in interfaceSwapLeg
- Parameters:
refData
- the reference data to use when resolving- Returns:
- the equivalent resolved swap leg
- Throws:
ReferenceDataNotFoundException
- if an identifier cannot be resolved in the reference dataRuntimeException
- if unable to resolve due to an invalid definition
-
meta
public static RatePeriodSwapLeg.Meta meta()
The meta-bean forRatePeriodSwapLeg
.- Returns:
- the meta-bean, not null
-
builder
public static RatePeriodSwapLeg.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public RatePeriodSwapLeg.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getType
public SwapLegType getType()
Gets the type of the leg, such as Fixed or Ibor.This provides a high level categorization of the swap leg.
-
getPayReceive
public PayReceive getPayReceive()
Gets whether the leg is pay or receive.A value of 'Pay' implies that the resulting amount is paid to the counterparty. A value of 'Receive' implies that the resulting amount is received from the counterparty. Note that negative interest rates can result in a payment in the opposite direction to that implied by this indicator.
The value of this flag should match the signs of the payment period notionals.
- Specified by:
getPayReceive
in interfaceSwapLeg
- Returns:
- the value of the property, not null
-
getPaymentPeriods
public ImmutableList<RatePaymentPeriod> getPaymentPeriods()
Gets the payment periods that combine to form the swap leg.Each payment period represents part of the life-time of the leg. In most cases, the periods do not overlap. However, since each payment period is essentially independent the data model allows overlapping periods.
The start date and end date of the leg are determined from the first and last period. As such, the periods should be sorted.
- Returns:
- the value of the property, not empty
-
isInitialExchange
public boolean isInitialExchange()
Gets the flag indicating whether to exchange the initial notional.Setting this to true indicates that the notional is transferred at the start of the trade. This should typically be set to true in the case of an FX reset swap, or one with a varying notional.
This flag controls whether a notional exchange object is created when the leg is resolved. It covers an exchange on the initial payment date of the swap leg, treated as the start date. If there is an FX reset, then this flag is ignored, see
intermediateExchange
. If there is no FX reset and the flag is true, then aNotionalExchange
object will be created.- Returns:
- the value of the property
-
isIntermediateExchange
public boolean isIntermediateExchange()
Gets the flag indicating whether to exchange the differences in the notional during the lifetime of the swap.Setting this to true indicates that the notional is transferred when it changes during the trade. This should typically be set to true in the case of an FX reset swap, or one with a varying notional.
This flag controls whether a notional exchange object is created when the leg is resolved. It covers an exchange on each intermediate payment date of the swap leg. If set to true, the behavior depends on whether an FX reset payment period is defined. If there is an FX reset, then an
FxResetNotionalExchange
object will be created. If there is no FX reset, then aNotionalExchange
object will be created.- Returns:
- the value of the property
-
isFinalExchange
public boolean isFinalExchange()
Gets the flag indicating whether to exchange the final notional.Setting this to true indicates that the notional is transferred at the end of the trade. This should typically be set to true in the case of an FX reset swap, or one with a varying notional.
This flag controls whether a notional exchange object is created when the leg is resolved. It covers an exchange on the final payment date of the swap leg. If there is an FX reset, then this flag is ignored, see
intermediateExchange
. If there is no FX reset and the flag is true, then aNotionalExchange
object will be created.- Returns:
- the value of the property
-
getPaymentEvents
public ImmutableList<SwapPaymentEvent> getPaymentEvents()
Gets the additional payment events that are associated with the swap leg.Payment events include fees. Notional exchange may also be specified here instead of via the dedicated fields.
- Returns:
- the value of the property, not null
-
getPaymentBusinessDayAdjustment
public BusinessDayAdjustment getPaymentBusinessDayAdjustment()
Gets the business day date adjustment to be applied to each payment date, default is to apply no adjustment.The business day adjustment is applied to period, exchange and event payment dates.
- Returns:
- the value of the property, not null
-
toBuilder
public RatePeriodSwapLeg.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-