Class GenericDoubleShifts

  • All Implemented Interfaces:
    ScenarioPerturbation<java.lang.Double>, java.io.Serializable, Bean, ImmutableBean

    public final class GenericDoubleShifts
    extends java.lang.Object
    implements ScenarioPerturbation<java.lang.Double>, ImmutableBean, java.io.Serializable
    A perturbation that applies different shifts to a double value.

    This class contains shifts, each of which is associated with a scenario and applied to a value based on the shift type. A constant spread can be added for all of the scenarios.

    A typical application of this is to generate scenario perturbation to market quotes, where the market quote is represented in terms of QuoteId and Double.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static GenericDoubleShifts of​(ShiftType shiftType,
                                             DoubleArray shiftAmount)
        Creates an instance with zero spread.
        Parameters:
        shiftType - the shift type
        shiftAmount - the shift amount
        Returns:
        the instance
      • of

        public static GenericDoubleShifts of​(ShiftType shiftType,
                                             DoubleArray shiftAmount,
                                             double spread)
        Creates an instance with spread.
        Parameters:
        shiftType - the shift type
        shiftAmount - the shift amount
        spread - the spread
        Returns:
        the instance
      • applyTo

        public MarketDataBox<java.lang.Double> applyTo​(MarketDataBox<java.lang.Double> marketData,
                                                       ReferenceData refData)
        Description copied from interface: ScenarioPerturbation
        Applies this perturbation to the market data in a box, returning a box containing new, modified data.

        The original market data must not be altered. Instead a perturbed copy must be returned.

        Specified by:
        applyTo in interface ScenarioPerturbation<java.lang.Double>
        Parameters:
        marketData - the market data to perturb
        refData - the reference data
        Returns:
        new market data derived by applying the perturbation to the input data
      • getScenarioCount

        public int getScenarioCount()
        Description copied from interface: ScenarioPerturbation
        Returns the number of scenarios for which this perturbation generates data.
        Specified by:
        getScenarioCount in interface ScenarioPerturbation<java.lang.Double>
        Returns:
        the number of scenarios for which this perturbation generates data
      • getMarketDataType

        public java.lang.Class<java.lang.Double> getMarketDataType()
        Description copied from interface: ScenarioPerturbation
        Returns the market data type that the perturbation changes.
        Specified by:
        getMarketDataType in interface ScenarioPerturbation<java.lang.Double>
        Returns:
        the data type
      • meta

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

        public ShiftType getShiftType()
        Gets the type of shift applied to a Double value.
        Returns:
        the value of the property, not null
      • getShiftAmount

        public DoubleArray getShiftAmount()
        Gets the shifts to apply to a Double value.

        Each element in the array corresponds to each scenario.

        Returns:
        the value of the property, not null
      • getSpread

        public double getSpread()
        Gets the constant spread.
        Returns:
        the value of the property, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object