Class WeightedTailMeasureCalc

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double[] calculateWeights​(int n, double lambda)
      Generates an array of weightings of length equal to the number of scenarios n, based on a Lambda value.
      Integer[] getIndices​(com.quartetfs.biz.pivot.IActivePivot activePivot, com.qfs.store.IDatastoreVersion datastore, IWeightedTailMeasureCalc.CalcType type, com.qfs.vector.IVector pnl, double[] weights, double quantile, boolean isPnlOldestFirst)
      Return an array of the indices in the vector that contribute to the weighted VaR/ES.
      Double getLEstimator​(com.quartetfs.biz.pivot.IActivePivot activePivot, com.qfs.store.IDatastoreVersion datastore, IWeightedTailMeasureCalc.CalcType type, com.qfs.vector.IVector referencePnl, com.qfs.vector.IVector pnl, double[] weights, double quantile, boolean isPnlOldestFirst)
      Calculate the contribution to the VaR, ES, VaE or ETG of the PnL vector for the quantile.
      protected double[][] getSortedWeightedPnLs​(com.qfs.vector.IVector referencePnl, com.qfs.vector.IVector originalPnLs, double[] weights, boolean reverse)  
      Double getWeightedESMetric​(com.qfs.vector.IVector referencePnl, com.qfs.vector.IVector originalPnLs, double[] weights, double quantile, boolean reverse, boolean isPnlOldestFirst)
      Calculate the weighted VaR of the PnL vector for the quantile.
      Integer[] getWeightedESMetricIndices​(com.qfs.vector.IVector originalPnLs, double[] weights, double quantile, boolean reverse, boolean isPnlOldestFirst)
      Calculate indices of the scenarios that contribute to the weighted VaR of the PnL vector for the quantile.
      protected com.quartetfs.fwk.impl.Pair<Double,​Integer[]> getWeightedESMetricWithIndices​(com.qfs.vector.IVector referencePnl, com.qfs.vector.IVector originalPnLs, double[] weights, double quantile, boolean reverse, boolean isPnlOldestFirst)
      Calculate the weighted ES of the PnL vector for the quantile.
      Double getWeightedTailMeasure​(com.quartetfs.biz.pivot.IActivePivot activePivot, com.qfs.store.IDatastoreVersion datastore, IWeightedTailMeasureCalc.CalcType type, com.qfs.vector.IVector pnl, double[] weights, double quantile, boolean isPnlOldestFirst)
      Calculate the ES or VaR of the PnL vector for the quantile.
      Double getWeightedVaRMetric​(com.qfs.vector.IVector referencePnl, com.qfs.vector.IVector originalPnLs, double[] weights, double quantile, boolean reverse, boolean isPnlOldestFirst)
      Calculate the weighted VaR of the PnL vector for the quantile.
      Integer[] getWeightedVaRMetricIndices​(com.qfs.vector.IVector originalPnLs, double[] weights, double quantile, boolean reverse, boolean isPnlOldestFirst)
      Calculate indices of the scenarios that contribute to the weighted VaR of the PnL vector for the quantile.
      com.quartetfs.fwk.impl.Pair<Double,​Integer[]> getWeightedVaRMetricWithIndices​(com.qfs.vector.IVector referencePnl, com.qfs.vector.IVector originalPnLs, double[] weights, double quantile, boolean reverse, boolean isPnlOldestFirst)
      Calculate the weighted VaR of the PnL vector for the quantile and also rfetrun the list of indicies that correspond to the weighted VaR.
    • Constructor Detail

      • WeightedTailMeasureCalc

        public WeightedTailMeasureCalc()
    • Method Detail

      • getWeightedTailMeasure

        public Double getWeightedTailMeasure​(com.quartetfs.biz.pivot.IActivePivot activePivot,
                                             com.qfs.store.IDatastoreVersion datastore,
                                             IWeightedTailMeasureCalc.CalcType type,
                                             com.qfs.vector.IVector pnl,
                                             double[] weights,
                                             double quantile,
                                             boolean isPnlOldestFirst)
        Calculate the ES or VaR of the PnL vector for the quantile.
        Specified by:
        getWeightedTailMeasure in interface IWeightedTailMeasureCalc
        Parameters:
        activePivot - activePivot
        datastore - datastore
        pnl - The PnL vector.
        weights - weights
        quantile - The quantile for the ES or VaR, between 0 and 1 (equals 1 minus the confidence level).
        isPnlOldestFirst - Whether the first entry in the PnL vector corresponds to the oldest scenario or the newest.
        type - "ES", "VaR", "VaE" or "ETG"
        Returns:
        The tail measure (i.e. VaR or ES value of the vector for the quantile).
      • calculateWeights

        public double[] calculateWeights​(int n,
                                         double lambda)
        Generates an array of weightings of length equal to the number of scenarios n, based on a Lambda value.
        Specified by:
        calculateWeights in interface IWeightedTailMeasureCalc
        Parameters:
        n - number
        lambda - lambda
        Returns:
        array of weightings.
      • getWeightedVaRMetric

        public Double getWeightedVaRMetric​(com.qfs.vector.IVector referencePnl,
                                           com.qfs.vector.IVector originalPnLs,
                                           double[] weights,
                                           double quantile,
                                           boolean reverse,
                                           boolean isPnlOldestFirst)
        Calculate the weighted VaR of the PnL vector for the quantile.
        Parameters:
        referencePnl - The reference PnL vector used for the scenario sorting
        originalPnLs - The PnL vector used for the VaR
        weights - weights
        quantile - The quantile for the VaR, between 0 and 1 (equals 1 minus the confidence level).
        reverse - false for negative tail measures, true for positive tail measures
        isPnlOldestFirst - flag to indicate if the PnL values in the PnL vector are present from with the oldest value at index 0 or the most recent value at index 0. The flag is set to 'true' if the oldest PnL value is present at index 0 and to 'false' if the most recent PnL value is present at index 0.
        Returns:
        The weighted VaR measure
      • getWeightedVaRMetricIndices

        public Integer[] getWeightedVaRMetricIndices​(com.qfs.vector.IVector originalPnLs,
                                                     double[] weights,
                                                     double quantile,
                                                     boolean reverse,
                                                     boolean isPnlOldestFirst)
        Calculate indices of the scenarios that contribute to the weighted VaR of the PnL vector for the quantile.
        Parameters:
        originalPnLs - The PnL vector.
        weights - weights
        quantile - The quantile for the VaR, between 0 and 1 (equals 1 minus the confidence level).
        reverse - false for negative tail measures, true for positive tail measures
        isPnlOldestFirst - flag to indicate if the PnL values in the PnL vector are present from with the oldest value at index 0 or the most recent value at index 0. The flag is set to 'true' if the oldest PnL value is present at index 0 and to 'false' if the most recent PnL value is present at index 0.
        Returns:
        The indices that contribute to the weighted VaR
      • getWeightedESMetric

        public Double getWeightedESMetric​(com.qfs.vector.IVector referencePnl,
                                          com.qfs.vector.IVector originalPnLs,
                                          double[] weights,
                                          double quantile,
                                          boolean reverse,
                                          boolean isPnlOldestFirst)
        Calculate the weighted VaR of the PnL vector for the quantile.
        Parameters:
        referencePnl - The PnL reference vector used for the scenario sorting
        originalPnLs - The PnL vector for the metric computation
        weights - weights
        quantile - The quantile for the VaR, between 0 and 1 (equals 1 minus the confidence level).
        reverse - false for negative tail measures, true for positive tail measures
        isPnlOldestFirst - flag to indicate if the PnL values in the PnL vector are present from with the oldest value at index 0 or the most recent value at index 0. The flag is set to 'true' if the oldest PnL value is present at index 0 and to 'false' if the most recent PnL value is present at index 0.
        Returns:
        The weighted VaR measure
      • getWeightedESMetricIndices

        public Integer[] getWeightedESMetricIndices​(com.qfs.vector.IVector originalPnLs,
                                                    double[] weights,
                                                    double quantile,
                                                    boolean reverse,
                                                    boolean isPnlOldestFirst)
        Calculate indices of the scenarios that contribute to the weighted VaR of the PnL vector for the quantile.
        Parameters:
        originalPnLs - The PnL vector.
        weights - weights
        quantile - The quantile for the VaR, between 0 and 1 (equals 1 minus the confidence level).
        reverse - false for negative tail measures, true for positive tail measures
        isPnlOldestFirst - flag to indicate if the PnL values in the PnL vector are present from with the oldest value at index 0 or the most recent value at index 0. The flag is set to 'true' if the oldest PnL value is present at index 0 and to 'false' if the most recent PnL value is present at index 0.
        Returns:
        The indices that contribute to the weighted VaR
      • getWeightedESMetricWithIndices

        protected com.quartetfs.fwk.impl.Pair<Double,​Integer[]> getWeightedESMetricWithIndices​(com.qfs.vector.IVector referencePnl,
                                                                                                     com.qfs.vector.IVector originalPnLs,
                                                                                                     double[] weights,
                                                                                                     double quantile,
                                                                                                     boolean reverse,
                                                                                                     boolean isPnlOldestFirst)
        Calculate the weighted ES of the PnL vector for the quantile.
        Parameters:
        referencePnl - The PnL reference vector used for the scenario sorting
        originalPnLs - The PnL vector for the metric computation
        weights - weight
        quantile - The quantile for the ES, between 0 and 1 (equals 1 minus the confidence level)
        reverse - false for negative tail measures, true for positive tail measures
        isPnlOldestFirst - flag to indicate if the PnL values in the PnL vector are present from with the oldest value at index 0 or the most recent value at index 0. The flag is set to 'true' if the oldest PnL value is present at index 0 and to 'false' if the most recent PnL value is present at index 0.
        Returns:
        The weighted ES measure and the list of indices that correspond to the scenarios used for the computation of the weighted ES
      • getSortedWeightedPnLs

        protected double[][] getSortedWeightedPnLs​(com.qfs.vector.IVector referencePnl,
                                                   com.qfs.vector.IVector originalPnLs,
                                                   double[] weights,
                                                   boolean reverse)
      • getWeightedVaRMetricWithIndices

        public com.quartetfs.fwk.impl.Pair<Double,​Integer[]> getWeightedVaRMetricWithIndices​(com.qfs.vector.IVector referencePnl,
                                                                                                   com.qfs.vector.IVector originalPnLs,
                                                                                                   double[] weights,
                                                                                                   double quantile,
                                                                                                   boolean reverse,
                                                                                                   boolean isPnlOldestFirst)
        Calculate the weighted VaR of the PnL vector for the quantile and also rfetrun the list of indicies that correspond to the weighted VaR.
        Parameters:
        referencePnl - The PnL vector used for the scenario sorting
        originalPnLs - The PnL vector used for the metric computation
        weights - weights
        quantile - The quantile for the VaR, between 0 and 1 (equals 1 minus the confidence level).
        reverse - false for negative tail measures, true for positive tail measures
        isPnlOldestFirst - flag to indicate if the PnL values in the PnL vector are present from with the oldest value at index 0 or the most recent value at index 0. The flag is set to 'true' if the oldest PnL value is present at index 0 and to 'false' if the most recent PnL value is present at index 0.
        Returns:
        The weighted VaR measure and the list of indicies that correspond to the scenarios used for the computation of the weighted VaR
      • getIndices

        public Integer[] getIndices​(com.quartetfs.biz.pivot.IActivePivot activePivot,
                                    com.qfs.store.IDatastoreVersion datastore,
                                    IWeightedTailMeasureCalc.CalcType type,
                                    com.qfs.vector.IVector pnl,
                                    double[] weights,
                                    double quantile,
                                    boolean isPnlOldestFirst)
        Description copied from interface: IWeightedTailMeasureCalc
        Return an array of the indices in the vector that contribute to the weighted VaR/ES.
        Specified by:
        getIndices in interface IWeightedTailMeasureCalc
        Parameters:
        activePivot - Active Pivot instance.
        datastore - Datastore version.
        type - "ES", "VaR", "VaE" or "ETG"
        pnl - The PnL vector.
        weights - the weights
        quantile - The quantile for the VaR, between 0 and 1 (equals 1 minus the confidence level).
        isPnlOldestFirst - flag to indicate if the PnL values in the PnL vector are present from with the oldest value at index 0 or the most recent value at index 0. The flag is set to 'true' if the oldest PnL value is present at index 0 and to 'false' if the most recent PnL value is present at index 0.
        Returns:
        The array of vector indices.
      • getLEstimator

        public Double getLEstimator​(com.quartetfs.biz.pivot.IActivePivot activePivot,
                                    com.qfs.store.IDatastoreVersion datastore,
                                    IWeightedTailMeasureCalc.CalcType type,
                                    com.qfs.vector.IVector referencePnl,
                                    com.qfs.vector.IVector pnl,
                                    double[] weights,
                                    double quantile,
                                    boolean isPnlOldestFirst)
        Description copied from interface: IWeightedTailMeasureCalc
        Calculate the contribution to the VaR, ES, VaE or ETG of the PnL vector for the quantile.
        Specified by:
        getLEstimator in interface IWeightedTailMeasureCalc
        Parameters:
        activePivot - Active Pivot instance.
        datastore - Datastore version.
        type - "ES", "VaR", "VaE" or "ETG"
        referencePnl - The aggregate PnL vector at the reference level.
        pnl - The PnL vector for the current sub-portfolio.
        weights - The weights
        quantile - The quantile for the ES, VaR or VaE between 0 and 1 (equals 1 minus the confidence level).
        isPnlOldestFirst - flag to indicate if the PnL values in the PnL vector are present from with the oldest value at index 0 or the most recent value at index 0. The flag is set to 'true' if the oldest PnL value is present at index 0 and to 'false' if the most recent PnL value is present at index 0.
        Returns:
        The tail measure (i.e. VaR, ES or VaE value of the vector for the quantile).