com.opengamma.strata.product.fx

## Class FxSwap

• All Implemented Interfaces:
Resolvable<ResolvedFxSwap>, Product, Serializable, Bean, ImmutableBean

public final class FxSwap
extends Object
implements Product, Resolvable<ResolvedFxSwap>, ImmutableBean, Serializable
An FX swap.

An FX swap is a financial instrument that represents the exchange of an equivalent amount in two different currencies between counterparties on two different dates.

The two exchanges are based on the same currency pair, with the two payment flows in the opposite directions.

For example, an FX swap might represent the payment of USD 1,000 and the receipt of EUR 932 on one date, and the payment of EUR 941 and the receipt of USD 1,000 at a later date.

Serialized Form
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  FxSwap.Meta
The meta-bean for FxSwap.
• ### Method Summary

All Methods
Modifier and Type Method and Description
boolean equals(Object obj)
FxSingle getFarLeg()
Gets the foreign exchange transaction at the later date.
FxSingle getNearLeg()
Gets the foreign exchange transaction at the earlier date.
int hashCode()
static FxSwap.Meta meta()
The meta-bean for FxSwap.
FxSwap.Meta metaBean()
static FxSwap of(FxSingle nearLeg, FxSingle farLeg)
Creates an FxSwap from two transactions.
static FxSwap ofForwardPoints(CurrencyAmount amount, FxRate nearRate, double forwardPoints, LocalDate nearDate, LocalDate farDate)
Creates an FxSwap using forward points.
static FxSwap ofForwardPoints(CurrencyAmount amount, FxRate nearRate, double forwardPoints, LocalDate nearDate, LocalDate farDate, BusinessDayAdjustment paymentDateAdjustment)
Creates an FxSwap using forward points, specifying a date adjustment.
ResolvedFxSwap resolve(ReferenceData refData)
Resolves this object using the specified reference data.
String toString()
• ### Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait
• ### Methods inherited from interface org.joda.beans.Bean

property, propertyNames
• ### Method Detail

• #### of

public static FxSwap of(FxSingle nearLeg,
FxSingle farLeg)
Creates an FxSwap from two transactions.

The transactions must be passed in with value dates in the correct order. The currency pair of each leg must match and have amounts flowing in opposite directions.

Parameters:
nearLeg - the earlier leg
farLeg - the later leg
Returns:
the FX swap
• #### ofForwardPoints

public static FxSwap ofForwardPoints(CurrencyAmount amount,
FxRate nearRate,
double forwardPoints,
LocalDate nearDate,
LocalDate farDate)
Creates an FxSwap using forward points.

The FX rate at the near date is specified as nearRate. The FX rate at the far date is equal to nearRate + forwardPoints

The two currencies are specified by the near FX rate. The amount must be specified using one of the currencies of the near FX rate. The near date must be before the far date. Conventions will be used to determine the base and counter currency.

Parameters:
amount - the amount being exchanged, positive if being received in the near leg, negative if being paid
nearRate - the near FX rate
forwardPoints - the forward points, where the far FX rate is (nearRate + forwardPoints)
nearDate - the near value date
farDate - the far value date
Returns:
the FX swap
• #### ofForwardPoints

public static FxSwap ofForwardPoints(CurrencyAmount amount,
FxRate nearRate,
double forwardPoints,
LocalDate nearDate,
LocalDate farDate,
BusinessDayAdjustment paymentDateAdjustment)
Creates an FxSwap using forward points, specifying a date adjustment.

The FX rate at the near date is specified as nearRate. The FX rate at the far date is equal to nearRate + forwardPoints

The two currencies are specified by the near FX rate. The amount must be specified using one of the currencies of the near FX rate. The near date must be before the far date. Conventions will be used to determine the base and counter currency.

Parameters:
amount - the amount being exchanged, positive if being received in the near leg, negative if being paid
nearRate - the near FX rate
forwardPoints - the forward points, where the far FX rate is (nearRate + forwardPoints)
nearDate - the near value date
farDate - the far value date
paymentDateAdjustment - the adjustment to apply to the payment dates
Returns:
the FX swap
• #### resolve

public ResolvedFxSwap resolve(ReferenceData refData)
Description copied from interface: Resolvable
Resolves this object using the specified reference data.

This converts the object implementing this interface 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 interface Resolvable<ResolvedFxSwap>
Parameters:
refData - the reference data to use when resolving
Returns:
the resolved instance
• #### meta

public static FxSwap.Meta meta()
The meta-bean for FxSwap.
Returns:
the meta-bean, not null
• #### metaBean

public FxSwap.Meta metaBean()
Specified by:
metaBean in interface Bean
• #### getNearLeg

public FxSingle getNearLeg()
Gets the foreign exchange transaction at the earlier date.

This provides details of a single foreign exchange at a specific date. The payment date of this transaction must be before that of the far leg.

Returns:
the value of the property, not null
• #### getFarLeg

public FxSingle getFarLeg()
Gets the foreign exchange transaction at the later date.

This provides details of a single foreign exchange at a specific date. The payment date of this transaction must be after that of the near leg.

Returns:
the value of the property, not null
• #### equals

public boolean equals(Object obj)
Overrides:
equals in class Object
• #### hashCode

public int hashCode()
Overrides:
hashCode in class Object
• #### toString

public String toString()
Overrides:
toString in class Object