Class FxSingle
- java.lang.Object
-
- com.opengamma.strata.product.fx.FxSingle
-
- All Implemented Interfaces:
Resolvable<ResolvedFxSingle>,FxProduct,Product,Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class FxSingle extends Object implements FxProduct, Resolvable<ResolvedFxSingle>, org.joda.beans.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.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFxSingle.MetaThe meta-bean forFxSingle.
-
Field Summary
Fields Modifier and Type Field Description static org.joda.beans.ser.SerDeserializerDESERIALIZERThe deserializer, for compatibility.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)CurrencyAmountgetBaseCurrencyAmount()Gets the amount in the base currency, positive if receiving, negative if paying.PaymentgetBaseCurrencyPayment()Gets the payment in the base currency, positive if receiving, negative if paying.CurrencyAmountgetCounterCurrencyAmount()Gets the amount in the counter currency, positive if receiving, negative if paying.PaymentgetCounterCurrencyPayment()Gets the payment in the counter currency, positive if receiving, negative if paying.CurrencyPairgetCurrencyPair()Gets currency pair of the base currency and counter currency.CurrencyAmountgetPayCurrencyAmount()Gets the currency amount in which the amount is paid.LocalDategetPaymentDate()Gets the last payment date.Optional<BusinessDayAdjustment>getPaymentDateAdjustment()Gets the payment date adjustment, optional.CurrencyAmountgetReceiveCurrencyAmount()Gets the currency amount in which the amount is received.inthashCode()static FxSingle.Metameta()The meta-bean forFxSingle.FxSingle.MetametaBean()static FxSingleof(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate)Creates anFxSinglefrom two amounts and the value date.static FxSingleof(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)Creates anFxSinglefrom two amounts and the value date, specifying a date adjustment.static FxSingleof(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate)Creates anFxSingleusing a rate.static FxSingleof(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)Creates anFxSingleusing a rate, specifying a date adjustment.static FxSingleof(Payment payment1, Payment payment2)Creates anFxSinglefrom two payments.static FxSingleof(Payment payment1, Payment payment2, BusinessDayAdjustment paymentDateAdjustment)Creates anFxSinglefrom two payments, specifying a date adjustment.ResolvedFxSingleresolve(ReferenceData refData)Resolves this object using the specified reference data.StringtoString()-
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 FxSingle of(Payment payment1, Payment payment2)
Creates anFxSinglefrom 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.
- Parameters:
payment1- the payment in the first currencypayment2- the payment in the second currency- Returns:
- the FX
-
of
public static FxSingle of(Payment payment1, Payment payment2, BusinessDayAdjustment paymentDateAdjustment)
Creates anFxSinglefrom 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.
- Parameters:
payment1- the payment in the first currencypayment2- the payment in the second currencypaymentDateAdjustment- the adjustment to apply to the payment date- Returns:
- the FX
-
of
public static FxSingle of(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate)
Creates anFxSinglefrom 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.
- Parameters:
amount1- the amount in the first currencyamount2- the amount in the second currencypaymentDate- the date that the FX settles- Returns:
- the FX
-
of
public static FxSingle of(CurrencyAmount amount1, CurrencyAmount amount2, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)
Creates anFxSinglefrom 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 currencyamount2- the amount in the second currencypaymentDate- the date that the FX settlespaymentDateAdjustment- the adjustment to apply to the payment date- Returns:
- the FX
-
of
public static FxSingle of(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate)
Creates anFxSingleusing 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.
- Parameters:
amount- the amount being exchanged, positive if being received, negative if being paidfxRate- the FX ratepaymentDate- the date that the FX settles- Returns:
- the FX
- Throws:
IllegalArgumentException- if the FX rate and amount do not have a currency in common
-
of
public static FxSingle of(CurrencyAmount amount, FxRate fxRate, LocalDate paymentDate, BusinessDayAdjustment paymentDateAdjustment)
Creates anFxSingleusing 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 paidfxRate- the FX ratepaymentDate- the date that the FX settlespaymentDateAdjustment- the adjustment to apply to the payment date- Returns:
- the FX
- Throws:
IllegalArgumentException- if the FX rate and amount do not have a currency in common
-
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.
- Specified by:
getCurrencyPairin interfaceFxProduct- Returns:
- the currency pair
-
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 amount
-
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 amount
-
getPayCurrencyAmount
public CurrencyAmount getPayCurrencyAmount()
Gets the currency amount in which the amount is paid.This returns the currency amount whose amount is negative or zero.
- Returns:
- the pay currency amount
-
getReceiveCurrencyAmount
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,
counterCurrencyAmountis returned.- Returns:
- the receive currency amount
-
getPaymentDate
public LocalDate getPaymentDate()
Gets the last payment date.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.
- Returns:
- the latest payment date
-
resolve
public ResolvedFxSingle resolve(ReferenceData refData)
Description copied from interface:ResolvableResolves this object using the specified reference data.This converts the object implementing this interface to the equivalent resolved form. All
ReferenceDataIdidentifiers 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:
resolvein interfaceResolvable<ResolvedFxSingle>- Parameters:
refData- the reference data to use when resolving- Returns:
- the resolved instance
-
meta
public static FxSingle.Meta meta()
The meta-bean forFxSingle.- Returns:
- the meta-bean, not null
-
metaBean
public FxSingle.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getBaseCurrencyPayment
public Payment getBaseCurrencyPayment()
Gets the payment 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.
The payment date is usually the same as
counterCurrencyPayment. It is typically a valid business day, however thebusinessDayAdjustmentproperty may be used to adjust it.- Returns:
- the value of the property, not null
-
getCounterCurrencyPayment
public Payment getCounterCurrencyPayment()
Gets the payment 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.
The payment date is usually the same as
baseCurrencyPayment. It is typically a valid business day, however thebusinessDayAdjustmentproperty may be used to adjust it.- Returns:
- the value of the property, not null
-
getPaymentDateAdjustment
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
-
-