Class ImmutableScenarioMarketData
- java.lang.Object
-
- com.opengamma.strata.data.scenario.ImmutableScenarioMarketData
-
- All Implemented Interfaces:
ScenarioMarketData
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class ImmutableScenarioMarketData extends Object implements ScenarioMarketData, org.joda.beans.ImmutableBean, Serializable
An immutable set of market data across one or more scenarios.This is the standard immutable implementation of
ScenarioMarketData
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImmutableScenarioMarketData.Meta
The meta-bean forImmutableScenarioMarketData
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutableScenarioMarketDataBuilder
builder(MarketDataBox<LocalDate> valuationDate)
Creates a mutable builder that can be used to create an instance of the market data.static ImmutableScenarioMarketDataBuilder
builder(LocalDate valuationDate)
Creates a mutable builder that can be used to create an instance of the market data.ImmutableScenarioMarketData
combinedWith(ImmutableScenarioMarketData other)
Returns set of market data which combines the data from this set of data with another set.ScenarioMarketData
combinedWith(ScenarioMarketData other)
Returns set of market data which combines the data from this set of data with another set.boolean
containsValue(MarketDataId<?> id)
Checks if this market data contains a value for the specified identifier.static ImmutableScenarioMarketData
empty()
Obtains a market data instance that contains no data and has no scenarios.boolean
equals(Object obj)
<T> Set<MarketDataId<T>>
findIds(MarketDataName<T> name)
Finds the market data identifiers associated with the specified name.<T> Optional<MarketDataBox<T>>
findValue(MarketDataId<T> id)
Finds the market data value associated with the specified identifier.Set<MarketDataId<?>>
getIds()
Gets the market data identifiers.int
getScenarioCount()
Gets the number of scenarios.ImmutableMap<ObservableId,LocalDateDoubleTimeSeries>
getTimeSeries()
Gets the time-series of market data values.LocalDateDoubleTimeSeries
getTimeSeries(ObservableId id)
Gets the time-series associated with the specified identifier, empty if not found.Set<ObservableId>
getTimeSeriesIds()
Gets the time-series identifiers.MarketDataBox<LocalDate>
getValuationDate()
Gets the valuation date associated with each scenario.<T> MarketDataBox<T>
getValue(MarketDataId<T> id)
Gets the market data value associated with the specified identifier.ImmutableMap<MarketDataId<?>,MarketDataBox<?>>
getValues()
Gets the individual items of market data.int
hashCode()
static ImmutableScenarioMarketData.Meta
meta()
The meta-bean forImmutableScenarioMarketData
.ImmutableScenarioMarketData.Meta
metaBean()
static ImmutableScenarioMarketData
of(int scenarioCount, MarketDataBox<LocalDate> valuationDate, Map<? extends MarketDataId<?>,MarketDataBox<?>> values, Map<? extends ObservableId,LocalDateDoubleTimeSeries> timeSeries)
Obtains an instance from a valuation date, map of values and time-series.static ImmutableScenarioMarketData
of(int scenarioCount, LocalDate valuationDate, Map<? extends MarketDataId<?>,MarketDataBox<?>> values, Map<? extends ObservableId,LocalDateDoubleTimeSeries> timeSeries)
Obtains an instance from a valuation date, map of values and time-series.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.data.scenario.ScenarioMarketData
getScenarioValue, scenario, scenarios, withPerturbation, withValue
-
-
-
-
Method Detail
-
of
public static ImmutableScenarioMarketData of(int scenarioCount, LocalDate valuationDate, Map<? extends MarketDataId<?>,MarketDataBox<?>> values, Map<? extends ObservableId,LocalDateDoubleTimeSeries> timeSeries)
Obtains an instance from a valuation date, map of values and time-series.The valuation date and map of values must have the same number of scenarios.
- Parameters:
scenarioCount
- the number of scenariosvaluationDate
- the valuation dates associated with all scenariosvalues
- the market data values, one for each scenariotimeSeries
- the time-series- Returns:
- a set of market data containing the values in the map
-
of
public static ImmutableScenarioMarketData of(int scenarioCount, MarketDataBox<LocalDate> valuationDate, Map<? extends MarketDataId<?>,MarketDataBox<?>> values, Map<? extends ObservableId,LocalDateDoubleTimeSeries> timeSeries)
Obtains an instance from a valuation date, map of values and time-series.The valuation date and map of values must have the same number of scenarios.
- Parameters:
scenarioCount
- the number of scenariosvaluationDate
- the valuation dates associated with the market data, one for each scenariovalues
- the market data values, one for each scenariotimeSeries
- the time-series- Returns:
- a set of market data containing the values in the map
-
empty
public static ImmutableScenarioMarketData empty()
Obtains a market data instance that contains no data and has no scenarios.- Returns:
- an empty instance
-
builder
public static ImmutableScenarioMarketDataBuilder builder(LocalDate valuationDate)
Creates a mutable builder that can be used to create an instance of the market data.- Parameters:
valuationDate
- the valuation date associated with the market data- Returns:
- the mutable builder
-
builder
public static ImmutableScenarioMarketDataBuilder builder(MarketDataBox<LocalDate> valuationDate)
Creates a mutable builder that can be used to create an instance of the market data.- Parameters:
valuationDate
- the valuation dates associated with the market data, one for each scenario- Returns:
- the mutable builder
-
containsValue
public boolean containsValue(MarketDataId<?> id)
Description copied from interface:ScenarioMarketData
Checks if this market data contains a value for the specified identifier.- Specified by:
containsValue
in interfaceScenarioMarketData
- Parameters:
id
- the identifier to find- Returns:
- true if the market data contains a value for the identifier
-
getValue
public <T> MarketDataBox<T> getValue(MarketDataId<T> id)
Description copied from interface:ScenarioMarketData
Gets the market data value associated with the specified identifier.The result is a box that provides data for all scenarios. If this market data instance contains the identifier, the value will be returned. Otherwise, an exception will be thrown.
- Specified by:
getValue
in interfaceScenarioMarketData
- Type Parameters:
T
- the type of the market data value- Parameters:
id
- the identifier to find- Returns:
- the market data value box providing data for all scenarios
-
findValue
public <T> Optional<MarketDataBox<T>> findValue(MarketDataId<T> id)
Description copied from interface:ScenarioMarketData
Finds the market data value associated with the specified identifier.The result is a box that provides data for all scenarios. If this market data instance contains the identifier, the value will be returned. Otherwise, an empty optional will be returned.
- Specified by:
findValue
in interfaceScenarioMarketData
- Type Parameters:
T
- the type of the market data value- Parameters:
id
- the identifier to find- Returns:
- the market data value box providing data for all scenarios, empty if not found
-
getIds
public Set<MarketDataId<?>> getIds()
Description copied from interface:ScenarioMarketData
Gets the market data identifiers.- Specified by:
getIds
in interfaceScenarioMarketData
- Returns:
- the set of market data identifiers
-
findIds
public <T> Set<MarketDataId<T>> findIds(MarketDataName<T> name)
Description copied from interface:ScenarioMarketData
Finds the market data identifiers associated with the specified name.This returns the unique identifiers that refer to the specified name. There may be more than one identifier associated with a name as the name is not unique.
- Specified by:
findIds
in interfaceScenarioMarketData
- Type Parameters:
T
- the type of the market data value- Parameters:
name
- the name to find- Returns:
- the set of market data identifiers, empty if name not found
-
getTimeSeriesIds
public Set<ObservableId> getTimeSeriesIds()
Description copied from interface:ScenarioMarketData
Gets the time-series identifiers.Time series are not affected by scenarios, therefore there is a single time-series for each identifier which is shared between all scenarios.
- Specified by:
getTimeSeriesIds
in interfaceScenarioMarketData
- Returns:
- the set of observable identifiers
-
getTimeSeries
public LocalDateDoubleTimeSeries getTimeSeries(ObservableId id)
Description copied from interface:ScenarioMarketData
Gets the time-series associated with the specified identifier, empty if not found.Time series are not affected by scenarios, therefore there is a single time-series for each identifier which is shared between all scenarios.
- Specified by:
getTimeSeries
in interfaceScenarioMarketData
- Parameters:
id
- the identifier to find- Returns:
- the time-series, empty if no time-series found
-
combinedWith
public ImmutableScenarioMarketData combinedWith(ImmutableScenarioMarketData other)
Returns set of market data which combines the data from this set of data with another set.If the same item of data is available in both sets, it will be taken from this set.
Both sets of data must contain the same number of scenarios, or one of them must have one scenario. If one of the sets of data has one scenario, the combined set will have the scenario count of the other set.
The valuation dates are taken from this set of data.
- Parameters:
other
- another set of market data- Returns:
- a set of market data combining the data in this set with the data in the other
-
combinedWith
public ScenarioMarketData combinedWith(ScenarioMarketData other)
Description copied from interface:ScenarioMarketData
Returns set of market data which combines the data from this set of data with another set.If the same item of data is available in both sets, it will be taken from this set.
Both sets of data must contain the same number of scenarios, or one of them must have one scenario. If one of the sets of data has one scenario, the combined set will have the scenario count of the other set.
- Specified by:
combinedWith
in interfaceScenarioMarketData
- Parameters:
other
- another set of market data- Returns:
- a set of market data combining the data in this set with the data in the other
-
meta
public static ImmutableScenarioMarketData.Meta meta()
The meta-bean forImmutableScenarioMarketData
.- Returns:
- the meta-bean, not null
-
metaBean
public ImmutableScenarioMarketData.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getScenarioCount
public int getScenarioCount()
Gets the number of scenarios.- Specified by:
getScenarioCount
in interfaceScenarioMarketData
- Returns:
- the value of the property
-
getValuationDate
public MarketDataBox<LocalDate> getValuationDate()
Gets the valuation date associated with each scenario.- Specified by:
getValuationDate
in interfaceScenarioMarketData
- Returns:
- the value of the property, not null
-
getValues
public ImmutableMap<MarketDataId<?>,MarketDataBox<?>> getValues()
Gets the individual items of market data.- Returns:
- the value of the property, not null
-
getTimeSeries
public ImmutableMap<ObservableId,LocalDateDoubleTimeSeries> getTimeSeries()
Gets the time-series of market data values.If a request is made for a time-series that is not in the map, an empty series will be returned.
- Returns:
- the value of the property, not null
-
-