Class ATailMeasureCalc

  • All Implemented Interfaces:
    ITailMeasureCalc
    Direct Known Subclasses:
    TailMeasureCalc

    public abstract class ATailMeasureCalc
    extends Object
    implements ITailMeasureCalc
    Abstract base class for ITailMeasureCalc where:
    • The VaR measure is the element in the sorted vector at position (with interpolation)
    • The ES measure is average in the sorted vector of the first elements (with partial weighting in the last element).
    • Field Detail

      • LOGGER

        public static final Logger LOGGER
    • Constructor Detail

      • ATailMeasureCalc

        public ATailMeasureCalc()
    • Method Detail

      • getRank

        protected abstract double getRank​(int vectorSize,
                                          double quantile,
                                          String roundingMethod,
                                          String quantile2Rank)
        The position in the (sorted) PnL vector to use. If the returned value is not an integer, the two values either side are interpolated.
        Parameters:
        vectorSize - The size of the PnL vector.
        quantile - the quantile, between 0 and 1 (equals 1 minus the confidence level).
        roundingMethod - rounding method level
        quantile2Rank - quantile method level
        Returns:
        The position in the vector.
      • getVaRIndices

        protected Integer[] getVaRIndices​(double rank,
                                          IntStream stream)
      • getESIndices

        protected Integer[] getESIndices​(double rank,
                                         IntStream stream)
      • getStreamOfIndices

        protected IntStream getStreamOfIndices​(ITailMeasureCalc.CalcType type,
                                               com.qfs.vector.IVector pnl,
                                               double rank)
        The stream is not in the same order depending if the top or the bottom is requested, always ascending, but wwe want from cutoff to tail.
        Parameters:
        type - type
        pnl - pnl vector
        rank - rank
        Returns:
        stream
      • getTailMeasure

        public Double getTailMeasure​(com.quartetfs.biz.pivot.IActivePivot activePivot,
                                     com.qfs.store.IDatastoreVersion datastore,
                                     ITailMeasureCalc.CalcType type,
                                     com.qfs.vector.IVector pnl,
                                     double quantile,
                                     String roundingMethod,
                                     String quantile2Rank)
        Calculate the ES or VaR of the PnL vector for the quantile.
        Specified by:
        getTailMeasure in interface ITailMeasureCalc
        Parameters:
        pnl - The PnL vector.
        quantile - The quantile for the ES or VaR, between 0 and 1 (equals 1 minus the confidence level).
        activePivot - Active Pivot instance.
        datastore - Datastore version.
        type - "ES", "VaR" or "VaE"
        roundingMethod - String representing the rounding for the computation of the index(es) corresponding to the confidence level
        quantile2Rank - String representing the method used to compute the quantile
        Returns:
        The tail measure (i.e. VaR or ES value of the vector for the quantile).
      • getIndices

        public Integer[] getIndices​(com.quartetfs.biz.pivot.IActivePivot activePivot,
                                    com.qfs.store.IDatastoreVersion datastore,
                                    ITailMeasureCalc.CalcType type,
                                    com.qfs.vector.IVector pnl,
                                    double quantile,
                                    String roundingMethod,
                                    String quantile2Rank)
        Description copied from interface: ITailMeasureCalc
        Return an array of the indices in the vector that contribute to the VaR/ES.
        Specified by:
        getIndices in interface ITailMeasureCalc
        Parameters:
        activePivot - Active Pivot instance.
        datastore - Datastore version.
        type - "ES" or "VaR".
        pnl - The PnL vector.
        quantile - The quantile for the VaR, between 0 and 1 (equals 1 minus the confidence level).
        roundingMethod - String representing the rounding for the computation of the index(es) corresponding to the confidence level
        quantile2Rank - String representing the method used to compute the quantile
        Returns:
        The array of vector indices.
      • getLEstimator

        public Double getLEstimator​(com.quartetfs.biz.pivot.IActivePivot activePivot,
                                    com.qfs.store.IDatastoreVersion datastore,
                                    ITailMeasureCalc.CalcType type,
                                    com.qfs.vector.IVector referencePnl,
                                    com.qfs.vector.IVector pnl,
                                    double quantile,
                                    String roundingMethod,
                                    String quantile2Rank)
        Calculate the VaR or ES L-Estimator of the PnL vector for the quantile, given the reference PnL vector.
        Specified by:
        getLEstimator in interface ITailMeasureCalc
        Parameters:
        referencePnl - The aggregate PnL vector at the reference level.
        pnl - The PnL vector for the current sub-portfolio.
        quantile - The quantile for the ES or VaR, between 0 and 1 (equals 1 minus the confidence level).
        activePivot - Active Pivot instance.
        datastore - Datastore version.
        type - "ES" or "VaR".
        roundingMethod - String representing the rounding for the computation of the index(es) corresponding to the confidence level
        quantile2Rank - String representing the method used to compute the quantile
        Returns:
        The VaR L-Estimator value.