Class LadderUtils


  • public class LadderUtils
    extends Object
    Helper methods used for sensitivity ladder calculations.
    • Constructor Summary

      Constructors 
      Constructor Description
      LadderUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static Double calculateFromSensi​(double percentageShift, com.qfs.vector.IVector sensiLadder, double[] shifts, int index, int direction, boolean secondOrder)
      Recursively calculates the value based on the sensitivity ladder.
      protected static Double calculateInputFromLadder​(com.qfs.vector.IVector sensiLadder, double percentageShift, double[] ladderScale, boolean secondOrder)
      Calculates a PnL value for a given ladder and market data shift.
      protected static Double determineAbsoluteShift​(Double absoluteShift, Double quoteT, Double quoteTMinus1)
      Calculates the absolute shift from the provided market data quotes, if the absolute shift is not provided.
      static Double determineInput​(IInputSelector inputSelector, com.qfs.vector.IVector sensi, com.qfs.vector.IVector sensiLadder, com.quartetfs.fwk.IPair<Boolean,​double[]> ladderScale, Double providedShift, com.qfs.vector.IVector quoteT, com.qfs.vector.IVector quoteTMinus1, int index, String sensitivityName)
      Determines the sensitivity input for a potential ladder calculation, depending on a configuration variable and calculation parameters.
      protected static Double determinePercentageShift​(Double percentageShift, Double quoteT, Double quoteTMinus1)
      Calculates the percentage shift from the provided market data quotes, if the percentage shift is not provided.
      static com.qfs.vector.IVector inputBasedExpansion​(boolean ladderInput, com.qfs.vector.IVector inputVector, double[] ladderScale, int index)
      Selects a subvector according to the input and the parameters.
      static boolean ladderExists​(com.quartetfs.biz.pivot.ILocation location, com.quartetfs.biz.pivot.cube.hierarchy.ILevelInfo ladderAvailabilityLevelInfo)
      Determines if a ladder exists, based on the member on the ladder availability level.
    • Constructor Detail

      • LadderUtils

        public LadderUtils()
    • Method Detail

      • determineInput

        public static Double determineInput​(IInputSelector inputSelector,
                                            com.qfs.vector.IVector sensi,
                                            com.qfs.vector.IVector sensiLadder,
                                            com.quartetfs.fwk.IPair<Boolean,​double[]> ladderScale,
                                            Double providedShift,
                                            com.qfs.vector.IVector quoteT,
                                            com.qfs.vector.IVector quoteTMinus1,
                                            int index,
                                            String sensitivityName)
        Determines the sensitivity input for a potential ladder calculation, depending on a configuration variable and calculation parameters.
        Parameters:
        inputSelector - The input selector of the configuration.
        sensi - The sensitivity vector.
        sensiLadder - The sensitivity ladder vector.
        ladderScale - The sensitivity ladder scale and type.
        providedShift - The market data shift.
        quoteT - The current day market data quote.
        quoteTMinus1 - The previous day market data quote.
        index - The index of the price to be retrieved from the quote vectors.
        sensitivityName - The sensitivityName.
        Returns:
        The sensitivity, or the result of the sensitivity ladder calculation.
      • inputBasedExpansion

        public static com.qfs.vector.IVector inputBasedExpansion​(boolean ladderInput,
                                                                 com.qfs.vector.IVector inputVector,
                                                                 double[] ladderScale,
                                                                 int index)
        Selects a subvector according to the input and the parameters.
        Parameters:
        ladderInput - Whether the input is a sensitivity ladder or not.
        inputVector - The input vector.
        ladderScale - The scale of the ladder.
        index - The pillar index to retrieve.
        Returns:
        The subvector corresponding to the pillar index.
      • determineAbsoluteShift

        protected static Double determineAbsoluteShift​(Double absoluteShift,
                                                       Double quoteT,
                                                       Double quoteTMinus1)
        Calculates the absolute shift from the provided market data quotes, if the absolute shift is not provided.
        Parameters:
        absoluteShift - The absolute shift.
        quoteT - The current day market data quote.
        quoteTMinus1 - The previous day market data quote.
        Returns:
        The absolute shift.
      • determinePercentageShift

        protected static Double determinePercentageShift​(Double percentageShift,
                                                         Double quoteT,
                                                         Double quoteTMinus1)
        Calculates the percentage shift from the provided market data quotes, if the percentage shift is not provided. If the previous day market data quote is 0.0, the result will be NaN, except when the current day quote is also 0.0 (the result will be 0.0).
        Parameters:
        percentageShift - The percentage shift.
        quoteT - The current day market data quote.
        quoteTMinus1 - The previous day market data quote.
        Returns:
        The percentage shift.
      • calculateInputFromLadder

        protected static Double calculateInputFromLadder​(com.qfs.vector.IVector sensiLadder,
                                                         double percentageShift,
                                                         double[] ladderScale,
                                                         boolean secondOrder)
        Calculates a PnL value for a given ladder and market data shift.
        Parameters:
        sensiLadder - The sensitivity ladder.
        percentageShift - The market data shift, as a percentage.
        ladderScale - The scale of the input ladder.
        secondOrder - If the sensitivity ladder is second order.
        Returns:
        The result of the calculation.
      • calculateFromSensi

        protected static Double calculateFromSensi​(double percentageShift,
                                                   com.qfs.vector.IVector sensiLadder,
                                                   double[] shifts,
                                                   int index,
                                                   int direction,
                                                   boolean secondOrder)
        Recursively calculates the value based on the sensitivity ladder. Direction determines whether iteration is positive (for positive shifts) or negative (for negative shifts)
        Parameters:
        percentageShift - The percentage shift for which the calculation is performed.
        sensiLadder - The sensitivity ladder.
        shifts - The sensitivity ladder scale.
        index - The index in the ladder.
        direction - -1 for negative shifts, +1 for positive shifts. Result will be null if other values are used.
        secondOrder - If the sensitivity ladder is second order.
        Returns:
        The cumulative result of the recursion.
      • ladderExists

        public static boolean ladderExists​(com.quartetfs.biz.pivot.ILocation location,
                                           com.quartetfs.biz.pivot.cube.hierarchy.ILevelInfo ladderAvailabilityLevelInfo)
        Determines if a ladder exists, based on the member on the ladder availability level.
        Parameters:
        location - The location in the cube.
        ladderAvailabilityLevelInfo - The ladder availability level info.
        Returns:
        Whether the ladder exists or not.