Class ResolvedSwapLeg
- java.lang.Object
-
- com.opengamma.strata.product.swap.ResolvedSwapLeg
-
- All Implemented Interfaces:
Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class ResolvedSwapLeg extends Object implements org.joda.beans.ImmutableBean, Serializable
A resolved swap leg, with dates calculated ready for pricing.A swap is a financial instrument that represents the exchange of streams of payments. The swap is formed of legs, where each leg typically represents the obligations of the seller or buyer of the swap.
This class defines a single swap leg in the form of a list of payment periods. Each payment period typically consists of one or more accrual periods.
Any combination of payment and accrual periods is supported in the data model, however there is no guarantee that exotic combinations will price sensibly.
All periods and events must be in the same currency.
A
ResolvedSwapLeg
contains information based on holiday calendars. If a holiday calendar changes, the adjusted dates may no longer be correct. Care must be taken when placing the resolved form in a cache or persistence layer.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResolvedSwapLeg.Builder
The bean-builder forResolvedSwapLeg
.static class
ResolvedSwapLeg.Meta
The meta-bean forResolvedSwapLeg
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ResolvedSwapLeg.Builder
builder()
Returns a builder used to create an instance of the bean.void
collectIndices(ImmutableSet.Builder<Index> builder)
Collects all the indices referred to by this leg.boolean
equals(Object obj)
Optional<CurrencyAmount>
findNotional(LocalDate date)
Finds the notional on the specified date.Optional<SwapPaymentPeriod>
findPaymentPeriod(LocalDate date)
Finds the payment period applicable for the specified accrual date.Currency
getCurrency()
Gets the primary currency of the swap leg.LocalDate
getEndDate()
Gets the accrual end date of the leg.ImmutableList<SwapPaymentEvent>
getPaymentEvents()
Gets the payment events that are associated with the swap leg.ImmutableList<SwapPaymentPeriod>
getPaymentPeriods()
Gets the payment periods that combine to form the swap leg.PayReceive
getPayReceive()
Gets whether the leg is pay or receive.LocalDate
getStartDate()
Gets the accrual start date of the leg.SwapLegType
getType()
Gets the type of the leg, such as Fixed or Ibor.int
hashCode()
static ResolvedSwapLeg.Meta
meta()
The meta-bean forResolvedSwapLeg
.ResolvedSwapLeg.Meta
metaBean()
ResolvedSwapLeg.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
-
-
-
Method Detail
-
getStartDate
public LocalDate getStartDate()
Gets the accrual start date of the leg.This is the first accrual date in the leg, often known as the effective date. This date has typically been adjusted to be a valid business day.
- Returns:
- the start date of the leg
-
getEndDate
public LocalDate getEndDate()
Gets the accrual end date of the leg.This is the last accrual date in the leg, often known as the termination date. This date has typically been adjusted to be a valid business day.
- Returns:
- the end date of the leg
-
getCurrency
public Currency getCurrency()
Gets the primary currency of the swap leg.Any currency associated with FX reset is not included.
- Returns:
- the currency
-
findPaymentPeriod
public Optional<SwapPaymentPeriod> findPaymentPeriod(LocalDate date)
Finds the payment period applicable for the specified accrual date.Each payment period contains one or more accrual periods. This method finds the matching accrual period and returns the payment period that holds it. Periods are considered to contain the end date but not the start date If no accrual period contains the date, an empty optional is returned.
- Parameters:
date
- the date to find- Returns:
- the payment period applicable at the date
-
collectIndices
public void collectIndices(ImmutableSet.Builder<Index> builder)
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.
- Parameters:
builder
- the builder to use
-
findNotional
public Optional<CurrencyAmount> findNotional(LocalDate date)
Finds the notional on the specified date.If the date falls before the start, the initial notional will be returned. If the date falls after the end, the final notional will be returned.
An empty optional is returned if the leg has no notional, for example if the payment amount is known and explicitly specified.
- Parameters:
date
- the date on which the notional is required- Returns:
- the notional on the specified date, if available
-
meta
public static ResolvedSwapLeg.Meta meta()
The meta-bean forResolvedSwapLeg
.- Returns:
- the meta-bean, not null
-
builder
public static ResolvedSwapLeg.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public ResolvedSwapLeg.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.
- Returns:
- the value of the property, not null
-
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.
- Returns:
- the value of the property, not null
-
getPaymentPeriods
public ImmutableList<SwapPaymentPeriod> 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
-
getPaymentEvents
public ImmutableList<SwapPaymentEvent> getPaymentEvents()
Gets the payment events that are associated with the swap leg.Payment events include notional exchange and fees.
- Returns:
- the value of the property, not null
-
toBuilder
public ResolvedSwapLeg.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-