Interface SwapLeg
-
- All Superinterfaces:
Resolvable<ResolvedSwapLeg>
- All Known Subinterfaces:
ScheduledSwapLeg
- All Known Implementing Classes:
KnownAmountSwapLeg
,RateCalculationSwapLeg
,RatePeriodSwapLeg
public interface SwapLeg extends Resolvable<ResolvedSwapLeg>
A single leg of a swap.A swap leg is one element of a
Swap
. In most cases, a swap has two legs, one expressing the obligations of the seller and one expressing the obligations of the buyer. However, it is possible to represent more complex swaps, with one, three or more legs.This interface imposes few restrictions on the swap leg. A leg must have a start and end date, where the start date can be before or after the date that the swap is traded. A single swap leg must produce payments in a single currency.
In most cases, a swap will consist of a list of payment periods, but this is not required by this interface. The
ResolvedSwapLeg
class, which this leg can be converted to, does define the swap in terms of payment periods.Implementations must be immutable and thread-safe beans.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ImmutableSet<Currency>
allCurrencies()
Returns the set of currencies referred to by the leg.default ImmutableSet<Index>
allIndices()
Returns the set of indices referred to by the leg.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.Currency
getCurrency()
Gets the payment currency of the leg.AdjustableDate
getEndDate()
Gets the accrual end date of the 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.default SwapLeg
replaceStartDate(LocalDate adjustedStartDate)
Returns an instance based on this leg with the start date replaced.ResolvedSwapLeg
resolve(ReferenceData refData)
Resolves this swap leg using the specified reference data.
-
-
-
Method Detail
-
getType
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 leg type
-
getPayReceive
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.
- Returns:
- the pay receive flag
-
getStartDate
AdjustableDate getStartDate()
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.
- Returns:
- the start date of the leg
-
getEndDate
AdjustableDate getEndDate()
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.
- Returns:
- the end date of the leg
-
getCurrency
Currency getCurrency()
Gets the payment currency of the leg.A swap leg has a single payment currency.
- Returns:
- the payment currency of the leg
-
allCurrencies
default ImmutableSet<Currency> allCurrencies()
Returns the set of currencies referred to by the leg.This returns the complete set of currencies for the leg, not just the payment currencies. For example, if there is an FX reset, then this set contains both the currency of the payment and the currency of the notional.
- Returns:
- the set of currencies referred to by this leg
-
collectCurrencies
void collectCurrencies(ImmutableSet.Builder<Currency> builder)
Collects all the currencies referred to by this leg.This collects the complete set of currencies for the leg, not just the payment currencies.
- Parameters:
builder
- the builder to populate
-
allIndices
default ImmutableSet<Index> allIndices()
Returns the set of indices referred to by the leg.A leg will typically refer to at least one index, such as 'GBP-LIBOR-3M'. Calling this method will return the complete list of indices, including any associated with FX reset.
- Returns:
- the set of indices referred to by this leg
-
collectIndices
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 populate
-
replaceStartDate
default SwapLeg replaceStartDate(LocalDate adjustedStartDate)
Returns an instance based on this leg with the start date replaced.This is used to change the start date of the leg, and is currently used by
Swaption
.See each implementation for details of how the override is performed.
- Parameters:
adjustedStartDate
- the new adjusted start date- Returns:
- the updated leg
- Throws:
IllegalArgumentException
- if the start date cannot be replaced with the proposed start dateUnsupportedOperationException
- if changing the start date is not supported
-
resolve
ResolvedSwapLeg resolve(ReferenceData refData)
Resolves this swap leg using the specified reference data.This converts the swap leg to the equivalent resolved form. All
ReferenceDataId
identifiers in this instance will be resolved. The resolved form will typically be a type that is optimized for pricing.Resolved objects may be bound to data that changes over time, such as holiday calendars. If the data changes, such as the addition of a new holiday, the resolved form will not be updated. Care must be taken when placing the resolved form in a cache or persistence layer.
- Specified by:
resolve
in interfaceResolvable<ResolvedSwapLeg>
- Parameters:
refData
- the reference data to use when resolving- Returns:
- the resolved instance
- Throws:
ReferenceDataNotFoundException
- if an identifier cannot be resolved in the reference dataRuntimeException
- if unable to resolve due to an invalid definition
-
-