com.opengamma.strata.calc.marketdata

Class ScenarioDefinition

• All Implemented Interfaces:
Bean, ImmutableBean

public final class ScenarioDefinition
extends Object
implements ImmutableBean
A scenario definition defines how to create multiple sets of market data for running calculations over a set of scenarios. The scenario data is created by applying perturbations to a set of base market data. A different set of perturbations is used for each scenario.

Each scenario definition contains market data filters and perturbations. Filters are used to choose items of market data that are shocked in the scenario, and the perturbations define those shocks.

Perturbations are applied in the order they are defined in scenario. An item of market data can only be perturbed once, so if multiple mappings apply to it, only the first will be used.

• Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  ScenarioDefinition.Builder
The bean-builder for ScenarioDefinition.
static class  ScenarioDefinition.Meta
The meta-bean for ScenarioDefinition.
• Method Summary

All Methods
Modifier and Type Method and Description
static ScenarioDefinition.Builder builder()
Returns a builder used to create an instance of the bean.
static ScenarioDefinition empty()
Returns an empty scenario definition.
boolean equals(Object obj)
ImmutableList<PerturbationMapping<?>> getMappings()
Gets the market data filters and perturbations that define the scenarios.
int getScenarioCount()
Returns the number of scenarios.
ImmutableList<String> getScenarioNames()
Gets the names of the scenarios.
int hashCode()
static ScenarioDefinition.Meta meta()
The meta-bean for ScenarioDefinition.
ScenarioDefinition.Meta metaBean()
static ScenarioDefinition ofMappings(List<? extends PerturbationMapping<?>> mapping)
Returns a scenario definition containing the perturbations in mappings.
static ScenarioDefinition ofMappings(List<? extends PerturbationMapping<?>> mappings, List<String> scenarioNames)
Returns a scenario definition containing the perturbations in mappings.
static ScenarioDefinition ofMappings(PerturbationMapping<?>... mappings)
Returns a scenario definition containing the perturbations in mappings.
<R> Property<R> property(String propertyName)
Set<String> propertyNames()
ScenarioDefinition.Builder toBuilder()
Returns a builder that allows this bean to be mutated.
String toString()
• Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait
• Method Detail

• empty

public static ScenarioDefinition empty()
Returns an empty scenario definition.
Returns:
an empty scenario definition
• ofMappings

public static ScenarioDefinition ofMappings(List<? extends PerturbationMapping<?>> mapping)
Returns a scenario definition containing the perturbations in mappings.

Each mapping must contain the same number of perturbations. The definition will contain the same number of scenarios as the number of perturbations in each mapping.

The first scenario contains the first perturbation from each mapping, the second scenario contains the second perturbation from each mapping, and so on.

Given three mappings, A, B and C, each containing two perturbations, 1 and 2, there will be two scenarios generated:

 |            |  A   |  B   |  C   |
|------------|------|------|------|
| Scenario 1 | A[1] | B[1] | C[1] |
| Scenario 2 | A[2] | B[2] | C[2] |

For example, consider the following perturbation mappings:
• Filter: USD Curves, Shocks: [-10bp, 0, +10bp]
• Filter: EUR/USD Rate, Shocks: [+5%, 0, -5%]
The scenario definition would contain the following three scenarios:
 |            | USD Curves | EUR/USD Rate |
|------------|------------|--------------|
| Scenario 1 |     -10bp  |     +5%      |
| Scenario 2 |       0    |      0       |
| Scenario 3 |     +10bp  |     -5%      |

Parameters:
mapping - the filters and perturbations that define the scenario. Each mapping must contain the same number of perturbations
Returns:
a scenario definition containing the perturbations in the mappings
• ofMappings

public static ScenarioDefinition ofMappings(PerturbationMapping<?>... mappings)
Returns a scenario definition containing the perturbations in mappings.

Each mapping must contain the same number of perturbations. The definition will contain the same number of scenarios as the number of perturbations in each mapping.

The first scenario contains the first perturbation from each mapping, the second scenario contains the second perturbation from each mapping, and so on.

Given three mappings, A, B and C, each containing two perturbations, 1 and 2, there will be two scenarios generated:

 |            |  A   |  B   |  C   |
|------------|------|------|------|
| Scenario 1 | A[1] | B[1] | C[1] |
| Scenario 2 | A[2] | B[2] | C[2] |

For example, consider the following perturbation mappings:
• Filter: USD Curves, Shocks: [-10bp, 0, +10bp]
• Filter: EUR/USD Rate, Shocks: [+5%, 0, -5%]
The scenario definition would contain the following three scenarios:
 |            | USD Curves | EUR/USD Rate |
|------------|------------|--------------|
| Scenario 1 |     -10bp  |     +5%      |
| Scenario 2 |       0    |      0       |
| Scenario 3 |     +10bp  |     -5%      |

Parameters:
mappings - the filters and perturbations that define the scenario. Each mapping must contain the same number of perturbations
Returns:
a scenario definition containing the perturbations in the mappings
• ofMappings

public static ScenarioDefinition ofMappings(List<? extends PerturbationMapping<?>> mappings,
List<String> scenarioNames)
Returns a scenario definition containing the perturbations in mappings.

Each mapping must contain the same number of perturbations. The definition will contain the same number of scenarios as the number of perturbations in each mapping.

The first scenario contains the first perturbation from each mapping, the second scenario contains the second perturbation from each mapping, and so on.

The set of scenario names must contain the same number of elements as the mappings.

Given three mappings, A, B and C, each containing two perturbations, 1 and 2, there will be two scenarios generated:

 |            |  A   |  B   |  C   |
|------------|------|------|------|
| Scenario 1 | A[1] | B[1] | C[1] |
| Scenario 2 | A[2] | B[2] | C[2] |

For example, consider the following perturbation mappings:
• Filter: USD Curves, Shocks: [-10bp, 0, +10bp]
• Filter: EUR/USD Rate, Shocks: [+5%, 0, -5%]
The scenario definition would contain the following three scenarios:
 |            | USD Curves | EUR/USD Rate |
|------------|------------|--------------|
| Scenario 1 |     -10bp  |     +5%      |
| Scenario 2 |       0    |      0       |
| Scenario 3 |     +10bp  |     -5%      |

Parameters:
mappings - the filters and perturbations that define the scenario. Each mapping must contain the same number of perturbations
scenarioNames - the names of the scenarios. This must be the same size as the list of perturbations in each mapping and the names must be unique
Returns:
a scenario definition containing the perturbations in the mappings
Throws:
IllegalArgumentException - if there are any duplicate scenario names
• getScenarioCount

public int getScenarioCount()
Returns the number of scenarios.
Returns:
the number of scenarios
• meta

public static ScenarioDefinition.Meta meta()
The meta-bean for ScenarioDefinition.
Returns:
the meta-bean, not null
• builder

public static ScenarioDefinition.Builder builder()
Returns a builder used to create an instance of the bean.
Returns:
the builder, not null
• metaBean

public ScenarioDefinition.Meta metaBean()
Specified by:
metaBean in interface Bean
• property

public <R> Property<R> property(String propertyName)
Specified by:
property in interface Bean
• propertyNames

public Set<String> propertyNames()
Specified by:
propertyNames in interface Bean
• getMappings

public ImmutableList<PerturbationMapping<?>> getMappings()
Gets the market data filters and perturbations that define the scenarios.
Returns:
the value of the property, not null
• getScenarioNames

public ImmutableList<String> getScenarioNames()
Gets the names of the scenarios.
Returns:
the value of the property, not null
• toBuilder

public ScenarioDefinition.Builder toBuilder()
Returns a builder that allows this bean to be mutated.
Returns:
the mutable builder, 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