Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Risk Class Sensitivity Aggregate #1 (1, 2)
	- Risk Class Sensitivity Aggregate #2 (3, 4)
	- Risk Class Sensitivity Aggregate #3 (5, 6)
	- Risk Class Sensitivity Aggregate #4 (7, 8)
	- Risk Class Sensitivity Aggregate #5 (9, 10)
	- Bucket Aggregate Bounded Weighted Sensitivity (11, 12)
	- Risk Class Sensitivity Aggregate #6 (13, 14)
	- Risk Class Sensitivity Aggregate #7 (15, 16)
	- SIMM 2.0 Risk Factor Aggregate Margin (25)
	- Equity Delta Vega Threshold Map (26, 27)
	- Equity Bucket Risk Weight Correlation (28, 29)
	- Equity Risk Cross Bucket Correlation (30)
	- Residual Equity Bucket Settings Entry (31)
	- ISDA Bucket Sensitivity Settings Map (32, 33)
	- Equity Bucket Delta Risk Weight (34, 35)


Bug Fixes/Clean-up:

Samples:

	- FX Delta Margin #1 (17, 18)
	- FX Delta Margin #2 (19, 20)
	- FX Delta Margin #3 (21, 22)
	- FX Delta Margin #4 (23, 24)
  • Loading branch information
lakshmiDRIP committed Aug 25, 2018
1 parent c5e0ee5 commit 2676cd8
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 183 deletions.
28 changes: 28 additions & 0 deletions ReleaseNotes/08_02_2018.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Features:

- Risk Class Sensitivity Aggregate #1 (1, 2)
- Risk Class Sensitivity Aggregate #2 (3, 4)
- Risk Class Sensitivity Aggregate #3 (5, 6)
- Risk Class Sensitivity Aggregate #4 (7, 8)
- Risk Class Sensitivity Aggregate #5 (9, 10)
- Bucket Aggregate Bounded Weighted Sensitivity (11, 12)
- Risk Class Sensitivity Aggregate #6 (13, 14)
- Risk Class Sensitivity Aggregate #7 (15, 16)
- SIMM 2.0 Risk Factor Aggregate Margin (25)
- Equity Delta Vega Threshold Map (26, 27)
- Equity Bucket Risk Weight Correlation (28, 29)
- Equity Risk Cross Bucket Correlation (30)
- Residual Equity Bucket Settings Entry (31)
- ISDA Bucket Sensitivity Settings Map (32, 33)
- Equity Bucket Delta Risk Weight (34, 35)


Bug Fixes/Clean-up:

Samples:

- FX Delta Margin #1 (17, 18)
- FX Delta Margin #2 (19, 20)
- FX Delta Margin #3 (21, 22)
- FX Delta Margin #4 (23, 24)
29 changes: 26 additions & 3 deletions src/main/java/org/drip/sample/simm20estimates/FXDeltaMargin.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.drip.simm20.margin.BucketAggregate;
import org.drip.simm20.parameters.RiskClassSensitivitySettings;
import org.drip.simm20.product.BucketSensitivity;
import org.drip.simm20.product.RiskClassSensitivity;

/*
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
Expand Down Expand Up @@ -213,6 +214,8 @@ public static final void main (

CategoryRiskFactorSensitivity (categorySensitivityMap);

Map<Integer, BucketSensitivity> bucketSensitivityMap = new TreeMap<Integer, BucketSensitivity>();

System.out.println ("\t|--------------------||");

System.out.println ("\t| BUCKET AGGREGATE ||");
Expand All @@ -237,20 +240,40 @@ public static final void main (
BucketSensitivity bucketSensitivity = new BucketSensitivity
(categorySensitivityMapEntry.getValue());

BucketAggregate bucketDigest = bucketSensitivity.augment
(riskClassSensitivitySettings.bucketSettingsMap().get (bucketIndex));
bucketSensitivityMap.put (
bucketIndex,
bucketSensitivity
);

BucketAggregate bucketDigest = bucketSensitivity.aggregate
(riskClassSensitivitySettings.bucketSensitivitySettingsMap().get (bucketIndex));

System.out.println ("\t| " +
bucketIndex + " => " +
FormatUtil.FormatDouble (Math.sqrt (bucketDigest.weightedSensitivityVariance()), 4, 0, 1.) + " | " +
FormatUtil.FormatDouble (bucketDigest.cumulativeRiskFactorSensitivity(), 4, 0, 1.) + " ||"
FormatUtil.FormatDouble (bucketDigest.cumulativeRiskFactorSensitivity(), 4, 0, 1.) + " ||"
);
}

System.out.println ("\t|--------------------||");

System.out.println();

System.out.println ("\t|----------------------------------||");

System.out.println ("\t| RISK CLASS DELTA MARGIN => " +
FormatUtil.FormatDouble (
Math.sqrt (
new RiskClassSensitivity (bucketSensitivityMap).aggregate
(riskClassSensitivitySettings).deltaSBA()
),
4, 0, 1.) + " ||"
);

System.out.println ("\t|----------------------------------||");

System.out.println();

EnvManager.TerminateEnv();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private static final void RiskWeights()
"\t||" + FormatUtil.FormatDouble (equityBucket.number(), 2, 0, 1.) + " | " +
equityBucket.size() + " | " +
equityBucket.region() + " | " +
FormatUtil.FormatDouble (equityBucket.riskWeight(), 3, 0, 1.) + " | " +
FormatUtil.FormatDouble (equityBucket.deltaRiskWeight(), 3, 0, 1.) + " | " +
FormatUtil.FormatDouble (equityBucket.memberCorrelation(), 2, 0, 100.) + "% | " +
FormatUtil.FormatDouble (equityBucket.vegaRiskWeight(), 1, 2, 1.) + " | {" +
sectorArrayDump + "}"
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/drip/simm20/equity/EQBucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public class EQBucket
private java.lang.String _size = "";
private java.lang.String _region = "";
private java.lang.String[] _sectorArray = null;
private double _riskWeight = java.lang.Double.NaN;
private double _vegaRiskWeight = java.lang.Double.NaN;
private double _deltaRiskWeight = java.lang.Double.NaN;
private double _memberCorrelation = java.lang.Double.NaN;

/**
Expand All @@ -86,9 +86,9 @@ public class EQBucket
* @param size Bucket Equity Market Capitalization Size
* @param region Buket Region
* @param sectorArray Bucket Sector Array
* @param riskWeight Bucket Risk Weight
* @param deltaRiskWeight Bucket Delta Risk Weight
* @param memberCorrelation Bucket Member Correlation
* @param vegaRiskWeight The Vega Risk Weight
* @param vegaRiskWeight The Bucket Vega Risk Weight
*
* @throws java.lang.Exception Thrown if the Inputs are Invalid
*/
Expand All @@ -98,15 +98,15 @@ public EQBucket (
final java.lang.String size,
final java.lang.String region,
final java.lang.String[] sectorArray,
final double riskWeight,
final double deltaRiskWeight,
final double memberCorrelation,
final double vegaRiskWeight)
throws java.lang.Exception
{
if (null == (_size = size) || _size.isEmpty() ||
null == (_region = region) || _region.isEmpty() ||
null == (_sectorArray = sectorArray) || 0 == _sectorArray.length ||
!org.drip.quant.common.NumberUtil.IsValid (_riskWeight = riskWeight) ||
!org.drip.quant.common.NumberUtil.IsValid (_deltaRiskWeight = deltaRiskWeight) ||
!org.drip.quant.common.NumberUtil.IsValid (_memberCorrelation = memberCorrelation) ||
!org.drip.quant.common.NumberUtil.IsValid (_vegaRiskWeight = vegaRiskWeight))
{
Expand Down Expand Up @@ -161,14 +161,14 @@ public java.lang.String[] sectorArray()
}

/**
* Retrieve the Bucket Risk Weight
* Retrieve the Bucket Delta Risk Weight
*
* @return The Bucket Risk Weight
* @return The Bucket Delta Risk Weight
*/

public double riskWeight()
public double deltaRiskWeight()
{
return _riskWeight;
return _deltaRiskWeight;
}

/**
Expand Down
25 changes: 22 additions & 3 deletions src/main/java/org/drip/simm20/margin/BucketAggregate.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class BucketAggregate
{
private double _weightedSensitivityVariance = java.lang.Double.NaN;
private double _cumulativeRiskFactorSensitivity = java.lang.Double.NaN;
private java.util.Map<java.lang.String, org.drip.simm20.margin.AugmentedRiskFactorSensitivity>
private java.util.Map<java.lang.String, org.drip.simm20.margin.RiskFactorAggregate>
_augmentedRiskFactorSensitivityMap = null;

/**
Expand All @@ -87,7 +87,7 @@ public class BucketAggregate
*/

public BucketAggregate (
final java.util.Map<java.lang.String, org.drip.simm20.margin.AugmentedRiskFactorSensitivity>
final java.util.Map<java.lang.String, org.drip.simm20.margin.RiskFactorAggregate>
augmentedRiskFactorSensitivityMap,
final double weightedSensitivityVariance,
final double cumulativeRiskFactorSensitivity)
Expand All @@ -110,7 +110,7 @@ public BucketAggregate (
* @return The Augmented Risk Factor Sensitivity Map
*/

public java.util.Map<java.lang.String, org.drip.simm20.margin.AugmentedRiskFactorSensitivity>
public java.util.Map<java.lang.String, org.drip.simm20.margin.RiskFactorAggregate>
augmentedRiskFactorSensitivityMap()
{
return _augmentedRiskFactorSensitivityMap;
Expand All @@ -137,4 +137,23 @@ public double cumulativeRiskFactorSensitivity()
{
return _cumulativeRiskFactorSensitivity;
}

/**
* Compute the Bounded Weighted Sensitivity
*
* @return The Bounded Weighted Sensitivity
*/

public double boundedWeightedSensitivity()
{
double weightedSensitivity = java.lang.Math.sqrt (_weightedSensitivityVariance);

return java.lang.Math.max (
java.lang.Math.min (
_cumulativeRiskFactorSensitivity,
weightedSensitivity
),
-1. * weightedSensitivity
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
*/

/**
* AugmentedRiskFactorSensitivity holds the Weighted and Normalized Bucket Risk Factor Sensitivity along with
* the Normalization Factors. The References are:
* RiskFactorAggregate holds the Weighted and Normalized Bucket Risk Factor Sensitivity along with the
* Normalization Factors. The References are:
*
* - Andersen, L. B. G., M. Pykhtin, and A. Sokol (2017): Credit Exposure in the Presence of Initial Margin,
* https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2806156, eSSRN.
Expand All @@ -69,29 +69,29 @@
* @author Lakshmi Krishnamurthy
*/

public class AugmentedRiskFactorSensitivity
public class RiskFactorAggregate
{
private double _weightedAndNormalized = java.lang.Double.NaN;
private double _concentrationRiskFactor = java.lang.Double.NaN;

/**
* AugmentedRiskFactorSensitivity Constructor
* RiskFactorAggregate Constructor
*
* @param weightedAndNormalized The Weighted and Normalized Bucket Sensitivity
* @param concentrationRiskFactor The Bucket Concentration Risk Factor
*
* @throws java.lang.Exception Thrown if the Inputs are Invalid
*/

public AugmentedRiskFactorSensitivity (
public RiskFactorAggregate (
final double weightedAndNormalized,
final double concentrationRiskFactor)
throws java.lang.Exception
{
if (!org.drip.quant.common.NumberUtil.IsValid (_weightedAndNormalized = weightedAndNormalized) ||
!org.drip.quant.common.NumberUtil.IsValid (_concentrationRiskFactor = concentrationRiskFactor))
{
throw new java.lang.Exception ("AugmentedRiskFactorSensitivity Constructor => Invalid Inputs");
throw new java.lang.Exception ("RiskFactorAggregate Constructor => Invalid Inputs");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static final EQSensitivitySettings ISDA()
bucketSettingsMap.put (
-1,
new org.drip.simm20.parameters.EQBucketSensitivitySettings (
bucketMap.get (-1).riskWeight(),
bucketMap.get (-1).deltaRiskWeight(),
deltaVegaRiskMap.get (-1).delta()
)
);
Expand All @@ -108,7 +108,7 @@ public static final EQSensitivitySettings ISDA()
bucketSettingsMap.put (
i,
new org.drip.simm20.parameters.EQBucketSensitivitySettings (
bucketMap.get (i).riskWeight(),
bucketMap.get (i).deltaRiskWeight(),
deltaVegaRiskMap.get (i).delta()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static final FlatSensitivitySettings EQ (
{
return null == equityBucket || null == deltaVegaThreshold ? null :
new FlatSensitivitySettings (
equityBucket.riskWeight(),
equityBucket.deltaRiskWeight(),
deltaVegaThreshold.delta()
);
}
Expand Down
Loading

0 comments on commit 2676cd8

Please sign in to comment.