Class ScenarioDefinition

  • All Implemented Interfaces:
    org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class ScenarioDefinition
    extends Object
    implements org.joda.beans.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.

    • 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
      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object