Class ATailMeasureCalc
- java.lang.Object
-
- com.activeviam.risk.ref.calc.impl.ATailMeasureCalc
-
- All Implemented Interfaces:
ITailMeasureCalc
- Direct Known Subclasses:
TailMeasureCalc
public abstract class ATailMeasureCalc extends Object implements ITailMeasureCalc
Abstract base class forITailMeasureCalc
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).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.activeviam.risk.core.calc.ITailMeasureCalc
ITailMeasureCalc.CalcType
-
-
Constructor Summary
Constructors Constructor Description ATailMeasureCalc()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Integer[]
getESIndices(double rank, IntStream stream)
protected double
getESMetric(double rank, PrimitiveIterator.OfDouble it)
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)
Return an array of the indices in the vector that contribute to the VaR/ES.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.protected abstract double
getRank(int vectorSize, double quantile, String roundingMethod, String quantile2Rank)
The position in the (sorted) PnL vector to use.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.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.protected Integer[]
getVaRIndices(double rank, IntStream stream)
protected double
getVaRMetric(double rank, PrimitiveIterator.OfDouble it)
-
-
-
Field Detail
-
LOGGER
public static final Logger LOGGER
-
-
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 levelquantile2Rank
- quantile method level- Returns:
- The position in the vector.
-
getVaRMetric
protected double getVaRMetric(double rank, PrimitiveIterator.OfDouble it)
-
getESMetric
protected double getESMetric(double rank, PrimitiveIterator.OfDouble it)
-
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
- typepnl
- pnl vectorrank
- 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 interfaceITailMeasureCalc
- 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 levelquantile2Rank
- 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 interfaceITailMeasureCalc
- 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 levelquantile2Rank
- 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 interfaceITailMeasureCalc
- 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 levelquantile2Rank
- String representing the method used to compute the quantile- Returns:
- The VaR L-Estimator value.
-
-