Class ImmutableFxIndex
- java.lang.Object
-
- com.opengamma.strata.basics.index.ImmutableFxIndex
-
- All Implemented Interfaces:
FxIndex
,Index
,Named
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class ImmutableFxIndex extends Object implements FxIndex, org.joda.beans.ImmutableBean, Serializable
A foreign exchange index implementation based on an immutable set of rules.A standard immutable implementation of
FxIndex
that defines the currency pair and the rule for converting from fixing to maturity.In most cases, applications should refer to indices by name, using
FxIndex.of(String)
. The named index will typically be resolved to an instance of this class. As such, it is recommended to use theFxIndex
interface in application code rather than directly referring to this class.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImmutableFxIndex.Builder
The bean-builder forImmutableFxIndex
.static class
ImmutableFxIndex.Meta
The meta-bean forImmutableFxIndex
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutableFxIndex.Builder
builder()
Returns a builder used to create an instance of the bean.LocalDate
calculateFixingFromMaturity(LocalDate maturityDate, ReferenceData refData)
Calculates the fixing date from the maturity date.LocalDate
calculateMaturityFromFixing(LocalDate fixingDate, ReferenceData refData)
Calculates the maturity date from the fixing date.boolean
equals(Object obj)
CurrencyPair
getCurrencyPair()
Gets the currency pair.HolidayCalendarId
getFixingCalendar()
Gets the calendar that determines which dates are fixing dates.DaysAdjustment
getFixingDateOffset()
Gets the adjustment applied to the maturity date to obtain the fixing date.DaysAdjustment
getMaturityDateOffset()
Gets the adjustment applied to the fixing date to obtain the maturity date.String
getName()
Gets the index name, such as 'EUR/GBP-ECB'.int
hashCode()
static ImmutableFxIndex.Meta
meta()
The meta-bean forImmutableFxIndex
.ImmutableFxIndex.Meta
metaBean()
Function<LocalDate,FxIndexObservation>
resolve(ReferenceData refData)
Resolves this index using the specified reference data, returning a function.ImmutableFxIndex.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
Returns the name of the index.
-
-
-
Method Detail
-
calculateMaturityFromFixing
public LocalDate calculateMaturityFromFixing(LocalDate fixingDate, ReferenceData refData)
Description copied from interface:FxIndex
Calculates the maturity date from the fixing date.The fixing date is the date on which the index is to be observed. The maturity date is the date on which the implied amount is delivered/exchanged. The maturity date is typically two days after the fixing date.
No error is thrown if the input date is not a valid fixing date. Instead, the fixing date is moved to the next valid fixing date and then processed.
The maturity date is also known as the value date.
- Specified by:
calculateMaturityFromFixing
in interfaceFxIndex
- Parameters:
fixingDate
- the fixing daterefData
- the reference data, used to resolve the holiday calendar- Returns:
- the maturity date
-
calculateFixingFromMaturity
public LocalDate calculateFixingFromMaturity(LocalDate maturityDate, ReferenceData refData)
Description copied from interface:FxIndex
Calculates the fixing date from the maturity date.The fixing date is the date on which the index is to be observed. The maturity date is the date on which the implied amount is delivered/exchanged. The maturity date is typically two days after the fixing date.
No error is thrown if the input date is not a valid effective date. Instead, the effective date is moved to the next valid effective date and then processed.
The maturity date is also known as the value date.
- Specified by:
calculateFixingFromMaturity
in interfaceFxIndex
- Parameters:
maturityDate
- the maturity daterefData
- the reference data, used to resolve the holiday calendar- Returns:
- the fixing date
-
resolve
public Function<LocalDate,FxIndexObservation> resolve(ReferenceData refData)
Description copied from interface:FxIndex
Resolves this index using the specified reference data, returning a function.This returns a
Function
that converts fixing dates to observations. It binds the holiday calendar, looked up from the reference data, into the result. As such, there is no need to pass the reference data in again.This method is intended for use when looping to create multiple instances of
FxIndexObservation
. Implementations of the method are intended to optimize, avoiding repeated calls to resolve the holiday calendar
-
toString
public String toString()
Returns the name of the index.
-
meta
public static ImmutableFxIndex.Meta meta()
The meta-bean forImmutableFxIndex
.- Returns:
- the meta-bean, not null
-
builder
public static ImmutableFxIndex.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public ImmutableFxIndex.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getName
public String getName()
Gets the index name, such as 'EUR/GBP-ECB'.
-
getCurrencyPair
public CurrencyPair getCurrencyPair()
Gets the currency pair.An index defines an FX rate in a single direction, such as from EUR to USD. This currency pair defines that direction.
In most cases, the same index can be used to convert in both directions by taking the rate or the reciprocal as necessary.
- Specified by:
getCurrencyPair
in interfaceFxIndex
- Returns:
- the value of the property, not null
-
getFixingCalendar
public HolidayCalendarId getFixingCalendar()
Gets the calendar that determines which dates are fixing dates.The fixing date is when the rate is determined.
- Specified by:
getFixingCalendar
in interfaceFxIndex
- Returns:
- the value of the property, not null
-
getFixingDateOffset
public DaysAdjustment getFixingDateOffset()
Gets the adjustment applied to the maturity date to obtain the fixing date.The maturity date is the start date of the indexed deposit. In most cases, the fixing date is 2 days before the maturity date.
- Specified by:
getFixingDateOffset
in interfaceFxIndex
- Returns:
- the value of the property, not null
-
getMaturityDateOffset
public DaysAdjustment getMaturityDateOffset()
Gets the adjustment applied to the fixing date to obtain the maturity date.The maturity date is the start date of the indexed deposit. In most cases, the maturity date is 2 days after the fixing date.
- Specified by:
getMaturityDateOffset
in interfaceFxIndex
- Returns:
- the value of the property, not null
-
toBuilder
public ImmutableFxIndex.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-