public final class Swap extends Object implements Product, Resolvable<ResolvedSwap>, org.joda.beans.ImmutableBean, Serializable
A rate 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. In the simplest vanilla interest rate swap, there are two legs, one with a fixed rate and the other a floating rate. Many other more complex swaps can also be represented.
For example, a swap might involve an agreement to exchange the difference between the fixed rate of 1% and the 'GBP-LIBOR-3M' rate every 3 months for 2 years.
| Modifier and Type | Class and Description |
|---|---|
static class |
Swap.Builder
The bean-builder for
Swap. |
static class |
Swap.Meta
The meta-bean for
Swap. |
| Modifier and Type | Method and Description |
|---|---|
ImmutableSet<Currency> |
allCurrencies()
Returns the set of currencies referred to by the swap.
|
ImmutableSet<Index> |
allIndices()
Returns the set of indices referred to by the swap.
|
ImmutableSet<Currency> |
allPaymentCurrencies()
Returns the set of payment currencies referred to by the swap.
|
static Swap.Builder |
builder()
Returns a builder used to create an instance of the bean.
|
boolean |
equals(Object obj) |
AdjustableDate |
getEndDate()
Gets the accrual end date of the swap.
|
Optional<SwapLeg> |
getLeg(PayReceive payReceive)
Gets the first pay or receive leg of the swap.
|
ImmutableList<SwapLeg> |
getLegs()
Gets the legs of the swap.
|
ImmutableList<SwapLeg> |
getLegs(SwapLegType type)
Gets the legs of the swap with the specified type.
|
Optional<SwapLeg> |
getPayLeg()
Gets the first pay leg of the swap.
|
Optional<SwapLeg> |
getReceiveLeg()
Gets the first receive leg of the swap.
|
AdjustableDate |
getStartDate()
Gets the accrual start date of the swap.
|
int |
hashCode() |
static Swap.Meta |
meta()
The meta-bean for
Swap. |
Swap.Meta |
metaBean() |
static Swap |
of(List<? extends SwapLeg> legs)
Creates a swap from one or more swap legs.
|
static Swap |
of(SwapLeg... legs)
Creates a swap from one or more swap legs.
|
Swap |
replaceStartDate(LocalDate adjustedStartDate)
Returns an instance based on this swap with the start date replaced.
|
ResolvedSwap |
resolve(ReferenceData refData) |
String |
summaryDescription()
Summarizes this swap into string form.
|
Swap.Builder |
toBuilder()
Returns a builder that allows this bean to be mutated.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitisCrossCurrencypublic static Swap of(SwapLeg... legs)
While most swaps have two legs, other combinations are possible.
legs - the array of legspublic static Swap of(List<? extends SwapLeg> legs)
While most swaps have two legs, other combinations are possible.
legs - the list of legspublic ImmutableList<SwapLeg> getLegs(SwapLegType type)
This returns all the legs with the given type.
type - the type to findpublic Optional<SwapLeg> getLeg(PayReceive payReceive)
This returns the first pay or receive leg of the swap, empty if no matching leg.
payReceive - the pay or receive flagpublic Optional<SwapLeg> getPayLeg()
This returns the first pay leg of the swap, empty if no pay leg.
public Optional<SwapLeg> getReceiveLeg()
This returns the first receive leg of the swap, empty if no receive leg.
public AdjustableDate getStartDate()
This is the earliest accrual date of the legs, often known as the effective date. The latest date is chosen by examining the unadjusted end date.
public AdjustableDate getEndDate()
This is the latest accrual date of the legs, often known as the termination date. The latest date is chosen by examining the unadjusted end date.
public ImmutableSet<Currency> allPaymentCurrencies()
This returns the complete set of payment currencies for the swap. This will typically return one or two currencies.
If there is an FX reset, then this set contains the currency of the payment, not the currency of the notional. Note that in many cases, the currency of the FX reset notional will be the currency of the other leg.
allPaymentCurrencies in interface Productpublic ImmutableSet<Currency> allCurrencies()
This returns the complete set of currencies for the swap, not just the payment currencies.
allCurrencies in interface Productpublic ImmutableSet<Index> allIndices()
A swap 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.
public String summaryDescription()
public Swap replaceStartDate(LocalDate adjustedStartDate)
This is used to change the start date of the swap, and is currently used by Swaption.
adjustedStartDate - the new adjusted start dateIllegalArgumentException - if the start date cannot be replaced with the proposed start dateUnsupportedOperationException - if changing the start date is not supportedpublic ResolvedSwap resolve(ReferenceData refData)
resolve in interface Resolvable<ResolvedSwap>public static Swap.Meta meta()
Swap.public static Swap.Builder builder()
public Swap.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic ImmutableList<SwapLeg> getLegs()
A swap consists of one or more legs. The legs of a swap are essentially unordered, however it is more efficient and closer to user expectation to treat them as being ordered.
public Swap.Builder toBuilder()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.