public final class FxSingle extends Object implements FxProduct, Resolvable<ResolvedFxSingle>, org.joda.beans.ImmutableBean, Serializable
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.
Modifier and Type | Class and Description |
---|---|
static class |
FxSingle.Meta
The meta-bean for
FxSingle . |
Modifier and Type | Field and Description |
---|---|
static org.joda.beans.ser.SerDeserializer |
DESERIALIZER
The deserializer, for compatibility.
|
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.
|
Payment |
getBaseCurrencyPayment()
Gets the payment 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.
|
Payment |
getCounterCurrencyPayment()
Gets the payment in the counter currency, positive if receiving, negative if paying.
|
CurrencyPair |
getCurrencyPair()
Gets currency pair of the base currency and counter currency.
|
CurrencyAmount |
getPayCurrencyAmount()
Gets the currency amount in which the amount is paid.
|
LocalDate |
getPaymentDate()
Gets the last payment date.
|
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. |
static FxSingle |
of(Payment payment1,
Payment payment2)
Creates an
FxSingle from two payments. |
static FxSingle |
of(Payment payment1,
Payment payment2,
BusinessDayAdjustment paymentDateAdjustment)
Creates an
FxSingle from two payments, specifying a date adjustment. |
ResolvedFxSingle |
resolve(ReferenceData refData) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
allCurrencies, isCrossCurrency
allPaymentCurrencies
public static final org.joda.beans.ser.SerDeserializer DESERIALIZER
public static FxSingle of(Payment payment1, Payment payment2)
FxSingle
from two payments.
The payments must be of the correct type, one pay and one receive. The currencies of the payments must differ. The payment dates may 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.
No payment date adjustments apply.
payment1
- the payment in the first currencypayment2
- the payment in the second currencypublic static FxSingle of(Payment payment1, Payment payment2, BusinessDayAdjustment paymentDateAdjustment)
FxSingle
from two payments, specifying a date adjustment.
The payments must be of the correct type, one pay and one receive. The currencies of the payments must differ. The payment dates may 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.
payment1
- the payment in the first currencypayment2
- the payment in the second currencypaymentDateAdjustment
- the adjustment to apply to the payment datepublic static FxSingle of(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate)
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.
No payment date adjustments apply.
amount1
- the amount in the first currencyamount2
- the amount in the second currencypaymentDate
- the date that the FX settlespublic static FxSingle of(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)
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.
amount1
- the amount in the first currencyamount2
- the amount in the second currencypaymentDate
- the date that the FX settlespaymentDateAdjustment
- the adjustment to apply to the payment datepublic static FxSingle of(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate)
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.
No payment date adjustments apply.
amount
- the amount being exchanged, positive if being received, negative if being paidfxRate
- the FX ratepaymentDate
- the date that the FX settlesIllegalArgumentException
- if the FX rate and amount do not have a currency in commonpublic static FxSingle of(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)
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.
amount
- the amount being exchanged, positive if being received, negative if being paidfxRate
- the FX ratepaymentDate
- the date that the FX settlespaymentDateAdjustment
- the adjustment to apply to the payment dateIllegalArgumentException
- if the FX rate and amount do not have a currency in commonpublic CurrencyPair getCurrencyPair()
This currency pair is conventional, thus indifferent to the direction of FX.
getCurrencyPair
in interface FxProduct
public CurrencyAmount getBaseCurrencyAmount()
The amount is signed. A positive amount indicates the payment is to be received. A negative amount indicates the payment is to be paid.
public CurrencyAmount getCounterCurrencyAmount()
The amount is signed. A positive amount indicates the payment is to be received. A negative amount indicates the payment is to be paid.
public CurrencyAmount getPayCurrencyAmount()
This returns the currency amount whose amount is negative or zero.
public CurrencyAmount getReceiveCurrencyAmount()
This returns the currency amount whose amount is non-negative.
If both are zero, counterCurrencyAmount
is returned.
public LocalDate getPaymentDate()
The payment date is normally the same for the base and counter currencies. If it differs, this method returns the latest of the two dates.
public ResolvedFxSingle resolve(ReferenceData refData)
resolve
in interface Resolvable<ResolvedFxSingle>
public static FxSingle.Meta meta()
FxSingle
.public FxSingle.Meta metaBean()
metaBean
in interface org.joda.beans.Bean
public Payment getBaseCurrencyPayment()
The amount is signed. A positive amount indicates the payment is to be received. A negative amount indicates the payment is to be paid.
The payment date is usually the same as counterCurrencyPayment
.
It is typically a valid business day, however the businessDayAdjustment
property may be used to adjust it.
public Payment getCounterCurrencyPayment()
The amount is signed. A positive amount indicates the payment is to be received. A negative amount indicates the payment is to be paid.
The payment date is usually the same as baseCurrencyPayment
.
It is typically a valid business day, however the businessDayAdjustment
property may be used to adjust it.
public Optional<BusinessDayAdjustment> getPaymentDateAdjustment()
If present, the adjustment will be applied to the payment date.
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.