com.opengamma.strata.product.fx

## Class FxSingle

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

public final class FxSingle
extends Object
implements Product, Resolvable<ResolvedFxSingle>, ImmutableBean, Serializable
A single foreign exchange, such as an FX forward or FX spot.

An FX is a financial instrument that represents the exchange of an equivalent amount in two different currencies between counterparties on a specific date. For example, it might represent the payment of USD 1,000 and the receipt of EUR 932.

FX spot and FX forward are essentially equivalent, simply with a different way to obtain the payment date; they are both represented using this class.

Serialized Form
• ### Nested Class Summary

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

All Methods
Modifier and Type Method and Description
boolean equals(Object obj)
CurrencyAmount getBaseCurrencyAmount()
Gets the amount in the base currency, positive if receiving, negative if paying.
CurrencyAmount getCounterCurrencyAmount()
Gets the amount in the counter currency, positive if receiving, negative if paying.
CurrencyPair getCurrencyPair()
Gets currency pair of the base currency and counter currency.
LocalDate getPaymentDate()
Gets the date that the FX settles.
Optional<BusinessDayAdjustment> getPaymentDateAdjustment()
Gets the payment date adjustment, optional.
CurrencyAmount getReceiveCurrencyAmount()
Gets the currency amount in which the amount is received.
int hashCode()
static FxSingle.Meta meta()
The meta-bean for FxSingle.
FxSingle.Meta metaBean()
static FxSingle of(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate)
Creates an FxSingle from two amounts and the value date.
static FxSingle of(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)
Creates an FxSingle from two amounts and the value date, specifying a date adjustment.
static FxSingle of(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate)
Creates an FxSingle using a rate.
static FxSingle of(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)
Creates an FxSingle using a rate, specifying a date adjustment.
ResolvedFxSingle 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 FxSingle of(CurrencyAmount amount1,
CurrencyAmount amount2,
LocalDate paymentDate)
Creates an FxSingle from two amounts and the value date.

The amounts must be of the correct type, one pay and one receive. The currencies of the payments must differ.

This factory identifies the currency pair of the exchange and assigns the payments to match the base or counter currency of the standardized currency pair. For example, a EUR/USD exchange always has EUR as the base payment and USD as the counter payment.

Parameters:
amount1 - the amount in the first currency
amount2 - the amount in the second currency
paymentDate - the date that the FX settles
Returns:
the FX
• #### of

public static FxSingle of(CurrencyAmount amount1,
CurrencyAmount amount2,
LocalDate paymentDate,
BusinessDayAdjustment paymentDateAdjustment)
Creates an FxSingle from two amounts and the value date, specifying a date adjustment.

The amounts must be of the correct type, one pay and one receive. The currencies of the payments must differ.

This factory identifies the currency pair of the exchange and assigns the payments to match the base or counter currency of the standardized currency pair. For example, a EUR/USD exchange always has EUR as the base payment and USD as the counter payment.

Parameters:
amount1 - the amount in the first currency
amount2 - the amount in the second currency
paymentDate - the date that the FX settles
paymentDateAdjustment - the adjustment to apply to the payment date
Returns:
the FX
• #### of

public static FxSingle of(CurrencyAmount amount,
FxRate fxRate,
LocalDate paymentDate)
Creates an FxSingle using a rate.

This creates a single foreign exchange specifying the amount, FX rate and value date. The amount must be specified using one of the currencies of the FX rate.

This factory identifies the currency pair of the exchange and assigns the payments to match the base or counter currency of the standardized currency pair. For example, a EUR/USD exchange always has EUR as the base payment and USD as the counter payment.

Parameters:
amount - the amount being exchanged, positive if being received, negative if being paid
fxRate - the FX rate
paymentDate - the date that the FX settles
Returns:
the FX
• #### of

public static FxSingle of(CurrencyAmount amount,
FxRate fxRate,
LocalDate paymentDate,
BusinessDayAdjustment paymentDateAdjustment)
Creates an FxSingle using a rate, specifying a date adjustment.

This creates a single foreign exchange specifying the amount, FX rate and value date. The amount must be specified using one of the currencies of the FX rate.

This factory identifies the currency pair of the exchange and assigns the payments to match the base or counter currency of the standardized currency pair. For example, a EUR/USD exchange always has EUR as the base payment and USD as the counter payment.

Parameters:
amount - the amount being exchanged, positive if being received, negative if being paid
fxRate - the FX rate
paymentDate - the date that the FX settles
paymentDateAdjustment - the adjustment to apply to the payment date
Returns:
the FX
• #### getCurrencyPair

public CurrencyPair getCurrencyPair()
Gets currency pair of the base currency and counter currency.

This currency pair is conventional, thus indifferent to the direction of FX.

Returns:
the currency pair

public CurrencyAmount getReceiveCurrencyAmount()
Gets the currency amount in which the amount is received.

This returns the currency amount whose amount is non-negative. If both are zero, counterCurrencyAmount is returned.

Returns:
• #### resolve

public ResolvedFxSingle 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<ResolvedFxSingle>
Parameters:
refData - the reference data to use when resolving
Returns:
the resolved instance
• #### meta

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

public FxSingle.Meta metaBean()
Specified by:
metaBean in interface Bean
• #### getBaseCurrencyAmount

public CurrencyAmount getBaseCurrencyAmount()
Gets the amount in the base currency, positive if receiving, negative if paying.

The amount is signed. A positive amount indicates the payment is to be received. A negative amount indicates the payment is to be paid.

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

public CurrencyAmount getCounterCurrencyAmount()
Gets the amount in the counter currency, positive if receiving, negative if paying.

The amount is signed. A positive amount indicates the payment is to be received. A negative amount indicates the payment is to be paid.

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

public LocalDate getPaymentDate()
Gets the date that the FX settles.

On this date, the pay and receive amounts will be exchanged. This date is typically a valid business day, however the businessDayAdjustment property may be used to adjust it.

Returns:
the value of the property, not null

public Optional<BusinessDayAdjustment> getPaymentDateAdjustment()
Gets the payment date adjustment, optional.

If present, the adjustment will be applied to the payment date.

Returns:
the optional 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