Class FxSwap
- java.lang.Object
-
- com.opengamma.strata.product.fx.FxSwap
-
- All Implemented Interfaces:
Resolvable<ResolvedFxSwap>
,FxProduct
,Product
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class FxSwap extends Object implements FxProduct, Resolvable<ResolvedFxSwap>, org.joda.beans.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.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FxSwap.Meta
The meta-bean forFxSwap
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
CurrencyPair
getCurrencyPair()
Gets the currency pair in conventional order.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 forFxSwap
.FxSwap.Meta
metaBean()
static FxSwap
of(CurrencyAmount amount, FxRate nearRate, LocalDate nearDate, FxRate farRate, LocalDate farDate)
Creates anFxSwap
using two FX rates, near and far, specifying a date adjustment.static FxSwap
of(CurrencyAmount amount, FxRate nearRate, LocalDate nearDate, FxRate farRate, LocalDate farDate, BusinessDayAdjustment paymentDateAdjustment)
Creates anFxSwap
using two FX rates, near and far, specifying a date adjustment.static FxSwap
of(FxSingle nearLeg, FxSingle farLeg)
Creates anFxSwap
from two transactions.static FxSwap
ofForwardPoints(CurrencyAmount amount, FxRate nearRate, double decimalForwardPoints, LocalDate nearDate, LocalDate farDate)
Creates anFxSwap
using decimal forward points.static FxSwap
ofForwardPoints(CurrencyAmount amount, FxRate nearRate, double decimalForwardPoints, LocalDate nearDate, LocalDate farDate, BusinessDayAdjustment paymentDateAdjustment)
Creates anFxSwap
using decimal 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 com.opengamma.strata.product.fx.FxProduct
allCurrencies, isCrossCurrency
-
Methods inherited from interface com.opengamma.strata.product.Product
allPaymentCurrencies
-
-
-
-
Method Detail
-
of
public static FxSwap of(FxSingle nearLeg, FxSingle farLeg)
Creates anFxSwap
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 legfarLeg
- the later leg- Returns:
- the FX swap
-
of
public static FxSwap of(CurrencyAmount amount, FxRate nearRate, LocalDate nearDate, FxRate farRate, LocalDate farDate)
Creates anFxSwap
using two FX rates, near and far, specifying a date adjustment.The FX rate at the near date is specified as
nearRate
. The FX rate at the far date is specified asfarRate
. The FX rates must have the same currency pair.The two currencies are specified by the FX rates. 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 paidnearRate
- the near FX ratefarRate
- the far FX ratenearDate
- the near value datefarDate
- the far value date- Returns:
- the FX swap
- Throws:
IllegalArgumentException
- if the FX rate and amount do not have a currency in common, or if the FX rate currencies differ
-
of
public static FxSwap of(CurrencyAmount amount, FxRate nearRate, LocalDate nearDate, FxRate farRate, LocalDate farDate, BusinessDayAdjustment paymentDateAdjustment)
Creates anFxSwap
using two FX rates, near and far, specifying a date adjustment.The FX rate at the near date is specified as
nearRate
. The FX rate at the far date is specified asfarRate
. The FX rates must have the same currency pair.The two currencies are specified by the FX rates. 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 paidnearRate
- the near FX ratefarRate
- the far FX ratenearDate
- the near value datefarDate
- the far value datepaymentDateAdjustment
- the adjustment to apply to the payment dates- Returns:
- the FX swap
- Throws:
IllegalArgumentException
- if the FX rate and amount do not have a currency in common, or if the FX rate currencies differ
-
ofForwardPoints
public static FxSwap ofForwardPoints(CurrencyAmount amount, FxRate nearRate, double decimalForwardPoints, LocalDate nearDate, LocalDate farDate)
Creates anFxSwap
using decimal forward points.The FX rate at the near date is specified as
nearRate
. The FX rate at the far date is equal tonearRate + forwardPoints
. Thus "FX forward spread" might be a better name for the concept.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 paidnearRate
- the near FX ratedecimalForwardPoints
- the decimal forward points, where the far FX rate is(nearRate + forwardPoints)
nearDate
- the near value datefarDate
- the far value date- Returns:
- the FX swap
- Throws:
IllegalArgumentException
- if the FX rate and amount do not have a currency in common
-
ofForwardPoints
public static FxSwap ofForwardPoints(CurrencyAmount amount, FxRate nearRate, double decimalForwardPoints, LocalDate nearDate, LocalDate farDate, BusinessDayAdjustment paymentDateAdjustment)
Creates anFxSwap
using decimal 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 tonearRate + forwardPoints
Thus "FX forward spread" might be a better name for the concept.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 paidnearRate
- the near FX ratedecimalForwardPoints
- the decimal forward points, where the far FX rate is(nearRate + forwardPoints)
nearDate
- the near value datefarDate
- the far value datepaymentDateAdjustment
- the adjustment to apply to the payment dates- Returns:
- the FX swap
- Throws:
IllegalArgumentException
- if the FX rate and amount do not have a currency in common
-
getCurrencyPair
public CurrencyPair getCurrencyPair()
Gets the currency pair in conventional order.- Specified by:
getCurrencyPair
in interfaceFxProduct
- Returns:
- the currency pair
-
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 interfaceResolvable<ResolvedFxSwap>
- Parameters:
refData
- the reference data to use when resolving- Returns:
- the resolved instance
-
meta
public static FxSwap.Meta meta()
The meta-bean forFxSwap
.- Returns:
- the meta-bean, not null
-
metaBean
public FxSwap.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.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
-
-