Class PnLExplainFormulaProvider

    • Constructor Detail

      • PnLExplainFormulaProvider

        public PnLExplainFormulaProvider​(org.springframework.core.env.Environment environment)
    • Method Detail

      • getCalculationMethod

        protected Object[] getCalculationMethod​(String sensitivityName,
                                                String riskClass)
      • absoluteFunctionPnL

        public com.qfs.func.ITriFunction<Double,​Double,​Double,​Double> absoluteFunctionPnL​(double priceFactor,
                                                                                                            Integer derivativeOrder)
      • relativeFunctionPnL

        public com.qfs.func.ITriFunction<Double,​Double,​Double,​Double> relativeFunctionPnL​(double priceFactor,
                                                                                                            Integer derivativeOrder)
      • dhsFunction

        public com.qfs.func.ITriFunction<Double,​Double,​Double,​Double> dhsFunction​(double priceFactor,
                                                                                                    Integer derivativeOrder,
                                                                                                    double shift)
      • getPnlExplainFormula

        public com.qfs.func.ITriFunction<Double,​Double,​Double,​Double> getPnlExplainFormula​(com.quartetfs.biz.pivot.query.IQueryCache cache,
                                                                                                             String sensitivityName,
                                                                                                             String riskClass)
        Description copied from interface: IPnLExplainFormulaProvider
        Retrieves a function that computes pnl from a market change from T-1 to T
        Specified by:
        getPnlExplainFormula in interface IPnLExplainFormulaProvider
        Parameters:
        cache - cache
        sensitivityName - sensitivity name
        riskClass - risk class
        Returns:
        A function that takes as parameter (double sensi, double quoteTMinus1, double quoteT)
      • getVaRExplainFormula

        public BiFunction<Double,​Double,​Double> getVaRExplainFormula​(com.quartetfs.biz.pivot.query.IQueryCache cache,
                                                                                 String sensitivityName,
                                                                                 String riskClass)
        Description copied from interface: IPnLExplainFormulaProvider
        Retrieves a function that computes pnl from a market change expressed as a shift that may be * Absolute : shift = MtM(T)-MtM(T-1) * Relative : shift = MtM(T)/MtM(T-1) - 1 * DHS : shift = (MtM(T) + c)/(MtM(T-1) + c) - 1
        Specified by:
        getVaRExplainFormula in interface IPnLExplainFormulaProvider
        Parameters:
        cache - cache
        sensitivityName - sensitivity name
        riskClass - risk class
        Returns:
        A function that takes as parameter (double sensi, double shift)
      • getMarketDataInterpolationFlag

        public boolean getMarketDataInterpolationFlag​(String sensitivityName,
                                                      String riskClass)
      • getMarketDataInterpolationFlag

        public Optional<Boolean> getMarketDataInterpolationFlag​(com.quartetfs.biz.pivot.query.IQueryCache cache,
                                                                String sensitivityName,
                                                                String riskClass)
        Description copied from interface: IPnLExplainFormulaProvider
        Retrieves the flag that specifies whether interpolation of the market data is used for the computation of PnL explain
        Specified by:
        getMarketDataInterpolationFlag in interface IPnLExplainFormulaProvider
        Parameters:
        cache - cache
        sensitivityName - the sensitivity name
        riskClass - the risk class
        Returns:
        A boolean flag that is true if interpolation is used and false otherwise
      • getPreMarketDataInterpolationFunction

        public BiFunction<Double,​Double,​Double> getPreMarketDataInterpolationFunction​(com.quartetfs.biz.pivot.query.IQueryCache cache,
                                                                                                  int axisIndex,
                                                                                                  String sensitivityName,
                                                                                                  String riskClass)
        Description copied from interface: IPnLExplainFormulaProvider
        Retrieves a function that performs a calculation on the market data for a given axis before interpolation of market data is done
        Specified by:
        getPreMarketDataInterpolationFunction in interface IPnLExplainFormulaProvider
        Parameters:
        cache - cache
        axisIndex - index of the axis
        sensitivityName - sensitivity name
        riskClass - risk class
        Returns:
        A function that takes as parameter (double market data)
      • getPostMarketDataInterpolationFunction

        public BiFunction<Double,​Double,​Double> getPostMarketDataInterpolationFunction​(com.quartetfs.biz.pivot.query.IQueryCache cache,
                                                                                                   int axisIndex,
                                                                                                   String sensitivityName,
                                                                                                   String riskClass)
        Description copied from interface: IPnLExplainFormulaProvider
        Retrieves a function that performs a calculation on the market data for a given axis after interpolation of market data is done
        Specified by:
        getPostMarketDataInterpolationFunction in interface IPnLExplainFormulaProvider
        Parameters:
        cache - cache
        axisIndex - index of the axis
        sensitivityName - sensitivity name
        riskClass - risk class
        Returns:
        A function that takes as parameter (double market data)
      • computeInterpolatedMarketDataForSingleDimensionalVectorisedSensitivities

        public com.quartetfs.fwk.impl.Pair<Double,​String> computeInterpolatedMarketDataForSingleDimensionalVectorisedSensitivities​(com.qfs.vector.IVector finalQuote,
                                                                                                                                         Map.Entry<Double,​Integer> tenor,
                                                                                                                                         TreeMap<Double,​Integer> inputTenors,
                                                                                                                                         BiFunction<Double,​Double,​Double> preInterpolationCalcTenors,
                                                                                                                                         BiFunction<Double,​Double,​Double> postInterpolationCalcTenors,
                                                                                                                                         boolean enableDebugString)
        Description copied from interface: IPnLExplainFormulaProvider
        Computes the interpolation of market daa in the case of a vectorised 1D-sensitivity
        Specified by:
        computeInterpolatedMarketDataForSingleDimensionalVectorisedSensitivities in interface IPnLExplainFormulaProvider
        Parameters:
        finalQuote - The IVector containing the market data
        tenor - The map of all the tenors
        inputTenors - The map of tenors corresponding to the market data entry
        preInterpolationCalcTenors - The function computed before the interpolation of market data is performed on the tenor axis
        postInterpolationCalcTenors - The function computed after the interpolation of market data is performed on the tenor axis
        enableDebugString - Flag used to enable the generation of a debug string for market data interpolation. If set to 'true', the string is generated, if set to 'false', it is not generated
        Returns:
        A Pair<Double, String> containing the interpolated market data on the left-hand side and the interpolation debug string on the right-hand side
      • computeInterpolatedMarketDataForBiDimensionalVectorisedSensitivities

        public com.quartetfs.fwk.impl.Pair<Double,​String> computeInterpolatedMarketDataForBiDimensionalVectorisedSensitivities​(com.qfs.vector.IVector finalQuote,
                                                                                                                                     Map.Entry<Double,​Integer> tenor,
                                                                                                                                     TreeMap<Double,​Integer> inputTenors,
                                                                                                                                     Map.Entry<Double,​Integer> maturity,
                                                                                                                                     TreeMap<Double,​Integer> inputMaturities,
                                                                                                                                     BiFunction<Double,​Double,​Double> preInterpolationCalcTenors,
                                                                                                                                     BiFunction<Double,​Double,​Double> postInterpolationCalcTenors,
                                                                                                                                     BiFunction<Double,​Double,​Double> preInterpolationCalcMaturities,
                                                                                                                                     BiFunction<Double,​Double,​Double> postInterpolationCalcMaturities,
                                                                                                                                     boolean enableDebugString)
        Description copied from interface: IPnLExplainFormulaProvider
        Computes the interpolation of market daa in the case of a vectorised 2D-sensitivity
        Specified by:
        computeInterpolatedMarketDataForBiDimensionalVectorisedSensitivities in interface IPnLExplainFormulaProvider
        Parameters:
        finalQuote - The IVector containing the market data
        tenor - The map of all the tenors
        inputTenors - The map of tenors corresponding to the market data entry
        maturity - The map of all the maturities
        inputMaturities - The map of maturities corresponding to the market data entry
        preInterpolationCalcTenors - The function computed before the interpolation of market data is performed on the tenor axis
        postInterpolationCalcTenors - The function computed after the interpolation of market data is performed on the tenor axis
        preInterpolationCalcMaturities - The function computed before the interpolation of market data is performed on the maturity axis
        postInterpolationCalcMaturities - The function computed after the interpolation of market data is performed on the maturity axis
        enableDebugString - Flag used to enable the generation of a debug string for market data interpolation. If set to 'true', the string is generated, if set to 'false', it is not generated
        Returns:
        A Pair<Double, String> containing the interpolated market data on the left-hand side and the interpolation debug string on the right-hand side
      • computeInterpolatedMarketDataForTriDimensionalVectorisedSensitivities

        public com.quartetfs.fwk.impl.Pair<Double,​String> computeInterpolatedMarketDataForTriDimensionalVectorisedSensitivities​(com.qfs.vector.IVector finalQuote,
                                                                                                                                      Map.Entry<Double,​Integer> tenor,
                                                                                                                                      TreeMap<Double,​Integer> inputTenors,
                                                                                                                                      Map.Entry<Double,​Integer> maturity,
                                                                                                                                      TreeMap<Double,​Integer> inputMaturities,
                                                                                                                                      Map.Entry<Double,​Integer> moneyness,
                                                                                                                                      TreeMap<Double,​Integer> inputMoneyness,
                                                                                                                                      BiFunction<Double,​Double,​Double> preInterpolationCalcTenors,
                                                                                                                                      BiFunction<Double,​Double,​Double> postInterpolationCalcTenors,
                                                                                                                                      BiFunction<Double,​Double,​Double> preInterpolationCalcMaturities,
                                                                                                                                      BiFunction<Double,​Double,​Double> postInterpolationCalcMaturities,
                                                                                                                                      BiFunction<Double,​Double,​Double> preInterpolationCalcMoneyness,
                                                                                                                                      BiFunction<Double,​Double,​Double> postInterpolationCalcMoneyness,
                                                                                                                                      boolean enableDebugString)
        Description copied from interface: IPnLExplainFormulaProvider
        Computes the interpolation of market daa in the case of a vectorised 3D-sensitivity
        Specified by:
        computeInterpolatedMarketDataForTriDimensionalVectorisedSensitivities in interface IPnLExplainFormulaProvider
        Parameters:
        finalQuote - The IVector containing the market data
        tenor - The map of all the tenors
        inputTenors - The map of tenors corresponding to the market data entry
        maturity - The map of all the maturities
        inputMaturities - The map of maturities corresponding to the market data entry
        moneyness - The map of all the moneyness values
        inputMoneyness - The map of moneyness values corresponding to the market data entry
        preInterpolationCalcTenors - The function computed before the interpolation of market data is performed on the tenor axis
        postInterpolationCalcTenors - The function computed after the interpolation of market data is performed on the tenor axis
        preInterpolationCalcMaturities - The function computed before the interpolation of market data is performed on the maturity axis
        postInterpolationCalcMaturities - The function computed after the interpolation of market data is performed on the maturity axis
        preInterpolationCalcMoneyness - The function computed before the interpolation of market data is performed on the moneyness axis
        postInterpolationCalcMoneyness - The function computed after the interpolation of market data is performed on the moneyness axis
        enableDebugString - Flag used to enable the generation of a debug string for market data interpolation. If set to 'true', the string is generated, if set to 'false', it is not generated
        Returns:
        A Pair<Double, String> containing the interpolated market data on the left-hand side and the interpolation debug string on the right-hand side
      • getMarketDataValueForScalarInterpolation

        public com.quartetfs.fwk.impl.Pair<Double,​String> getMarketDataValueForScalarInterpolation​(MarketPrice marketDataRecord,
                                                                                                         List<String> pos,
                                                                                                         int[] interpolationOrder)
        Description copied from interface: IPnLExplainFormulaProvider
        Retrieves the market data from a MarketPrice record
        Specified by:
        getMarketDataValueForScalarInterpolation in interface IPnLExplainFormulaProvider
        Parameters:
        marketDataRecord - The market price record
        pos - A list representing the position of the market daa to retrieve on each axis
        interpolationOrder - Order in which the interpolation of market data is performed. That order is defined as an int[] in which each index indicates the order in which each of the axis defined in the bucketTypes parameter is processed during the interpolation calculation, starting at the value 0. Ex: if there are three elements defined in bucketTypes like: {BucketType.TENOR_INPUT, BucketType.MATURITY_INPUT, BucketType.MONEYNESS_INPUT} and if the interpolation order is defined as: 0,1,2, the interpolation will first be done on the tenors axis, then on the maturity axis, and then on the moneyness axis.
        Returns:
        A Pair<Double, String> containing the market data (interpolated if interpolation is enabled) on the left-hand side and the interpolation debug string on the right-hand side
      • getEnvironment

        public org.springframework.core.env.Environment getEnvironment()