diff --git a/ReleaseNotes/01_26_2023.txt b/ReleaseNotes/01_26_2023.txt new file mode 100644 index 000000000000..9f885f60e88a --- /dev/null +++ b/ReleaseNotes/01_26_2023.txt @@ -0,0 +1,40 @@ + +Features: + +Bug Fixes/Re-organization: + + - XVA Topology Collateral Group (1, 2, 3) + - XVA Topology Credit Debt Group #1 (4, 5) + - XVA Topology Credit Debt Group #2 (6, 7) + - XVA Topology Funding Group #1 (8, 9) + - XVA Topology Funding Group #2 (10, 11) + - XVA Topology Adiabat Market Parameters #1 (12, 13, 14) + - XVA Topology Adiabat Market Parameters #2 (15, 16) + - XVA Topology Adiabat #1 (17, 18) + - XVA Topology Adiabat #2 (19, 20) + - XVA Vertex Albanese Andersen (21) + - XVA Vertex Burgard Kjaer Exposure (22, 23, 24) + - XVA Vertex Burgard Kjaer (25, 26, 27) + - XVA Vertex Burgard Kjaer Builder (28, 29) + - Validation Distance Importance Weight (30, 31) + - Validation Distance Hypothesis Suite (32, 33) + - Validation Distance Gap Test Outcome (34, 35) + - Validation Distance Hypothesis Outcome (36) + - Validation Distance Hypothesis Outcome Suite (37, 38) + - Validation Distance Gap Loss Test (39) + - Validation Distance Gap Loss Weight Function (40) + - Validation Distance Gap Test Setting (41, 42) + - Validation Distance README (43, 44) + - Validation Evidence Test Statistic Evaluator (45) + - Validation Evidence Test Statistic Accumulator (46, 47) + - Validation Evidence Native PIT Generator (48) + - Validation Evidence Sample (49) + - Validation Evidence Ensemble (50, 51, 52) + - Validation Hypothesis T Test Outcome (53, 54, 55) + - Validation Hypothesis Significance Test Setting (56, 57) + - Validation Hypothesis Significance Test Outcome (58, 59, 60) + + +Samples: + +IdeaDRIP: diff --git a/ScheduleSheet.xlsx b/ScheduleSheet.xlsx index d0efda5ce88f..d9a67be933ad 100644 Binary files a/ScheduleSheet.xlsx and b/ScheduleSheet.xlsx differ diff --git a/src/main/java/org/drip/validation/distance/GapLossFunction.java b/src/main/java/org/drip/validation/distance/GapLossFunction.java index 3e84cdd973b8..51f362c71523 100644 --- a/src/main/java/org/drip/validation/distance/GapLossFunction.java +++ b/src/main/java/org/drip/validation/distance/GapLossFunction.java @@ -1,11 +1,16 @@ package org.drip.validation.distance; +import org.drip.numerical.common.NumberUtil; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -131,11 +136,10 @@ public static final GapLossFunction RiskFactorTest() { @Override public double loss ( final double gap) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (gap)) - { - throw new java.lang.Exception ("GapLossFunction::loss => Invalid Inputs"); + if (!NumberUtil.IsValid (gap)) { + throw new Exception ("GapLossFunction::loss => Invalid Inputs"); } return gap * gap; @@ -157,11 +161,10 @@ public static final GapLossFunction ConservativePortfolioTest() { @Override public double loss ( final double gap) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (gap)) - { - throw new java.lang.Exception ("GapLossFunction::loss => Invalid Inputs"); + if (!NumberUtil.IsValid (gap)) { + throw new Exception ("GapLossFunction::loss => Invalid Inputs"); } return gap < 0. ? 0. : gap * gap; @@ -177,10 +180,10 @@ public static final GapLossFunction ConservativePortfolioTest() * * @return The Loss * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public abstract double loss ( final double gap) - throws java.lang.Exception; + throws Exception; } diff --git a/src/main/java/org/drip/validation/distance/GapLossWeightFunction.java b/src/main/java/org/drip/validation/distance/GapLossWeightFunction.java index 0c236c1340fd..a97b3ad9bc40 100644 --- a/src/main/java/org/drip/validation/distance/GapLossWeightFunction.java +++ b/src/main/java/org/drip/validation/distance/GapLossWeightFunction.java @@ -1,11 +1,16 @@ package org.drip.validation.distance; +import org.drip.numerical.common.NumberUtil; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -130,11 +135,10 @@ public static final GapLossWeightFunction CramersVonMises() { @Override public double weight ( final double pValueHypothesis) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (pValueHypothesis)) - { - throw new java.lang.Exception ("GapLossWeightFunction::weight => Invalid Inputs"); + if (!NumberUtil.IsValid (pValueHypothesis)) { + throw new Exception ("GapLossWeightFunction::weight => Invalid Inputs"); } return 1.; @@ -154,11 +158,10 @@ public static final GapLossWeightFunction AndersonDarling() { @Override public double weight ( final double pValueHypothesis) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (pValueHypothesis)) - { - throw new java.lang.Exception ("GapLossWeightFunction::weight => Invalid Inputs"); + if (!NumberUtil.IsValid (pValueHypothesis)) { + throw new Exception ("GapLossWeightFunction::weight => Invalid Inputs"); } return 0. == pValueHypothesis || 1. == pValueHypothesis ? 0. : @@ -175,10 +178,10 @@ public static final GapLossWeightFunction AndersonDarling() * * @return The Weight * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public abstract double weight ( final double pValueHypothesis) - throws java.lang.Exception; + throws Exception; } diff --git a/src/main/java/org/drip/validation/distance/GapTestOutcome.java b/src/main/java/org/drip/validation/distance/GapTestOutcome.java index f402864db621..2f274479d4fa 100644 --- a/src/main/java/org/drip/validation/distance/GapTestOutcome.java +++ b/src/main/java/org/drip/validation/distance/GapTestOutcome.java @@ -1,11 +1,17 @@ package org.drip.validation.distance; +import org.drip.numerical.common.NumberUtil; +import org.drip.validation.hypothesis.ProbabilityIntegralTransform; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,11 +123,9 @@ public class GapTestOutcome { - private double _distance = java.lang.Double.NaN; - private org.drip.validation.hypothesis.ProbabilityIntegralTransform - _probabilityIntegralTransformWeighted = null; - private org.drip.validation.hypothesis.ProbabilityIntegralTransform - _probabilityIntegralTransformUnweighted = null; + private double _distance = Double.NaN; + private ProbabilityIntegralTransform _probabilityIntegralTransformWeighted = null; + private ProbabilityIntegralTransform _probabilityIntegralTransformUnweighted = null; /** * GapTestOutcome Constructor @@ -131,22 +135,19 @@ public class GapTestOutcome * Losses * @param distance Distance Metric * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public GapTestOutcome ( - final org.drip.validation.hypothesis.ProbabilityIntegralTransform - probabilityIntegralTransformUnweighted, - final org.drip.validation.hypothesis.ProbabilityIntegralTransform - probabilityIntegralTransformWeighted, + final ProbabilityIntegralTransform probabilityIntegralTransformUnweighted, + final ProbabilityIntegralTransform probabilityIntegralTransformWeighted, final double distance) - throws java.lang.Exception + throws Exception { if (null == (_probabilityIntegralTransformUnweighted = probabilityIntegralTransformUnweighted) || null == (_probabilityIntegralTransformWeighted = probabilityIntegralTransformWeighted) || - !org.drip.numerical.common.NumberUtil.IsValid (_distance = distance)) - { - throw new java.lang.Exception ("GapTestOutcome Constructor => Invalid Inputs"); + !NumberUtil.IsValid (_distance = distance)) { + throw new Exception ("GapTestOutcome Constructor => Invalid Inputs"); } } @@ -156,8 +157,7 @@ public GapTestOutcome ( * @return The Probability Integral Transform of the Raw Gap Losses */ - public org.drip.validation.hypothesis.ProbabilityIntegralTransform - probabilityIntegralTransformUnweighted() + public ProbabilityIntegralTransform probabilityIntegralTransformUnweighted() { return _probabilityIntegralTransformUnweighted; } @@ -168,7 +168,7 @@ public GapTestOutcome ( * @return The Probability Integral Transform of the Weighted Gap Losses */ - public org.drip.validation.hypothesis.ProbabilityIntegralTransform probabilityIntegralTransformWeighted() + public ProbabilityIntegralTransform probabilityIntegralTransformWeighted() { return _probabilityIntegralTransformWeighted; } diff --git a/src/main/java/org/drip/validation/distance/GapTestSetting.java b/src/main/java/org/drip/validation/distance/GapTestSetting.java index 88e8c5bcff50..3d304e5555cb 100644 --- a/src/main/java/org/drip/validation/distance/GapTestSetting.java +++ b/src/main/java/org/drip/validation/distance/GapTestSetting.java @@ -6,6 +6,9 @@ */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,8 +120,8 @@ public class GapTestSetting { - private org.drip.validation.distance.GapLossFunction _lossFunction = null; - private org.drip.validation.distance.GapLossWeightFunction _lossWeightFunction = null; + private GapLossFunction _lossFunction = null; + private GapLossWeightFunction _lossWeightFunction = null; /** * Construct the Anfuso Karyampas Nawroth (2017) Risk Factor Loss Test Variant of the Gap Test Setting @@ -129,17 +132,11 @@ public class GapTestSetting */ public static final GapTestSetting RiskFactorLossTest ( - final org.drip.validation.distance.GapLossWeightFunction lossWeightFunction) + final GapLossWeightFunction lossWeightFunction) { - try - { - return new GapTestSetting ( - org.drip.validation.distance.GapLossFunction.RiskFactorTest(), - lossWeightFunction - ); - } - catch (java.lang.Exception e) - { + try { + return new GapTestSetting (GapLossFunction.RiskFactorTest(), lossWeightFunction); + } catch (Exception e) { e.printStackTrace(); } @@ -157,17 +154,11 @@ public static final GapTestSetting RiskFactorLossTest ( */ public static final GapTestSetting ConservativePortfolioLossTest ( - final org.drip.validation.distance.GapLossWeightFunction lossWeightFunction) + final GapLossWeightFunction lossWeightFunction) { - try - { - return new GapTestSetting ( - org.drip.validation.distance.GapLossFunction.ConservativePortfolioTest(), - lossWeightFunction - ); - } - catch (java.lang.Exception e) - { + try { + return new GapTestSetting (GapLossFunction.ConservativePortfolioTest(), lossWeightFunction); + } catch (Exception e) { e.printStackTrace(); } @@ -180,18 +171,16 @@ public static final GapTestSetting ConservativePortfolioLossTest ( * @param lossFunction Gap Loss Function * @param lossWeightFunction Gap Loss Weight Function * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public GapTestSetting ( - final org.drip.validation.distance.GapLossFunction lossFunction, - final org.drip.validation.distance.GapLossWeightFunction lossWeightFunction) - throws java.lang.Exception + final GapLossFunction lossFunction, + final GapLossWeightFunction lossWeightFunction) + throws Exception { - if (null == (_lossFunction = lossFunction) || - null == (_lossWeightFunction = lossWeightFunction)) - { - throw new java.lang.Exception ("GapTestSetting Constructor => Invalid Inputs"); + if (null == (_lossFunction = lossFunction) || null == (_lossWeightFunction = lossWeightFunction)) { + throw new Exception ("GapTestSetting Constructor => Invalid Inputs"); } } @@ -201,7 +190,7 @@ public GapTestSetting ( * @return The Gap Loss Function */ - public org.drip.validation.distance.GapLossFunction lossFunction() + public GapLossFunction lossFunction() { return _lossFunction; } @@ -212,7 +201,7 @@ public org.drip.validation.distance.GapLossFunction lossFunction() * @return The Gap Loss Weight Function */ - public org.drip.validation.distance.GapLossWeightFunction lossWeightFunction() + public GapLossWeightFunction lossWeightFunction() { return _lossWeightFunction; } diff --git a/src/main/java/org/drip/validation/distance/HypothesisOutcome.java b/src/main/java/org/drip/validation/distance/HypothesisOutcome.java index a94b66693a05..c6a2ec8a5300 100644 --- a/src/main/java/org/drip/validation/distance/HypothesisOutcome.java +++ b/src/main/java/org/drip/validation/distance/HypothesisOutcome.java @@ -6,6 +6,9 @@ */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,8 +120,8 @@ public class HypothesisOutcome { - private java.lang.String _hypothesisID = ""; - private org.drip.validation.distance.GapTestOutcome _gapTestOutcome = null; + private String _hypothesisID = ""; + private GapTestOutcome _gapTestOutcome = null; /** * HypothesisOutcome Constructor @@ -126,18 +129,17 @@ public class HypothesisOutcome * @param hypothesisID The Hypothesis ID * @param gapTestOutcome The Gap Test Outcome * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public HypothesisOutcome ( - final java.lang.String hypothesisID, - final org.drip.validation.distance.GapTestOutcome gapTestOutcome) - throws java.lang.Exception + final String hypothesisID, + final GapTestOutcome gapTestOutcome) + throws Exception { if (null == (_hypothesisID = hypothesisID) || _hypothesisID.isEmpty() || - null == (_gapTestOutcome = gapTestOutcome)) - { - throw new java.lang.Exception ("HypothesisOutcome Constructor => Invalid Inputs"); + null == (_gapTestOutcome = gapTestOutcome)) { + throw new Exception ("HypothesisOutcome Constructor => Invalid Inputs"); } } @@ -147,7 +149,7 @@ public HypothesisOutcome ( * @return The Hypothesis ID */ - public java.lang.String hypothesisID() + public String hypothesisID() { return _hypothesisID; } @@ -158,7 +160,7 @@ public java.lang.String hypothesisID() * @return The Gap Test Outcome */ - public org.drip.validation.distance.GapTestOutcome gapTestOutcome() + public GapTestOutcome gapTestOutcome() { return _gapTestOutcome; } diff --git a/src/main/java/org/drip/validation/distance/HypothesisOutcomeSuite.java b/src/main/java/org/drip/validation/distance/HypothesisOutcomeSuite.java index 6f5da4f20558..67bf19b4ca63 100644 --- a/src/main/java/org/drip/validation/distance/HypothesisOutcomeSuite.java +++ b/src/main/java/org/drip/validation/distance/HypothesisOutcomeSuite.java @@ -1,11 +1,19 @@ package org.drip.validation.distance; +import java.util.Map; +import java.util.TreeMap; + +import org.drip.analytics.support.CaseInsensitiveHashMap; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -118,11 +126,9 @@ public class HypothesisOutcomeSuite { - private java.util.Map _outcomeMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + private TreeMap _distanceHypothesisMap = new TreeMap(); - private java.util.TreeMap _distanceHypothesisMap = new - java.util.TreeMap(); + private Map _outcomeMap = new CaseInsensitiveHashMap(); /** * Empty HypothesisOutcomeSuite Constructor @@ -138,7 +144,7 @@ public HypothesisOutcomeSuite() * @return The Outcome Map */ - public java.util.Map outcomeMap() + public Map outcomeMap() { return _outcomeMap; } @@ -149,7 +155,7 @@ public java.util.Map distanceHypothesisMap() + public TreeMap distanceHypothesisMap() { return _distanceHypothesisMap; } @@ -164,24 +170,16 @@ public java.util.TreeMap distanceHypothesisM */ public boolean add ( - final java.lang.String hypothesisID, - final org.drip.validation.distance.GapTestOutcome gapTestOutcome) + final String hypothesisID, + final GapTestOutcome gapTestOutcome) { - if (null == hypothesisID || hypothesisID.isEmpty() || - null == gapTestOutcome) - { + if (null == hypothesisID || hypothesisID.isEmpty() || null == gapTestOutcome) { return false; } - _outcomeMap.put ( - hypothesisID, - gapTestOutcome - ); + _outcomeMap.put (hypothesisID, gapTestOutcome); - _distanceHypothesisMap.put ( - gapTestOutcome.distance(), - hypothesisID - ); + _distanceHypothesisMap.put (gapTestOutcome.distance(), hypothesisID); return true; } @@ -192,24 +190,17 @@ public boolean add ( * @return The Leading/Best Fit Hypothesis and its Test Outcome */ - public org.drip.validation.distance.HypothesisOutcome leadingHypothesis() + public HypothesisOutcome leadingHypothesis() { - if (0 == _distanceHypothesisMap.size()) - { + if (0 == _distanceHypothesisMap.size()) { return null; } - java.lang.String leadingHypothesisID = _distanceHypothesisMap.firstEntry().getValue(); + String leadingHypothesisID = _distanceHypothesisMap.firstEntry().getValue(); - try - { - return new org.drip.validation.distance.HypothesisOutcome ( - leadingHypothesisID, - _outcomeMap.get (leadingHypothesisID) - ); - } - catch (java.lang.Exception e) - { + try { + return new HypothesisOutcome (leadingHypothesisID, _outcomeMap.get (leadingHypothesisID)); + } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/org/drip/validation/distance/HypothesisSuite.java b/src/main/java/org/drip/validation/distance/HypothesisSuite.java index acd8c6cb0c3b..e225e451c931 100644 --- a/src/main/java/org/drip/validation/distance/HypothesisSuite.java +++ b/src/main/java/org/drip/validation/distance/HypothesisSuite.java @@ -1,11 +1,19 @@ package org.drip.validation.distance; +import java.util.Map; + +import org.drip.analytics.support.CaseInsensitiveHashMap; +import org.drip.validation.evidence.Ensemble; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,8 +125,7 @@ public class HypothesisSuite { - private java.util.Map _hypothesisMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + private Map _hypothesisMap = new CaseInsensitiveHashMap(); /** * Empty HypothesisSuite Constructor @@ -134,7 +141,7 @@ public HypothesisSuite() * @return The Hypothesis Map */ - public java.util.Map hypothesisMap() + public Map hypothesisMap() { return _hypothesisMap; } @@ -149,19 +156,14 @@ public java.util.Map hy */ public boolean add ( - final java.lang.String hypothesisID, - final org.drip.validation.evidence.Ensemble hypothesis) + final String hypothesisID, + final Ensemble hypothesis) { - if (null == hypothesisID || hypothesisID.isEmpty() || - null == hypothesis) - { + if (null == hypothesisID || hypothesisID.isEmpty() || null == hypothesis) { return false; } - _hypothesisMap.put ( - hypothesisID, - hypothesis - ); + _hypothesisMap.put (hypothesisID, hypothesis); return true; } @@ -175,9 +177,9 @@ public boolean add ( */ public boolean containsHypothesis ( - final java.lang.String hypothesisID) + final String hypothesisID) { - return null != hypothesisID && !hypothesisID.isEmpty() && _hypothesisMap.containsKey (hypothesisID); + return null != hypothesisID && _hypothesisMap.containsKey (hypothesisID); } /** @@ -188,8 +190,8 @@ public boolean containsHypothesis ( * @return The Hypothesis Specified by the ID */ - public org.drip.validation.evidence.Ensemble hypothesis ( - final java.lang.String hypothesisID) + public Ensemble hypothesis ( + final String hypothesisID) { return containsHypothesis (hypothesisID) ? _hypothesisMap.get (hypothesisID) : null; } diff --git a/src/main/java/org/drip/validation/distance/ImportanceWeight.java b/src/main/java/org/drip/validation/distance/ImportanceWeight.java index edd69cfc3e22..576fa19a6149 100644 --- a/src/main/java/org/drip/validation/distance/ImportanceWeight.java +++ b/src/main/java/org/drip/validation/distance/ImportanceWeight.java @@ -1,11 +1,19 @@ package org.drip.validation.distance; +import org.drip.function.e2erf.ErrorFunctionInverse; +import org.drip.measure.continuous.R1Univariate; +import org.drip.measure.gaussian.R1UnivariateNormal; +import org.drip.numerical.common.NumberUtil; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,8 +125,8 @@ public class ImportanceWeight { - private double _positiveExpectation = java.lang.Double.NaN; - private org.drip.measure.continuous.R1Univariate _r1Univariate = null; + private R1Univariate _r1Univariate = null; + private double _positiveExpectation = Double.NaN; /** * Construct the Importance Weight Version based on Normal Distribution @@ -129,10 +137,9 @@ public class ImportanceWeight */ public static final ImportanceWeight Normal ( - final org.drip.measure.gaussian.R1UnivariateNormal r1UnivariateNormal) + final R1UnivariateNormal r1UnivariateNormal) { - if (null == r1UnivariateNormal) - { + if (null == r1UnivariateNormal) { return null; } @@ -140,38 +147,30 @@ public static final ImportanceWeight Normal ( final double sigma = r1UnivariateNormal.sigma(); - org.drip.measure.gaussian.R1UnivariateNormal r1UnivariateNormalStandard = - org.drip.measure.gaussian.R1UnivariateNormal.Standard(); + R1UnivariateNormal r1UnivariateNormalStandard = R1UnivariateNormal.Standard(); double meanOverSigma = mean / sigma; - try - { - final double positiveExpectation = java.lang.Math.max ( + try { + final double positiveExpectation = Math.max ( mean * r1UnivariateNormalStandard.cumulative (meanOverSigma) + sigma * r1UnivariateNormalStandard.density (meanOverSigma), 0. ); - return new ImportanceWeight ( - r1UnivariateNormal, - positiveExpectation - ) - { + return new ImportanceWeight (r1UnivariateNormal, positiveExpectation) { @Override public double quantileLoading ( final double q) - throws java.lang.Exception + throws Exception { - return 0. == positiveExpectation ? 0. : java.lang.Math.max ( - org.drip.function.e2erf.ErrorFunctionInverse.Winitzki2008b().evaluate - (2. * q - 1.) * sigma * java.lang.Math.sqrt (2.) + mean, + return 0. == positiveExpectation ? 0. : Math.max ( + ErrorFunctionInverse.Winitzki2008b().evaluate (2. * q - 1.) * sigma * Math.sqrt (2.) + + mean, 0 ) / positiveExpectation; } }; - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -184,19 +183,17 @@ public static final ImportanceWeight Normal ( * @param r1Univariate The Underlying R1 Distribution * @param positiveExpectation The Positive Expectation * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public ImportanceWeight ( - final org.drip.measure.continuous.R1Univariate r1Univariate, + final R1Univariate r1Univariate, final double positiveExpectation) - throws java.lang.Exception + throws Exception { if (null == (_r1Univariate = r1Univariate) || - !org.drip.numerical.common.NumberUtil.IsValid (_positiveExpectation = positiveExpectation) || - 0. > _positiveExpectation) - { - throw new java.lang.Exception ("ImportanceWeight Constructor => Invalid Inputs"); + !NumberUtil.IsValid (_positiveExpectation = positiveExpectation) || 0. > _positiveExpectation) { + throw new Exception ("ImportanceWeight Constructor => Invalid Inputs"); } } @@ -217,7 +214,7 @@ public double positiveExpectation() * @return The Underlying R1 Distribution */ - public org.drip.measure.continuous.R1Univariate r1Univariate() + public R1Univariate r1Univariate() { return _r1Univariate; } @@ -229,16 +226,14 @@ public org.drip.measure.continuous.R1Univariate r1Univariate() * * @return The Importance Weight Loading * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public double quantileLoading ( final double q) throws java.lang.Exception { - return 0. == _positiveExpectation ? 0. : java.lang.Math.max ( - _r1Univariate.invCumulative (q), - 0 - ) / _positiveExpectation; + return 0. == _positiveExpectation ? 0. : + Math.max (_r1Univariate.invCumulative (q), 0) / _positiveExpectation; } } diff --git a/src/main/java/org/drip/validation/distance/README.md b/src/main/java/org/drip/validation/distance/README.md index 0f0e065e750a..a5d9998b87e8 100644 --- a/src/main/java/org/drip/validation/distance/README.md +++ b/src/main/java/org/drip/validation/distance/README.md @@ -16,7 +16,7 @@ DROP XVA Validation Distance implements the Hypothesis Target Distance Test Buil * [***GapTestOutcome***](https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/distance/GapTestOutcome.java) GapTestOutcome holds the Outcomes of a Distance Test of a Sample from the Hypothesis. - * [***GapTestOutcome***](https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/distance/GapTestOutcome.java) + * [***GapTestSetting***](https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/distance/GapTestSetting.java) GapTestSetting holds the Settings required to Control a Gap Test Run. * [***HypothesisOutcome***](https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/distance/HypothesisOutcome.java) @@ -28,9 +28,6 @@ DROP XVA Validation Distance implements the Hypothesis Target Distance Test Buil * [***HypothesisSuite***](https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/distance/HypothesisSuite.java) HypothesisSuite holds the Map of Hypotheses to be subjected to Discriminatory Power Analysis. - * [***HypothesisSuite***](https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/distance/HypothesisSuite.java) - HypothesisSuite holds the Map of Hypotheses to be subjected to Discriminatory Power Analysis. - * [***ImportanceWeight***](https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/distance/ImportanceWeight.java) ImportanceWeight weighs the Importance of each Empirical Hypothesis Outcome. diff --git a/src/main/java/org/drip/validation/evidence/Ensemble.java b/src/main/java/org/drip/validation/evidence/Ensemble.java index 0369fca0d9bc..f88b1b5e8b4c 100644 --- a/src/main/java/org/drip/validation/evidence/Ensemble.java +++ b/src/main/java/org/drip/validation/evidence/Ensemble.java @@ -1,11 +1,22 @@ package org.drip.validation.evidence; +import org.drip.measure.statistics.UnivariateMoments; +import org.drip.numerical.common.NumberUtil; +import org.drip.validation.hypothesis.ProbabilityIntegralTransform; +import org.drip.validation.hypothesis.ProbabilityIntegralTransformTest; +import org.drip.validation.hypothesis.SignificanceTestSetting; +import org.drip.validation.hypothesis.StatisticalTestOutcome; +import org.drip.validation.hypothesis.TTestOutcome; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -116,14 +127,12 @@ * @author Lakshmi Krishnamurthy */ -public class Ensemble implements org.drip.validation.evidence.NativePITGenerator +public class Ensemble implements NativePITGenerator { + private Sample[] _sampleArray = null; private double[][] _evaluatedSampleTestStatistic = null; - private org.drip.validation.evidence.Sample[] _sampleArray = null; - private org.drip.validation.evidence.TestStatisticEvaluator[] _testStatisticEvaluatorArray = - null; - private org.drip.validation.hypothesis.ProbabilityIntegralTransform[] _probabilityIntegralTransformArray - = null; + private TestStatisticEvaluator[] _testStatisticEvaluatorArray = null; + private ProbabilityIntegralTransform[] _probabilityIntegralTransformArray = null; /** * Ensemble Constructor @@ -131,66 +140,55 @@ public class Ensemble implements org.drip.validation.evidence.NativePITGenerator * @param sampleArray Array of the Statistical Hypothesis Samples * @param testStatisticEvaluatorArray Array of the Test Statistic Evaluators * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public Ensemble ( - final org.drip.validation.evidence.Sample[] sampleArray, - final org.drip.validation.evidence.TestStatisticEvaluator[] testStatisticEvaluatorArray) - throws java.lang.Exception + final Sample[] sampleArray, + final TestStatisticEvaluator[] testStatisticEvaluatorArray) + throws Exception { if (null == (_sampleArray = sampleArray) || - null == (_testStatisticEvaluatorArray = testStatisticEvaluatorArray)) - { - throw new java.lang.Exception ("Ensemble Constructor => Invalid Inputs"); + null == (_testStatisticEvaluatorArray = testStatisticEvaluatorArray)) { + throw new Exception ("Ensemble Constructor => Invalid Inputs"); } int sampleCount = _sampleArray.length; int testStatisticEvaluatorCount = _testStatisticEvaluatorArray.length; _evaluatedSampleTestStatistic = new double[testStatisticEvaluatorCount][sampleCount]; - _probabilityIntegralTransformArray = new - org.drip.validation.hypothesis.ProbabilityIntegralTransform[testStatisticEvaluatorCount]; + _probabilityIntegralTransformArray = new ProbabilityIntegralTransform[testStatisticEvaluatorCount]; - if (0 == sampleCount || 0 == testStatisticEvaluatorCount) - { - throw new java.lang.Exception ("Ensemble Constructor => Invalid Inputs"); + if (0 == sampleCount || 0 == testStatisticEvaluatorCount) { + throw new Exception ("Ensemble Constructor => Invalid Inputs"); } - for (int sampleIndex = 0; sampleIndex < sampleCount; ++sampleIndex) - { - if (null == _sampleArray[sampleIndex]) - { - throw new java.lang.Exception ("Ensemble Constructor => Invalid Inputs"); + for (int sampleIndex = 0; sampleIndex < sampleCount; ++sampleIndex) { + if (null == _sampleArray[sampleIndex]) { + throw new Exception ("Ensemble Constructor => Invalid Inputs"); } } for (int testStatisticEvaluatorIndex = 0; testStatisticEvaluatorIndex < testStatisticEvaluatorCount; - ++testStatisticEvaluatorIndex) - { - if (null == _testStatisticEvaluatorArray[testStatisticEvaluatorIndex]) - { - throw new java.lang.Exception ("Ensemble Constructor => Invalid Inputs"); + ++testStatisticEvaluatorIndex) { + if (null == _testStatisticEvaluatorArray[testStatisticEvaluatorIndex]) { + throw new Exception ("Ensemble Constructor => Invalid Inputs"); } - org.drip.validation.evidence.TestStatisticAccumulator testStatisticAccumulator = new - org.drip.validation.evidence.TestStatisticAccumulator(); + TestStatisticAccumulator testStatisticAccumulator = new TestStatisticAccumulator(); - for (int sampleIndex = 0; sampleIndex < sampleCount; ++sampleIndex) - { + for (int sampleIndex = 0; sampleIndex < sampleCount; ++sampleIndex) { if (!testStatisticAccumulator.addTestStatistic (_evaluatedSampleTestStatistic[testStatisticEvaluatorIndex][sampleIndex] = _sampleArray[sampleIndex].applyTestStatistic - (_testStatisticEvaluatorArray[testStatisticEvaluatorIndex]))) - { - throw new java.lang.Exception ("Ensemble Constructor => Invalid Inputs"); + (_testStatisticEvaluatorArray[testStatisticEvaluatorIndex]))) { + throw new Exception ("Ensemble Constructor => Invalid Inputs"); } } if (null == (_probabilityIntegralTransformArray[testStatisticEvaluatorIndex] = - testStatisticAccumulator.probabilityIntegralTransform())) - { - throw new java.lang.Exception ("Ensemble Constructor => Invalid Inputs"); + testStatisticAccumulator.probabilityIntegralTransform())) { + throw new Exception ("Ensemble Constructor => Invalid Inputs"); } } } @@ -212,7 +210,7 @@ public double[][] evaluatedSampleTestStatistic() * @return The Array of the Statistical Hypothesis Samples */ - public org.drip.validation.evidence.Sample[] sampleArray() + public Sample[] sampleArray() { return _sampleArray; } @@ -223,7 +221,7 @@ public org.drip.validation.evidence.Sample[] sampleArray() * @return The Array of the Test Statistic Evaluators */ - public org.drip.validation.evidence.TestStatisticEvaluator[] testStatisticEvaluatorArray() + public TestStatisticEvaluator[] testStatisticEvaluatorArray() { return _testStatisticEvaluatorArray; } @@ -234,7 +232,7 @@ public org.drip.validation.evidence.TestStatisticEvaluator[] testStatisticEvalua * @return The Array of Probability Integral Transforms */ - public org.drip.validation.hypothesis.ProbabilityIntegralTransform[] probabilityIntegralTransformArray() + public ProbabilityIntegralTransform[] probabilityIntegralTransformArray() { return _probabilityIntegralTransformArray; } @@ -245,25 +243,20 @@ public org.drip.validation.hypothesis.ProbabilityIntegralTransform[] probability * @return The Test Statistic Based Significance Test Hypothesis Array */ - public org.drip.validation.hypothesis.ProbabilityIntegralTransformTest[] significanceTest() + public ProbabilityIntegralTransformTest[] significanceTest() { int probabilityIntegralTransformCount = _testStatisticEvaluatorArray.length; - org.drip.validation.hypothesis.ProbabilityIntegralTransformTest[] - probabilityIntegralTransformTestArray = new - org.drip.validation.hypothesis.ProbabilityIntegralTransformTest[probabilityIntegralTransformCount]; + ProbabilityIntegralTransformTest[] probabilityIntegralTransformTestArray = + new ProbabilityIntegralTransformTest[probabilityIntegralTransformCount]; for (int probabilityIntegralTransformIndex = 0; probabilityIntegralTransformIndex < probabilityIntegralTransformCount; - ++probabilityIntegralTransformIndex) - { - try - { + ++probabilityIntegralTransformIndex) { + try { probabilityIntegralTransformTestArray[probabilityIntegralTransformIndex] = new org.drip.validation.hypothesis.ProbabilityIntegralTransformTest (_probabilityIntegralTransformArray[probabilityIntegralTransformIndex]); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); return null; @@ -281,33 +274,28 @@ public org.drip.validation.hypothesis.ProbabilityIntegralTransformTest[] signifi * @return The Array of t-Test Results */ - public org.drip.validation.hypothesis.TTestOutcome[] tTest ( + public TTestOutcome[] tTest ( final double testStatistic) { int sampleCount = _sampleArray.length; int testStatisticEvaluatorCount = _testStatisticEvaluatorArray.length; - org.drip.validation.hypothesis.TTestOutcome[] tTestArray = new - org.drip.validation.hypothesis.TTestOutcome[testStatisticEvaluatorCount]; + TTestOutcome[] tTestOutcomeArray = new TTestOutcome[testStatisticEvaluatorCount]; for (int testStatisticEvaluatorIndex = 0; testStatisticEvaluatorIndex < testStatisticEvaluatorCount; - ++testStatisticEvaluatorIndex) - { - org.drip.measure.statistics.UnivariateMoments ensembleUnivariateMoments = - org.drip.measure.statistics.UnivariateMoments.Standard ( - "UnivariateMoments", - _evaluatedSampleTestStatistic[testStatisticEvaluatorIndex], - null - ); - - if (null == ensembleUnivariateMoments) - { + ++testStatisticEvaluatorIndex) { + UnivariateMoments ensembleUnivariateMoments = UnivariateMoments.Standard ( + "UnivariateMoments", + _evaluatedSampleTestStatistic[testStatisticEvaluatorIndex], + null + ); + + if (null == ensembleUnivariateMoments) { return null; } - try - { - tTestArray[testStatisticEvaluatorIndex] = new org.drip.validation.hypothesis.TTestOutcome ( + try { + tTestOutcomeArray[testStatisticEvaluatorIndex] = new TTestOutcome ( testStatistic, sampleCount, ensembleUnivariateMoments.mean(), @@ -319,16 +307,14 @@ public org.drip.validation.hypothesis.TTestOutcome[] tTest ( ensembleUnivariateMoments.tStatistic (testStatistic), ensembleUnivariateMoments.standardErrorOffset (testStatistic) ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); return null; } } - return tTestArray; + return tTestOutcomeArray; } /** @@ -340,63 +326,54 @@ public org.drip.validation.hypothesis.TTestOutcome[] tTest ( * @return The Array of Statistical Test Outcomes */ - public org.drip.validation.hypothesis.StatisticalTestOutcome[] statisticalTest ( + public StatisticalTestOutcome[] statisticalTest ( final double testStatistic, - final org.drip.validation.hypothesis.SignificanceTestSetting pTestSetting) + final SignificanceTestSetting pTestSetting) { - if (!org.drip.numerical.common.NumberUtil.IsValid (testStatistic) || null == pTestSetting) - { + if (!NumberUtil.IsValid (testStatistic) || null == pTestSetting) { return null; } int sampleCount = _sampleArray.length; int testStatisticEvaluatorCount = _testStatisticEvaluatorArray.length; - org.drip.validation.hypothesis.StatisticalTestOutcome[] statisticalTestOutcomeArray = new - org.drip.validation.hypothesis.StatisticalTestOutcome[testStatisticEvaluatorCount]; + StatisticalTestOutcome[] statisticalTestOutcomeArray = + new StatisticalTestOutcome[testStatisticEvaluatorCount]; - org.drip.validation.hypothesis.ProbabilityIntegralTransformTest[] - probabilityIntegralTransformTestArray = significanceTest(); + ProbabilityIntegralTransformTest[] probabilityIntegralTransformTestArray = significanceTest(); for (int testStatisticEvaluatorIndex = 0; testStatisticEvaluatorIndex < testStatisticEvaluatorCount; - ++testStatisticEvaluatorIndex) - { - org.drip.measure.statistics.UnivariateMoments ensembleUnivariateMoments = - org.drip.measure.statistics.UnivariateMoments.Standard ( - "UnivariateMoments", - _evaluatedSampleTestStatistic[testStatisticEvaluatorIndex], - null - ); - - if (null == ensembleUnivariateMoments) - { + ++testStatisticEvaluatorIndex) { + UnivariateMoments ensembleUnivariateMoments = UnivariateMoments.Standard ( + "UnivariateMoments", + _evaluatedSampleTestStatistic[testStatisticEvaluatorIndex], + null + ); + + if (null == ensembleUnivariateMoments) { return null; } - try - { - statisticalTestOutcomeArray[testStatisticEvaluatorIndex] = new - org.drip.validation.hypothesis.StatisticalTestOutcome ( - probabilityIntegralTransformTestArray[testStatisticEvaluatorIndex].significanceTest ( - testStatistic, - pTestSetting - ), - new org.drip.validation.hypothesis.TTestOutcome ( - testStatistic, - sampleCount, - ensembleUnivariateMoments.mean(), - ensembleUnivariateMoments.variance(), - ensembleUnivariateMoments.stdDev(), - ensembleUnivariateMoments.stdError(), - ensembleUnivariateMoments.degreesOfFreedom(), - ensembleUnivariateMoments.predictiveConfidenceLevel(), - ensembleUnivariateMoments.tStatistic (testStatistic), - ensembleUnivariateMoments.standardErrorOffset (testStatistic) - ) - ); - } - catch (java.lang.Exception e) - { + try { + statisticalTestOutcomeArray[testStatisticEvaluatorIndex] = new StatisticalTestOutcome ( + probabilityIntegralTransformTestArray[testStatisticEvaluatorIndex].significanceTest ( + testStatistic, + pTestSetting + ), + new TTestOutcome ( + testStatistic, + sampleCount, + ensembleUnivariateMoments.mean(), + ensembleUnivariateMoments.variance(), + ensembleUnivariateMoments.stdDev(), + ensembleUnivariateMoments.stdError(), + ensembleUnivariateMoments.degreesOfFreedom(), + ensembleUnivariateMoments.predictiveConfidenceLevel(), + ensembleUnivariateMoments.tStatistic (testStatistic), + ensembleUnivariateMoments.standardErrorOffset (testStatistic) + ) + ); + } catch (Exception e) { e.printStackTrace(); return null; @@ -406,20 +383,15 @@ public org.drip.validation.hypothesis.StatisticalTestOutcome[] statisticalTest ( return statisticalTestOutcomeArray; } - @Override public org.drip.validation.hypothesis.ProbabilityIntegralTransform - nativeProbabilityIntegralTransform() + @Override public ProbabilityIntegralTransform nativeProbabilityIntegralTransform() { - org.drip.validation.evidence.TestStatisticAccumulator testStatisticAccumulator = new - org.drip.validation.evidence.TestStatisticAccumulator(); + TestStatisticAccumulator testStatisticAccumulator = new TestStatisticAccumulator(); int sampleCount = _sampleArray.length; - for (int sampleIndex = 0; sampleIndex < sampleCount; ++sampleIndex) - { - for (double realization : _sampleArray[sampleIndex].realizationArray()) - { - if (!testStatisticAccumulator.addTestStatistic (realization)) - { + for (int sampleIndex = 0; sampleIndex < sampleCount; ++sampleIndex) { + for (double realization : _sampleArray[sampleIndex].realizationArray()) { + if (!testStatisticAccumulator.addTestStatistic (realization)) { return null; } } diff --git a/src/main/java/org/drip/validation/evidence/NativePITGenerator.java b/src/main/java/org/drip/validation/evidence/NativePITGenerator.java index 7bd71f8c8a4f..293824bfc1d6 100644 --- a/src/main/java/org/drip/validation/evidence/NativePITGenerator.java +++ b/src/main/java/org/drip/validation/evidence/NativePITGenerator.java @@ -1,11 +1,16 @@ package org.drip.validation.evidence; +import org.drip.validation.hypothesis.ProbabilityIntegralTransform; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -125,6 +130,5 @@ public interface NativePITGenerator * @return PIT over the Sample Instance Realizations */ - public abstract org.drip.validation.hypothesis.ProbabilityIntegralTransform - nativeProbabilityIntegralTransform(); + public abstract ProbabilityIntegralTransform nativeProbabilityIntegralTransform(); } diff --git a/src/main/java/org/drip/validation/evidence/Sample.java b/src/main/java/org/drip/validation/evidence/Sample.java index 66c5dd5dd272..648e4cdcfb6f 100644 --- a/src/main/java/org/drip/validation/evidence/Sample.java +++ b/src/main/java/org/drip/validation/evidence/Sample.java @@ -1,11 +1,17 @@ package org.drip.validation.evidence; +import org.drip.numerical.common.NumberUtil; +import org.drip.validation.hypothesis.ProbabilityIntegralTransform; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -115,7 +121,7 @@ * @author Lakshmi Krishnamurthy */ -public class Sample implements org.drip.validation.evidence.NativePITGenerator +public class Sample implements NativePITGenerator { private double[] _realizationArray = null; @@ -129,13 +135,11 @@ public class Sample implements org.drip.validation.evidence.NativePITGenerator public Sample ( final double[] realizationArray) - throws java.lang.Exception + throws Exception { - if (null == (_realizationArray = realizationArray) || - 0 == _realizationArray.length || - !org.drip.numerical.common.NumberUtil.IsValid (_realizationArray)) - { - throw new java.lang.Exception ("Sample Constructor => Invalid Inputs"); + if (null == (_realizationArray = realizationArray) || 0 == _realizationArray.length || + !NumberUtil.IsValid (_realizationArray)) { + throw new Exception ("Sample Constructor => Invalid Inputs"); } } @@ -157,31 +161,26 @@ public double[] realizationArray() * * @return The Sample Test Statistic * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public double applyTestStatistic ( - final org.drip.validation.evidence.TestStatisticEvaluator testStatisticEvaluator) - throws java.lang.Exception + final TestStatisticEvaluator testStatisticEvaluator) + throws Exception { - if (null == testStatisticEvaluator) - { - throw new java.lang.Exception ("Sample::applyTestStatistic => Invalid Inputs"); + if (null == testStatisticEvaluator) { + throw new Exception ("Sample::applyTestStatistic => Invalid Inputs"); } return testStatisticEvaluator.evaluate (_realizationArray); } - @Override public org.drip.validation.hypothesis.ProbabilityIntegralTransform - nativeProbabilityIntegralTransform() + @Override public ProbabilityIntegralTransform nativeProbabilityIntegralTransform() { - org.drip.validation.evidence.TestStatisticAccumulator testStatisticAccumulator = new - org.drip.validation.evidence.TestStatisticAccumulator(); + TestStatisticAccumulator testStatisticAccumulator = new TestStatisticAccumulator(); - for (double realization : _realizationArray) - { - if (!testStatisticAccumulator.addTestStatistic (realization)) - { + for (double realization : _realizationArray) { + if (!testStatisticAccumulator.addTestStatistic (realization)) { return null; } } diff --git a/src/main/java/org/drip/validation/evidence/TestStatisticAccumulator.java b/src/main/java/org/drip/validation/evidence/TestStatisticAccumulator.java index d716723924f0..05101f31a193 100644 --- a/src/main/java/org/drip/validation/evidence/TestStatisticAccumulator.java +++ b/src/main/java/org/drip/validation/evidence/TestStatisticAccumulator.java @@ -1,11 +1,20 @@ package org.drip.validation.evidence; +import java.util.Map; +import java.util.TreeMap; + +import org.drip.numerical.common.NumberUtil; +import org.drip.validation.hypothesis.ProbabilityIntegralTransform; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -118,7 +127,7 @@ public class TestStatisticAccumulator { private int _totalInstanceCount = 0; - private java.util.TreeMap _instanceCountMap = null; + private TreeMap _instanceCountMap = null; /** * Empty TestStatisticAccumulator Constructor @@ -134,7 +143,7 @@ public TestStatisticAccumulator() * @return The Instance Counter Map */ - public java.util.Map instanceCountMap() + public Map instanceCountMap() { return _instanceCountMap; } @@ -161,14 +170,12 @@ public int totalInstanceCount() public boolean addTestStatistic ( final double testStatistic) { - if (!org.drip.numerical.common.NumberUtil.IsValid (testStatistic)) - { + if (!NumberUtil.IsValid (testStatistic)) { return false; } - if (null == _instanceCountMap) - { - _instanceCountMap = new java.util.TreeMap(); + if (null == _instanceCountMap) { + _instanceCountMap = new TreeMap(); } _instanceCountMap.put ( @@ -187,25 +194,22 @@ public boolean addTestStatistic ( * * @return The Empirical Cumulative Test Statistic Probability from the Smallest Response Value * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public double cumulativeProbabilityFromLeft ( final double testStatistic) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (testStatistic) || 0 == _totalInstanceCount) - { - throw new java.lang.Exception + if (!NumberUtil.IsValid (testStatistic) || 0 == _totalInstanceCount) { + throw new Exception ("TestStatisticAccumulator::cumulativeProbabilityFromLeft => Invalid Inputs"); } - double cumulativeProbabilityFromLeft = 0; + double cumulativeProbabilityFromLeft = 0.; - for (double testStatisticKey : _instanceCountMap.keySet()) - { - if (testStatisticKey > testStatistic) - { + for (double testStatisticKey : _instanceCountMap.keySet()) { + if (testStatisticKey > testStatistic) { break; } @@ -222,25 +226,22 @@ public double cumulativeProbabilityFromLeft ( * * @return The Empirical Cumulative Test Statistic Probability from the Largest Response Value * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public double cumulativeProbabilityFromRight ( final double testStatistic) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (testStatistic) || 0 == _totalInstanceCount) - { - throw new java.lang.Exception + if (!NumberUtil.IsValid (testStatistic) || 0 == _totalInstanceCount) { + throw new Exception ("TestStatisticAccumulator::cumulativeProbabilityFromRight => Invalid Inputs"); } - double cumulativeProbabilityFromRight = 0; + double cumulativeProbabilityFromRight = 0.; - for (double testStatisticKey : _instanceCountMap.descendingKeySet()) - { - if (testStatisticKey < testStatistic) - { + for (double testStatisticKey : _instanceCountMap.descendingKeySet()) { + if (testStatisticKey < testStatistic) { break; } @@ -256,30 +257,22 @@ public double cumulativeProbabilityFromRight ( * @return The Test Statistic CDF Distribution */ - public org.drip.validation.hypothesis.ProbabilityIntegralTransform probabilityIntegralTransform() + public ProbabilityIntegralTransform probabilityIntegralTransform() { int instanceCount = 0; double totalInstanceCountReciprocal = 1. / _totalInstanceCount; - java.util.Map testStatisticPValueMap = new - java.util.TreeMap(); + Map testStatisticPValueMap = new TreeMap(); - for (double testStatisticKey : _instanceCountMap.keySet()) - { + for (double testStatisticKey : _instanceCountMap.keySet()) { instanceCount += _instanceCountMap.get (testStatisticKey); - testStatisticPValueMap.put ( - testStatisticKey, - totalInstanceCountReciprocal * instanceCount - ); + testStatisticPValueMap.put (testStatisticKey, totalInstanceCountReciprocal * instanceCount); } - try - { - return new org.drip.validation.hypothesis.ProbabilityIntegralTransform (testStatisticPValueMap); - } - catch (java.lang.Exception e) - { + try { + return new ProbabilityIntegralTransform (testStatisticPValueMap); + } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/org/drip/validation/evidence/TestStatisticEvaluator.java b/src/main/java/org/drip/validation/evidence/TestStatisticEvaluator.java index 9db5529cfb89..a3d3ce7af8c7 100644 --- a/src/main/java/org/drip/validation/evidence/TestStatisticEvaluator.java +++ b/src/main/java/org/drip/validation/evidence/TestStatisticEvaluator.java @@ -6,6 +6,9 @@ */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -126,10 +129,10 @@ public interface TestStatisticEvaluator * * @return The Test Statistic * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public abstract double evaluate ( final double[] sampleArray) - throws java.lang.Exception; + throws Exception; } diff --git a/src/main/java/org/drip/validation/hypothesis/SignificanceTestOutcome.java b/src/main/java/org/drip/validation/hypothesis/SignificanceTestOutcome.java index 29e3e964e24c..34bef8fe66c8 100644 --- a/src/main/java/org/drip/validation/hypothesis/SignificanceTestOutcome.java +++ b/src/main/java/org/drip/validation/hypothesis/SignificanceTestOutcome.java @@ -1,11 +1,16 @@ package org.drip.validation.hypothesis; +import org.drip.numerical.common.NumberUtil; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -118,9 +123,9 @@ public class SignificanceTestOutcome { private boolean _pass = false; - private double _testStatistic = java.lang.Double.NaN; - private double _leftTailPValue = java.lang.Double.NaN; - private double _rightTailPValue = java.lang.Double.NaN; + private double _testStatistic = Double.NaN; + private double _leftTailPValue = Double.NaN; + private double _rightTailPValue = Double.NaN; /** * SignificanceTestOutcome Constructor @@ -130,7 +135,7 @@ public class SignificanceTestOutcome * @param rightTailPValue Right Tail p-value * @param pass TRUE - Test successfully Passed * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public SignificanceTestOutcome ( @@ -138,13 +143,12 @@ public SignificanceTestOutcome ( final double leftTailPValue, final double rightTailPValue, final boolean pass) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (_testStatistic = testStatistic) || - !org.drip.numerical.common.NumberUtil.IsValid (_leftTailPValue = leftTailPValue) || - !org.drip.numerical.common.NumberUtil.IsValid (_rightTailPValue = rightTailPValue)) - { - throw new java.lang.Exception ("SignificanceTestOutcome Constructor => Invalid Inputs"); + if (!NumberUtil.IsValid (_testStatistic = testStatistic) || + !NumberUtil.IsValid (_leftTailPValue = leftTailPValue) || + !NumberUtil.IsValid (_rightTailPValue = rightTailPValue)) { + throw new Exception ("SignificanceTestOutcome Constructor => Invalid Inputs"); } _pass = pass; diff --git a/src/main/java/org/drip/validation/hypothesis/SignificanceTestSetting.java b/src/main/java/org/drip/validation/hypothesis/SignificanceTestSetting.java index 5ba5a81e3029..e4eb4a72aad3 100644 --- a/src/main/java/org/drip/validation/hypothesis/SignificanceTestSetting.java +++ b/src/main/java/org/drip/validation/hypothesis/SignificanceTestSetting.java @@ -1,11 +1,16 @@ package org.drip.validation.hypothesis; +import org.drip.numerical.common.NumberUtil; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -149,8 +154,8 @@ public class SignificanceTestSetting public static final double ANFUSO_KARYAMPAS_NAWROTH_2017_P_TEST_THRESHOLD = 0.01; + private double _threshold = Double.NaN; private int _tailCheck = RIGHT_TAIL_CHECK; - private double _threshold = java.lang.Double.NaN; /** * Construct Right Tail Check Significance Test Setting using the Fisher Threshold @@ -160,15 +165,9 @@ public class SignificanceTestSetting public static final SignificanceTestSetting FisherRightTail() { - try - { - return new SignificanceTestSetting ( - FISHER_1925_P_TEST_THRESHOLD, - RIGHT_TAIL_CHECK - ); - } - catch (java.lang.Exception e) - { + try { + return new SignificanceTestSetting (FISHER_1925_P_TEST_THRESHOLD, RIGHT_TAIL_CHECK); + } catch (Exception e) { e.printStackTrace(); } @@ -183,15 +182,9 @@ public static final SignificanceTestSetting FisherRightTail() public static final SignificanceTestSetting FisherLeftTail() { - try - { - return new SignificanceTestSetting ( - FISHER_1925_P_TEST_THRESHOLD, - LEFT_TAIL_CHECK - ); - } - catch (java.lang.Exception e) - { + try { + return new SignificanceTestSetting (FISHER_1925_P_TEST_THRESHOLD, LEFT_TAIL_CHECK); + } catch (Exception e) { e.printStackTrace(); } @@ -206,15 +199,9 @@ public static final SignificanceTestSetting FisherLeftTail() public static final SignificanceTestSetting FisherDoubleTail() { - try - { - return new SignificanceTestSetting ( - 2. * FISHER_1925_P_TEST_THRESHOLD, - DOUBLE_TAIL_CHECK - ); - } - catch (java.lang.Exception e) - { + try { + return new SignificanceTestSetting (2. * FISHER_1925_P_TEST_THRESHOLD, DOUBLE_TAIL_CHECK); + } catch (Exception e) { e.printStackTrace(); } @@ -227,17 +214,16 @@ public static final SignificanceTestSetting FisherDoubleTail() * @param threshold The Test Threshold * @param tailCheck Test Tail Check Flag * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public SignificanceTestSetting ( final double threshold, final int tailCheck) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (_threshold = threshold)) - { - throw new java.lang.Exception ("SignificanceTestSetting Constructor => Invalid Inputs"); + if (!NumberUtil.IsValid (_threshold = threshold)) { + throw new Exception ("SignificanceTestSetting Constructor => Invalid Inputs"); } _tailCheck = tailCheck; diff --git a/src/main/java/org/drip/validation/hypothesis/TTestOutcome.java b/src/main/java/org/drip/validation/hypothesis/TTestOutcome.java index f8b9361d7675..a2a01849df4d 100644 --- a/src/main/java/org/drip/validation/hypothesis/TTestOutcome.java +++ b/src/main/java/org/drip/validation/hypothesis/TTestOutcome.java @@ -1,11 +1,16 @@ package org.drip.validation.hypothesis; +import org.drip.numerical.common.NumberUtil; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -115,16 +120,16 @@ public class TTestOutcome { - private double _ensembleMean = java.lang.Double.NaN; - private double _testStatistic = java.lang.Double.NaN; - private int _sampleCount = java.lang.Integer.MIN_VALUE; - private double _ensembleVariance = java.lang.Double.NaN; - private double _ensembleTStatistics = java.lang.Double.NaN; - private double _ensembleStandardError = java.lang.Double.NaN; - private double _ensembleStandardDeviation = java.lang.Double.NaN; - private double _ensembleStandardErrorOffset = java.lang.Double.NaN; - private int _ensembleDegreesOfFreedom = java.lang.Integer.MIN_VALUE; - private double _ensemblePredictiveConfidenceInterval = java.lang.Double.NaN; + private double _ensembleMean = Double.NaN; + private double _testStatistic = Double.NaN; + private int _sampleCount = Integer.MIN_VALUE; + private double _ensembleVariance = Double.NaN; + private double _ensembleTStatistics = Double.NaN; + private double _ensembleStandardError = Double.NaN; + private double _ensembleStandardDeviation = Double.NaN; + private double _ensembleStandardErrorOffset = Double.NaN; + private int _ensembleDegreesOfFreedom = Integer.MIN_VALUE; + private double _ensemblePredictiveConfidenceInterval = Double.NaN; /** * TTestOutcome Constructor @@ -140,7 +145,7 @@ public class TTestOutcome * @param ensembleTStatistics Ensemble t-Statistics * @param ensembleStandardErrorOffset Ensemble Standard Error Offset * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public TTestOutcome ( @@ -156,21 +161,17 @@ public TTestOutcome ( final double ensembleStandardErrorOffset) throws java.lang.Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (_testStatistic = testStatistic) || - 0 >= (_sampleCount = sampleCount) || - !org.drip.numerical.common.NumberUtil.IsValid (_ensembleMean = ensembleMean) || - !org.drip.numerical.common.NumberUtil.IsValid (_ensembleVariance = ensembleVariance) || - !org.drip.numerical.common.NumberUtil.IsValid (_ensembleStandardDeviation = - ensembleStandardDeviation) || - !org.drip.numerical.common.NumberUtil.IsValid (_ensembleStandardError = ensembleStandardError) || - 0 > (_ensembleDegreesOfFreedom = ensembleDegreesOfFreedom) || - !org.drip.numerical.common.NumberUtil.IsValid (_ensemblePredictiveConfidenceInterval = + if (!NumberUtil.IsValid (_testStatistic = testStatistic) || 0 >= (_sampleCount = sampleCount) || + !NumberUtil.IsValid (_ensembleMean = ensembleMean) || + !NumberUtil.IsValid (_ensembleVariance = ensembleVariance) || + !NumberUtil.IsValid (_ensembleStandardDeviation = ensembleStandardDeviation) || + !NumberUtil.IsValid (_ensembleStandardError = ensembleStandardError) || + 0 > (_ensembleDegreesOfFreedom = ensembleDegreesOfFreedom) || + !NumberUtil.IsValid (_ensemblePredictiveConfidenceInterval = ensemblePredictiveConfidenceInterval) || - !org.drip.numerical.common.NumberUtil.IsValid (_ensembleTStatistics = ensembleTStatistics) || - !org.drip.numerical.common.NumberUtil.IsValid (_ensembleStandardErrorOffset = - ensembleStandardErrorOffset)) - { - throw new java.lang.Exception ("TTestOutcome Constructor => Invalid Inputs"); + !NumberUtil.IsValid (_ensembleTStatistics = ensembleTStatistics) || + !NumberUtil.IsValid (_ensembleStandardErrorOffset = ensembleStandardErrorOffset)) { + throw new Exception ("TTestOutcome Constructor => Invalid Inputs"); } } diff --git a/src/main/java/org/drip/xva/topology/Adiabat.java b/src/main/java/org/drip/xva/topology/Adiabat.java index 1bab4f916952..fdd8bcd87ff8 100644 --- a/src/main/java/org/drip/xva/topology/Adiabat.java +++ b/src/main/java/org/drip/xva/topology/Adiabat.java @@ -1,11 +1,24 @@ package org.drip.xva.topology; +import java.util.Map; + +import org.drip.analytics.support.CaseInsensitiveHashMap; +import org.drip.state.identifier.CSALabel; +import org.drip.state.identifier.EntityFundingLabel; +import org.drip.state.identifier.EntityHazardLabel; +import org.drip.state.identifier.EntityRecoveryLabel; +import org.drip.state.identifier.OvernightLabel; +import org.drip.xva.proto.ObjectSpecification; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,9 +130,9 @@ * @author Lakshmi Krishnamurthy */ -public class Adiabat extends org.drip.xva.proto.ObjectSpecification +public class Adiabat extends ObjectSpecification { - private java.util.Map _fundingGroupMap = null; + private Map _fundingGroupMap = null; /** * Adiabat Constructor @@ -127,21 +140,17 @@ public class Adiabat extends org.drip.xva.proto.ObjectSpecification * @param id BookGraph ID * @param name BookGraph Name * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public Adiabat ( - final java.lang.String id, - final java.lang.String name) - throws java.lang.Exception + final String id, + final String name) + throws Exception { - super ( - id, - name - ); + super (id, name); - _fundingGroupMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + _fundingGroupMap = new CaseInsensitiveHashMap(); } /** @@ -150,7 +159,7 @@ public Adiabat ( * @return The Funding Group Map */ - public java.util.Map fundingGroupMap() + public Map fundingGroupMap() { return _fundingGroupMap; } @@ -164,17 +173,13 @@ public java.util.Map fundi */ public boolean addFundingGroup ( - final org.drip.xva.topology.FundingGroup fundingGroup) + final FundingGroup fundingGroup) { - if (null == fundingGroup) - { + if (null == fundingGroup) { return false; } - _fundingGroupMap.put ( - fundingGroup.id(), - fundingGroup - ); + _fundingGroupMap.put (fundingGroup.id(), fundingGroup); return true; } @@ -188,10 +193,9 @@ public boolean addFundingGroup ( */ public boolean containsFundingGroup ( - final java.lang.String fundingGroupID) + final String fundingGroupID) { - return null == fundingGroupID || fundingGroupID.isEmpty() ? false : _fundingGroupMap.containsKey - (fundingGroupID); + return null != fundingGroupID && _fundingGroupMap.containsKey (fundingGroupID); } /** @@ -202,8 +206,8 @@ public boolean containsFundingGroup ( * @return TRUE - The Funding Group */ - public org.drip.xva.topology.FundingGroup fundingGroup ( - final java.lang.String fundingGroupID) + public FundingGroup fundingGroup ( + final String fundingGroupID) { return containsFundingGroup (fundingGroupID) ? _fundingGroupMap.get (fundingGroupID) : null; } @@ -214,37 +218,26 @@ public org.drip.xva.topology.FundingGroup fundingGroup ( * @return The Overnight Label Map */ - public java.util.Map overnightLabelMap() + public Map overnightLabelMap() { - java.util.Map overnightLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map overnightLabelMap = new CaseInsensitiveHashMap(); - for (java.util.Map.Entry fundingGroupEntry : - _fundingGroupMap.entrySet()) - { - java.util.Map creditDebtGroupMap = + for (Map.Entry fundingGroupEntry : _fundingGroupMap.entrySet()) { + Map creditDebtGroupMap = fundingGroupEntry.getValue().creditDebtGroupMap(); - for (java.util.Map.Entry - creditDebtGroupEntry : creditDebtGroupMap.entrySet()) - { - java.util.Map collateralGroupMap = + for (Map.Entry creditDebtGroupEntry : creditDebtGroupMap.entrySet()) { + Map collateralGroupMap = creditDebtGroupEntry.getValue().collateralGroupMap(); - for (java.util.Map.Entry - collateralGroupMapEntry : collateralGroupMap.entrySet()) - { - org.drip.state.identifier.OvernightLabel overnightLabel = - collateralGroupMapEntry.getValue().overnightLabel(); + for (Map.Entry collateralGroupMapEntry : + collateralGroupMap.entrySet()) { + OvernightLabel overnightLabel = collateralGroupMapEntry.getValue().overnightLabel(); - java.lang.String overnightLabelFQN = overnightLabel.fullyQualifiedName(); + String overnightLabelFQN = overnightLabel.fullyQualifiedName(); - if (!overnightLabelMap.containsKey (overnightLabelFQN)) - { - overnightLabelMap.put ( - overnightLabelFQN, - overnightLabel - ); + if (!overnightLabelMap.containsKey (overnightLabelFQN)) { + overnightLabelMap.put (overnightLabelFQN, overnightLabel); } } } @@ -259,37 +252,26 @@ public java.util.Map * @return The CSA Label Map */ - public java.util.Map csaLabelMap() + public Map csaLabelMap() { - java.util.Map csaLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map csaLabelMap = new CaseInsensitiveHashMap(); - for (java.util.Map.Entry fundingGroupEntry : - _fundingGroupMap.entrySet()) - { - java.util.Map creditDebtGroupMap = + for (Map.Entry fundingGroupEntry : _fundingGroupMap.entrySet()) { + Map creditDebtGroupMap = fundingGroupEntry.getValue().creditDebtGroupMap(); - for (java.util.Map.Entry - creditDebtGroupEntry : creditDebtGroupMap.entrySet()) - { - java.util.Map collateralGroupMap = + for (Map.Entry creditDebtGroupEntry : creditDebtGroupMap.entrySet()) { + Map collateralGroupMap = creditDebtGroupEntry.getValue().collateralGroupMap(); - for (java.util.Map.Entry - collateralGroupMapEntry : collateralGroupMap.entrySet()) - { - org.drip.state.identifier.CSALabel csaLabel = - collateralGroupMapEntry.getValue().csaLabel(); + for (Map.Entry collateralGroupMapEntry : + collateralGroupMap.entrySet()) { + CSALabel csaLabel = collateralGroupMapEntry.getValue().csaLabel(); - java.lang.String csaLabelFQN = csaLabel.fullyQualifiedName(); + String csaLabelFQN = csaLabel.fullyQualifiedName(); - if (!csaLabelMap.containsKey (csaLabelFQN)) - { - csaLabelMap.put ( - csaLabelFQN, - csaLabel - ); + if (!csaLabelMap.containsKey (csaLabelFQN)) { + csaLabelMap.put (csaLabelFQN, csaLabel); } } } @@ -304,33 +286,23 @@ public java.util.Map csaLa * @return The Dealer Hazard Label Map */ - public java.util.Map - dealerHazardLabelMap() + public Map dealerHazardLabelMap() { - java.util.Map dealerHazardLabelMap = - new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry fundingGroupEntry : - _fundingGroupMap.entrySet()) - { - java.util.Map creditDebtGroupMap = + Map dealerHazardLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry fundingGroupEntry : _fundingGroupMap.entrySet()) { + Map creditDebtGroupMap = fundingGroupEntry.getValue().creditDebtGroupMap(); - for (java.util.Map.Entry - creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) + for (Map.Entry creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) { - org.drip.state.identifier.EntityHazardLabel dealerHazardLabel = - creditDebtGroupMapEntry.getValue().dealerHazardLabel(); + EntityHazardLabel dealerHazardLabel = creditDebtGroupMapEntry.getValue().dealerHazardLabel(); - java.lang.String dealerHazardLabelFQN = dealerHazardLabel.fullyQualifiedName(); + String dealerHazardLabelFQN = dealerHazardLabel.fullyQualifiedName(); - if (!dealerHazardLabelMap.containsKey (dealerHazardLabelFQN)) - { - dealerHazardLabelMap.put ( - dealerHazardLabelFQN, - dealerHazardLabel - ); + if (!dealerHazardLabelMap.containsKey (dealerHazardLabelFQN)) { + dealerHazardLabelMap.put (dealerHazardLabelFQN, dealerHazardLabel); } } } @@ -344,33 +316,24 @@ public java.util.Map csaLa * @return The Client Hazard Label Map */ - public java.util.Map - clientHazardLabelMap() + public Map clientHazardLabelMap() { - java.util.Map clientHazardLabelMap = - new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry fundingGroupEntry : - _fundingGroupMap.entrySet()) - { - java.util.Map creditDebtGroupMap = + Map clientHazardLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry fundingGroupEntry : _fundingGroupMap.entrySet()) { + Map creditDebtGroupMap = fundingGroupEntry.getValue().creditDebtGroupMap(); - for (java.util.Map.Entry - creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) + for (Map.Entry creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) { - org.drip.state.identifier.EntityHazardLabel clientHazardLabel = + EntityHazardLabel clientHazardLabel = creditDebtGroupMapEntry.getValue().clientPartyHazardLabel(); - java.lang.String clientHazardLabelFQN = clientHazardLabel.fullyQualifiedName(); + String clientHazardLabelFQN = clientHazardLabel.fullyQualifiedName(); - if (!clientHazardLabelMap.containsKey (clientHazardLabelFQN)) - { - clientHazardLabelMap.put ( - clientHazardLabelFQN, - clientHazardLabel - ); + if (!clientHazardLabelMap.containsKey (clientHazardLabelFQN)) { + clientHazardLabelMap.put (clientHazardLabelFQN, clientHazardLabel); } } } @@ -384,30 +347,23 @@ public java.util.Map csaLa * @return The Dealer Senior Recovery Label Map */ - public java.util.Map - dealerSeniorRecoveryLabelMap() + public Map dealerSeniorRecoveryLabelMap() { - java.util.Map - dealerSeniorRecoveryLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry fundingGroupEntry : - _fundingGroupMap.entrySet()) - { - java.util.Map creditDebtGroupMap = + Map dealerSeniorRecoveryLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry fundingGroupEntry : _fundingGroupMap.entrySet()) { + Map creditDebtGroupMap = fundingGroupEntry.getValue().creditDebtGroupMap(); - for (java.util.Map.Entry - creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) + for (Map.Entry creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) { - org.drip.state.identifier.EntityRecoveryLabel dealerSeniorRecoveryLabel = + EntityRecoveryLabel dealerSeniorRecoveryLabel = creditDebtGroupMapEntry.getValue().dealerSeniorRecoveryLabel(); - java.lang.String dealerSeniorRecoveryLabelFQN = - dealerSeniorRecoveryLabel.fullyQualifiedName(); + String dealerSeniorRecoveryLabelFQN = dealerSeniorRecoveryLabel.fullyQualifiedName(); - if (!dealerSeniorRecoveryLabelMap.containsKey (dealerSeniorRecoveryLabelFQN)) - { + if (!dealerSeniorRecoveryLabelMap.containsKey (dealerSeniorRecoveryLabelFQN)) { dealerSeniorRecoveryLabelMap.put ( dealerSeniorRecoveryLabelFQN, dealerSeniorRecoveryLabel @@ -425,33 +381,24 @@ public java.util.Map csaLa * @return The Client Recovery Label Map */ - public java.util.Map - clientRecoveryLabelMap() + public Map clientRecoveryLabelMap() { - java.util.Map clientRecoveryLabelMap - = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry fundingGroupEntry : - _fundingGroupMap.entrySet()) - { - java.util.Map creditDebtGroupMap = + Map clientRecoveryLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry fundingGroupEntry : _fundingGroupMap.entrySet()) { + Map creditDebtGroupMap = fundingGroupEntry.getValue().creditDebtGroupMap(); - for (java.util.Map.Entry - creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) + for (Map.Entry creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) { - org.drip.state.identifier.EntityRecoveryLabel clientRecoveryLabel = + EntityRecoveryLabel clientRecoveryLabel = creditDebtGroupMapEntry.getValue().clientRecoveryLabel(); - java.lang.String clientRecoveryLabelFQN = clientRecoveryLabel.fullyQualifiedName(); + String clientRecoveryLabelFQN = clientRecoveryLabel.fullyQualifiedName(); - if (!clientRecoveryLabelMap.containsKey (clientRecoveryLabelFQN)) - { - clientRecoveryLabelMap.put ( - clientRecoveryLabelFQN, - clientRecoveryLabel - ); + if (!clientRecoveryLabelMap.containsKey (clientRecoveryLabelFQN)) { + clientRecoveryLabelMap.put (clientRecoveryLabelFQN, clientRecoveryLabel); } } } @@ -465,30 +412,24 @@ public java.util.Map csaLa * @return The Dealer Subordinate Recovery Label Map */ - public java.util.Map - dealerSubordinateRecoveryLabelMap() + public Map dealerSubordinateRecoveryLabelMap() { - java.util.Map - dealerSubordinateRecoveryLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry fundingGroupEntry : - _fundingGroupMap.entrySet()) - { - java.util.Map creditDebtGroupMap = + Map dealerSubordinateRecoveryLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry fundingGroupEntry : _fundingGroupMap.entrySet()) { + Map creditDebtGroupMap = fundingGroupEntry.getValue().creditDebtGroupMap(); - for (java.util.Map.Entry - creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) + for (Map.Entry creditDebtGroupMapEntry : creditDebtGroupMap.entrySet()) { - org.drip.state.identifier.EntityRecoveryLabel dealerSubordinateRecoveryLabel = + EntityRecoveryLabel dealerSubordinateRecoveryLabel = creditDebtGroupMapEntry.getValue().dealerSubordinateRecoveryLabel(); - java.lang.String dealerSubordinateRecoveryLabelFQN = + String dealerSubordinateRecoveryLabelFQN = dealerSubordinateRecoveryLabel.fullyQualifiedName(); - if (!dealerSubordinateRecoveryLabelMap.containsKey (dealerSubordinateRecoveryLabelFQN)) - { + if (!dealerSubordinateRecoveryLabelMap.containsKey (dealerSubordinateRecoveryLabelFQN)) { dealerSubordinateRecoveryLabelMap.put ( dealerSubordinateRecoveryLabelFQN, dealerSubordinateRecoveryLabel @@ -506,27 +447,19 @@ public java.util.Map csaLa * @return The Dealer Senior Funding Label Map */ - public java.util.Map - dealerSeniorFundingLabelMap() + public Map dealerSeniorFundingLabelMap() { - java.util.Map - dealerSeniorFundingLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry fundingGroupMapEntry : - _fundingGroupMap.entrySet()) - { - org.drip.state.identifier.EntityFundingLabel dealerSeniorFundingLabel = + Map dealerSeniorFundingLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry fundingGroupMapEntry : _fundingGroupMap.entrySet()) { + EntityFundingLabel dealerSeniorFundingLabel = fundingGroupMapEntry.getValue().dealerSeniorFundingLabel(); - java.lang.String dealerSeniorFundingLabelFQN = dealerSeniorFundingLabel.fullyQualifiedName(); + String dealerSeniorFundingLabelFQN = dealerSeniorFundingLabel.fullyQualifiedName(); - if (!dealerSeniorFundingLabelMap.containsKey (dealerSeniorFundingLabelFQN)) - { - dealerSeniorFundingLabelMap.put ( - dealerSeniorFundingLabelFQN, - dealerSeniorFundingLabel - ); + if (!dealerSeniorFundingLabelMap.containsKey (dealerSeniorFundingLabelFQN)) { + dealerSeniorFundingLabelMap.put (dealerSeniorFundingLabelFQN, dealerSeniorFundingLabel); } } @@ -539,27 +472,18 @@ public java.util.Map csaLa * @return The Client Funding Label Map */ - public java.util.Map - clientFundingLabelMap() + public Map clientFundingLabelMap() { - java.util.Map clientFundingLabelMap = - new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map clientFundingLabelMap = + new CaseInsensitiveHashMap(); - for (java.util.Map.Entry fundingGroupMapEntry : - _fundingGroupMap.entrySet()) - { - org.drip.state.identifier.EntityFundingLabel clientFundingLabel = - fundingGroupMapEntry.getValue().clientFundingLabel(); + for (Map.Entry fundingGroupMapEntry : _fundingGroupMap.entrySet()) { + EntityFundingLabel clientFundingLabel = fundingGroupMapEntry.getValue().clientFundingLabel(); - java.lang.String clientFundingLabelFQN = clientFundingLabel.fullyQualifiedName(); + String clientFundingLabelFQN = clientFundingLabel.fullyQualifiedName(); - if (!clientFundingLabelMap.containsKey (clientFundingLabelFQN)) - { - clientFundingLabelMap.put ( - clientFundingLabelFQN, - clientFundingLabel - ); + if (!clientFundingLabelMap.containsKey (clientFundingLabelFQN)) { + clientFundingLabelMap.put (clientFundingLabelFQN, clientFundingLabel); } } @@ -572,26 +496,19 @@ public java.util.Map csaLa * @return The Dealer Subordinate Funding Label Map */ - public java.util.Map - dealerSubordinateFundingLabelMap() + public Map dealerSubordinateFundingLabelMap() { - java.util.Map - dealerSubordinateFundingLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry fundingGroupMapEntry : - _fundingGroupMap.entrySet()) - { - org.drip.state.identifier.EntityFundingLabel dealerSubordinateFundingLabel = + Map dealerSubordinateFundingLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry fundingGroupMapEntry : _fundingGroupMap.entrySet()) { + EntityFundingLabel dealerSubordinateFundingLabel = fundingGroupMapEntry.getValue().dealerSubordinateFundingLabel(); - if (null != dealerSubordinateFundingLabel) - { - java.lang.String dealerSubordinateFundingLabelFQN = - dealerSubordinateFundingLabel.fullyQualifiedName(); + if (null != dealerSubordinateFundingLabel) { + String dealerSubordinateFundingLabelFQN = dealerSubordinateFundingLabel.fullyQualifiedName(); - if (!dealerSubordinateFundingLabelMap.containsKey (dealerSubordinateFundingLabelFQN)) - { + if (!dealerSubordinateFundingLabelMap.containsKey (dealerSubordinateFundingLabelFQN)) { dealerSubordinateFundingLabelMap.put ( dealerSubordinateFundingLabelFQN, dealerSubordinateFundingLabel @@ -609,85 +526,61 @@ public java.util.Map csaLa * @return The Adiabat Dependent Market Parameters */ - public org.drip.xva.topology.AdiabatMarketParams marketParams() + public AdiabatMarketParams marketParams() { - java.util.Map csaLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map csaLabelMap = new CaseInsensitiveHashMap(); - java.util.Map overnightLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map overnightLabelMap = new CaseInsensitiveHashMap(); - java.util.Map dealerHazardLabelMap = - new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map clientHazardLabelMap = + new CaseInsensitiveHashMap(); - java.util.Map clientHazardLabelMap = - new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map dealerHazardLabelMap = + new CaseInsensitiveHashMap(); - java.util.Map - dealerSeniorRecoveryLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map clientRecoveryLabelMap = + new CaseInsensitiveHashMap(); - java.util.Map clientRecoveryLabelMap - = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map dealerSeniorRecoveryLabelMap = + new CaseInsensitiveHashMap(); - java.util.Map - dealerSubordinateRecoveryLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map dealerSubordinateRecoveryLabelMap = + new CaseInsensitiveHashMap(); - java.util.Map - dealerSeniorFundingLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map dealerSeniorFundingLabelMap = + new CaseInsensitiveHashMap(); - java.util.Map clientFundingLabelMap = - new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map clientFundingLabelMap = + new CaseInsensitiveHashMap(); - java.util.Map - dealerSubordinateFundingLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map dealerSubordinateFundingLabelMap = + new CaseInsensitiveHashMap(); - for (java.util.Map.Entry fundingGroupEntry : - _fundingGroupMap.entrySet()) - { - org.drip.state.identifier.EntityFundingLabel dealerSeniorFundingLabel = + for (Map.Entry fundingGroupEntry : _fundingGroupMap.entrySet()) { + EntityFundingLabel dealerSeniorFundingLabel = fundingGroupEntry.getValue().dealerSeniorFundingLabel(); - java.lang.String dealerSeniorFundingLabelFQN = dealerSeniorFundingLabel.fullyQualifiedName(); + String dealerSeniorFundingLabelFQN = dealerSeniorFundingLabel.fullyQualifiedName(); - if (!dealerSeniorFundingLabelMap.containsKey (dealerSeniorFundingLabelFQN)) - { - dealerSeniorFundingLabelMap.put ( - dealerSeniorFundingLabelFQN, - dealerSeniorFundingLabel - ); + if (!dealerSeniorFundingLabelMap.containsKey (dealerSeniorFundingLabelFQN)) { + dealerSeniorFundingLabelMap.put (dealerSeniorFundingLabelFQN, dealerSeniorFundingLabel); } - org.drip.state.identifier.EntityFundingLabel clientFundingLabel = - fundingGroupEntry.getValue().clientFundingLabel(); + EntityFundingLabel clientFundingLabel = fundingGroupEntry.getValue().clientFundingLabel(); - java.lang.String clientFundingLabelFQN = clientFundingLabel.fullyQualifiedName(); + String clientFundingLabelFQN = clientFundingLabel.fullyQualifiedName(); - if (!clientFundingLabelMap.containsKey (clientFundingLabelFQN)) - { - clientFundingLabelMap.put ( - clientFundingLabelFQN, - clientFundingLabel - ); + if (!clientFundingLabelMap.containsKey (clientFundingLabelFQN)) { + clientFundingLabelMap.put (clientFundingLabelFQN, clientFundingLabel); } - org.drip.state.identifier.EntityFundingLabel dealerSubordinateFundingLabel = + EntityFundingLabel dealerSubordinateFundingLabel = fundingGroupEntry.getValue().dealerSubordinateFundingLabel(); - if (null != dealerSubordinateFundingLabel) - { - java.lang.String dealerSubordinateFundingLabelFQN = - dealerSubordinateFundingLabel.fullyQualifiedName(); + if (null != dealerSubordinateFundingLabel) { + String dealerSubordinateFundingLabelFQN = dealerSubordinateFundingLabel.fullyQualifiedName(); - if (!dealerSubordinateFundingLabelMap.containsKey (dealerSubordinateFundingLabelFQN)) - { + if (!dealerSubordinateFundingLabelMap.containsKey (dealerSubordinateFundingLabelFQN)) { dealerSubordinateFundingLabelMap.put ( dealerSubordinateFundingLabelFQN, dealerSubordinateFundingLabel @@ -695,78 +588,60 @@ public org.drip.xva.topology.AdiabatMarketParams marketParams() } } - java.util.Map creditDebtGroupMap = + Map creditDebtGroupMap = fundingGroupEntry.getValue().creditDebtGroupMap(); - for (java.util.Map.Entry - creditDebtGroupEntry : creditDebtGroupMap.entrySet()) - { - java.util.Map collateralGroupMap = + for (Map.Entry creditDebtGroupEntry : creditDebtGroupMap.entrySet()) { + Map collateralGroupMap = creditDebtGroupEntry.getValue().collateralGroupMap(); - org.drip.state.identifier.EntityHazardLabel dealerHazardLabel = - creditDebtGroupEntry.getValue().dealerHazardLabel(); + EntityHazardLabel dealerHazardLabel = creditDebtGroupEntry.getValue().dealerHazardLabel(); - java.lang.String dealerHazardLabelFQN = dealerHazardLabel.fullyQualifiedName(); + String dealerHazardLabelFQN = dealerHazardLabel.fullyQualifiedName(); - if (!dealerHazardLabelMap.containsKey (dealerHazardLabelFQN)) - { - dealerHazardLabelMap.put ( - dealerHazardLabelFQN, - dealerHazardLabel - ); + if (!dealerHazardLabelMap.containsKey (dealerHazardLabelFQN)) { + dealerHazardLabelMap.put (dealerHazardLabelFQN, dealerHazardLabel); } - org.drip.state.identifier.EntityHazardLabel clientHazardLabel = + EntityHazardLabel clientHazardLabel = creditDebtGroupEntry.getValue().clientPartyHazardLabel(); - java.lang.String clientHazardLabelFQN = clientHazardLabel.fullyQualifiedName(); + String clientHazardLabelFQN = clientHazardLabel.fullyQualifiedName(); - if (!clientHazardLabelMap.containsKey (clientHazardLabelFQN)) - { - clientHazardLabelMap.put ( - clientHazardLabelFQN, - clientHazardLabel - ); + if (!clientHazardLabelMap.containsKey (clientHazardLabelFQN)) { + clientHazardLabelMap.put (clientHazardLabelFQN, clientHazardLabel); } - org.drip.state.identifier.EntityRecoveryLabel dealerSeniorRecoveryLabel = + EntityRecoveryLabel dealerSeniorRecoveryLabel = creditDebtGroupEntry.getValue().dealerSeniorRecoveryLabel(); - java.lang.String dealerSeniorRecoveryLabelFQN = + String dealerSeniorRecoveryLabelFQN = dealerSeniorRecoveryLabel.fullyQualifiedName(); - if (!dealerSeniorRecoveryLabelMap.containsKey (dealerSeniorRecoveryLabelFQN)) - { + if (!dealerSeniorRecoveryLabelMap.containsKey (dealerSeniorRecoveryLabelFQN)) { dealerSeniorRecoveryLabelMap.put ( dealerSeniorRecoveryLabelFQN, dealerSeniorRecoveryLabel ); } - org.drip.state.identifier.EntityRecoveryLabel clientRecoveryLabel = + EntityRecoveryLabel clientRecoveryLabel = creditDebtGroupEntry.getValue().clientRecoveryLabel(); - java.lang.String clientRecoveryLabelFQN = clientRecoveryLabel.fullyQualifiedName(); + String clientRecoveryLabelFQN = clientRecoveryLabel.fullyQualifiedName(); - if (!clientRecoveryLabelMap.containsKey (clientRecoveryLabelFQN)) - { - clientRecoveryLabelMap.put ( - clientRecoveryLabelFQN, - clientRecoveryLabel - ); + if (!clientRecoveryLabelMap.containsKey (clientRecoveryLabelFQN)) { + clientRecoveryLabelMap.put (clientRecoveryLabelFQN, clientRecoveryLabel); } - org.drip.state.identifier.EntityRecoveryLabel dealerSubordinateRecoveryLabel = + EntityRecoveryLabel dealerSubordinateRecoveryLabel = creditDebtGroupEntry.getValue().dealerSubordinateRecoveryLabel(); - if (null != dealerSubordinateRecoveryLabel) - { - java.lang.String dealerSubordinateRecoveryLabelFQN = + if (null != dealerSubordinateRecoveryLabel) { + String dealerSubordinateRecoveryLabelFQN = dealerSubordinateRecoveryLabel.fullyQualifiedName(); - if (!dealerSubordinateRecoveryLabelMap.containsKey (dealerSubordinateRecoveryLabelFQN)) - { + if (!dealerSubordinateRecoveryLabelMap.containsKey (dealerSubordinateRecoveryLabelFQN)) { dealerSubordinateRecoveryLabelMap.put ( dealerSubordinateRecoveryLabelFQN, dealerSubordinateRecoveryLabel @@ -774,39 +649,29 @@ public org.drip.xva.topology.AdiabatMarketParams marketParams() } } - for (java.util.Map.Entry - collateralGroupMapEntry : collateralGroupMap.entrySet()) - { - org.drip.state.identifier.OvernightLabel overnightLabel = - collateralGroupMapEntry.getValue().overnightLabel(); + for (Map.Entry collateralGroupMapEntry : + collateralGroupMap.entrySet()) { + OvernightLabel overnightLabel = collateralGroupMapEntry.getValue().overnightLabel(); - java.lang.String overnightLabelFQN = overnightLabel.fullyQualifiedName(); + String overnightLabelFQN = overnightLabel.fullyQualifiedName(); - if (!overnightLabelMap.containsKey (overnightLabelFQN)) - { - overnightLabelMap.put ( - overnightLabelFQN, - overnightLabel - ); + if (!overnightLabelMap.containsKey (overnightLabelFQN)) { + overnightLabelMap.put (overnightLabelFQN, overnightLabel); } - org.drip.state.identifier.CSALabel csaLabel = - collateralGroupMapEntry.getValue().csaLabel(); - java.lang.String csaLabelFQN = csaLabel.fullyQualifiedName(); + CSALabel csaLabel = collateralGroupMapEntry.getValue().csaLabel(); - if (!csaLabelMap.containsKey (csaLabelFQN)) - { - csaLabelMap.put ( - csaLabelFQN, - csaLabel - ); + String csaLabelFQN = csaLabel.fullyQualifiedName(); + + if (!csaLabelMap.containsKey (csaLabelFQN)) { + csaLabelMap.put (csaLabelFQN, csaLabel); } } } } try { - return new org.drip.xva.topology.AdiabatMarketParams ( + return new AdiabatMarketParams ( overnightLabelMap, csaLabelMap, dealerHazardLabelMap, @@ -818,9 +683,7 @@ public org.drip.xva.topology.AdiabatMarketParams marketParams() clientFundingLabelMap, dealerSubordinateFundingLabelMap ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/org/drip/xva/topology/AdiabatMarketParams.java b/src/main/java/org/drip/xva/topology/AdiabatMarketParams.java index e1d679adf024..b412022b17c5 100644 --- a/src/main/java/org/drip/xva/topology/AdiabatMarketParams.java +++ b/src/main/java/org/drip/xva/topology/AdiabatMarketParams.java @@ -1,11 +1,22 @@ package org.drip.xva.topology; +import java.util.Map; + +import org.drip.state.identifier.CSALabel; +import org.drip.state.identifier.EntityFundingLabel; +import org.drip.state.identifier.EntityHazardLabel; +import org.drip.state.identifier.EntityRecoveryLabel; +import org.drip.state.identifier.OvernightLabel; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -119,25 +130,16 @@ public class AdiabatMarketParams { - private java.util.Map _csaLabelMap = null; - private java.util.Map _overnightLabelMap = - null; - private java.util.Map - _clientHazardLabelMap = null; - private java.util.Map - _dealerHazardLabelMap = null; - private java.util.Map - _clientRecoveryLabelMap = null; - private java.util.Map - _dealerSeniorRecoveryLabelMap = null; - private java.util.Map - _clientFundingLabelMap = null; - private java.util.Map - _dealerSubordinateRecoveryLabelMap = null; - private java.util.Map - _dealerSeniorFundingLabelMap = null; - private java.util.Map - _dealerSubordinateFundingLabelMap = null; + private Map _csaLabelMap = null; + private Map _overnightLabelMap = null; + private Map _clientHazardLabelMap = null; + private Map _dealerHazardLabelMap = null; + private Map _clientFundingLabelMap = null; + private Map _clientRecoveryLabelMap = null; + private Map _dealerSeniorFundingLabelMap = null; + private Map _dealerSeniorRecoveryLabelMap = null; + private Map _dealerSubordinateFundingLabelMap = null; + private Map _dealerSubordinateRecoveryLabelMap = null; /** * AdiabatMarketParams Constructor @@ -153,43 +155,34 @@ public class AdiabatMarketParams * @param clientFundingLabelMap Map of Client Funding Labels * @param dealerSubordinateFundingLabelMap Map of Dealer Subordinate Funding Labels * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public AdiabatMarketParams ( - final java.util.Map overnightLabelMap, - final java.util.Map csaLabelMap, - final java.util.Map - dealerHazardLabelMap, - final java.util.Map - clientHazardLabelMap, - final java.util.Map - dealerSeniorRecoveryLabelMap, - final java.util.Map - clientRecoveryLabelMap, - final java.util.Map - dealerSubordinateRecoveryLabelMap, - final java.util.Map - dealerSeniorFundingLabelMap, - final java.util.Map - clientFundingLabelMap, - final java.util.Map - dealerSubordinateFundingLabelMap) - throws java.lang.Exception + final Map overnightLabelMap, + final Map csaLabelMap, + final Map dealerHazardLabelMap, + final Map clientHazardLabelMap, + final Map dealerSeniorRecoveryLabelMap, + final Map clientRecoveryLabelMap, + final Map dealerSubordinateRecoveryLabelMap, + final Map dealerSeniorFundingLabelMap, + final Map clientFundingLabelMap, + final Map dealerSubordinateFundingLabelMap) + throws Exception { if (null == (_overnightLabelMap = overnightLabelMap) || 0 == _overnightLabelMap.size() || null == (_csaLabelMap = csaLabelMap) || 0 == _csaLabelMap.size() || null == (_dealerHazardLabelMap = dealerHazardLabelMap) || 0 == _dealerHazardLabelMap.size() || null == (_clientHazardLabelMap = clientHazardLabelMap) || 0 == _clientHazardLabelMap.size() || - null == (_dealerSeniorRecoveryLabelMap = dealerSeniorRecoveryLabelMap) || 0 == - _dealerSeniorRecoveryLabelMap.size() || - null == (_clientRecoveryLabelMap = clientRecoveryLabelMap) || 0 == _clientRecoveryLabelMap.size() - || - null == (_dealerSeniorFundingLabelMap = dealerSeniorFundingLabelMap) || 0 == - _dealerSeniorFundingLabelMap.size() || - null == (_clientFundingLabelMap = clientFundingLabelMap) || 0 == _clientFundingLabelMap.size()) - { - throw new java.lang.Exception ("AdiabatMarketParams Constructor => Invalid Inputs"); + null == (_dealerSeniorRecoveryLabelMap = dealerSeniorRecoveryLabelMap) || + 0 == _dealerSeniorRecoveryLabelMap.size() || + null == (_clientRecoveryLabelMap = clientRecoveryLabelMap) || + 0 == _clientRecoveryLabelMap.size() || + null == (_dealerSeniorFundingLabelMap = dealerSeniorFundingLabelMap) || + 0 == _dealerSeniorFundingLabelMap.size() || + null == (_clientFundingLabelMap = clientFundingLabelMap) || 0 == _clientFundingLabelMap.size()) { + throw new Exception ("AdiabatMarketParams Constructor => Invalid Inputs"); } _dealerSubordinateFundingLabelMap = dealerSubordinateFundingLabelMap; @@ -202,7 +195,7 @@ public AdiabatMarketParams ( * @return The Map of Overnight Labels */ - public java.util.Map overnightLabelMap() + public Map overnightLabelMap() { return _overnightLabelMap; } @@ -213,7 +206,7 @@ public java.util.Map * @return The Map of CSA Labels */ - public java.util.Map csaLabelMap() + public Map csaLabelMap() { return _csaLabelMap; } @@ -224,8 +217,7 @@ public java.util.Map csaLa * @return The Map of Dealer Hazard Labels */ - public java.util.Map - dealerHazardLabelMap() + public Map dealerHazardLabelMap() { return _dealerHazardLabelMap; } @@ -236,8 +228,7 @@ public java.util.Map csaLa * @return The Map of Client Hazard Labels */ - public java.util.Map - clientHazardLabelMap() + public Map clientHazardLabelMap() { return _clientHazardLabelMap; } @@ -248,8 +239,7 @@ public java.util.Map csaLa * @return The Map of Dealer Senior Recovery Labels */ - public java.util.Map - dealerSeniorRecoveryLabelMap() + public Map dealerSeniorRecoveryLabelMap() { return _dealerSeniorRecoveryLabelMap; } @@ -260,8 +250,7 @@ public java.util.Map csaLa * @return The Map of Client Recovery Labels */ - public java.util.Map - clientRecoveryLabelMap() + public Map clientRecoveryLabelMap() { return _clientRecoveryLabelMap; } @@ -272,8 +261,7 @@ public java.util.Map csaLa * @return The Map of Dealer Subordinate Recovery Labels */ - public java.util.Map - dealerSubordinateRecoveryLabelMap() + public Map dealerSubordinateRecoveryLabelMap() { return _dealerSubordinateRecoveryLabelMap; } @@ -284,8 +272,7 @@ public java.util.Map csaLa * @return The Map of Dealer Senior Funding Labels */ - public java.util.Map - dealerSeniorFundingLabelMap() + public Map dealerSeniorFundingLabelMap() { return _dealerSeniorFundingLabelMap; } @@ -296,8 +283,7 @@ public java.util.Map csaLa * @return The Map of Client Funding Labels */ - public java.util.Map - clientFundingLabelMap() + public Map clientFundingLabelMap() { return _clientFundingLabelMap; } @@ -308,8 +294,7 @@ public java.util.Map csaLa * @return The Map of Dealer Subordinate Funding Labels */ - public java.util.Map - dealerSubordinateFundingLabelMap() + public Map dealerSubordinateFundingLabelMap() { return _dealerSubordinateFundingLabelMap; } diff --git a/src/main/java/org/drip/xva/topology/CollateralGroup.java b/src/main/java/org/drip/xva/topology/CollateralGroup.java index dfff0fc68c3b..c61a3fc9549f 100644 --- a/src/main/java/org/drip/xva/topology/CollateralGroup.java +++ b/src/main/java/org/drip/xva/topology/CollateralGroup.java @@ -1,11 +1,22 @@ package org.drip.xva.topology; +import java.util.Map; + +import org.drip.analytics.support.CaseInsensitiveHashMap; +import org.drip.state.identifier.CSALabel; +import org.drip.state.identifier.OvernightLabel; +import org.drip.xva.proto.CollateralGroupSpecification; +import org.drip.xva.proto.ObjectSpecification; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,10 +128,10 @@ * @author Lakshmi Krishnamurthy */ -public class CollateralGroup extends org.drip.xva.proto.ObjectSpecification +public class CollateralGroup extends ObjectSpecification { - private org.drip.xva.proto.CollateralGroupSpecification _collateralGroupSpecification = null; - private java.util.Map _positionGroupMap = null; + private Map _positionGroupMap = null; + private CollateralGroupSpecification _collateralGroupSpecification = null; /** * CollateralGroup Constructor @@ -129,27 +140,22 @@ public class CollateralGroup extends org.drip.xva.proto.ObjectSpecification * @param name The Collateral Group Name * @param collateralGroupSpecification The Collateral Group Specification * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public CollateralGroup ( - final java.lang.String id, - final java.lang.String name, - final org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecification) - throws java.lang.Exception + final String id, + final String name, + final CollateralGroupSpecification collateralGroupSpecification) + throws Exception { - super ( - id, - name - ); - - if (null == (_collateralGroupSpecification = collateralGroupSpecification)) - { - throw new java.lang.Exception ("CollateralGroup Contructor => Invalid Inputs"); + super (id, name); + + if (null == (_collateralGroupSpecification = collateralGroupSpecification)) { + throw new Exception ("CollateralGroup Contructor => Invalid Inputs"); } - _positionGroupMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + _positionGroupMap = new CaseInsensitiveHashMap(); } /** @@ -158,7 +164,7 @@ public CollateralGroup ( * @return The Collateral Group Specification */ - public org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecification() + public CollateralGroupSpecification collateralGroupSpecification() { return _collateralGroupSpecification; } @@ -169,7 +175,7 @@ public org.drip.xva.proto.CollateralGroupSpecification collateralGroupSpecificat * @return The Position Group Map */ - public java.util.Map positionGroupMap() + public Map positionGroupMap() { return _positionGroupMap; } @@ -183,17 +189,13 @@ public java.util.Map posi */ public boolean addPositionGroup ( - final org.drip.xva.topology.PositionGroup positionGroup) + final PositionGroup positionGroup) { - if (null == positionGroup) - { + if (null == positionGroup) { return false; } - _positionGroupMap.put ( - positionGroup.id(), - positionGroup - ); + _positionGroupMap.put (positionGroup.id(), positionGroup); return true; } @@ -207,10 +209,9 @@ public boolean addPositionGroup ( */ public boolean containsPositionGroup ( - final java.lang.String positionGroupID) + final String positionGroupID) { - return null == positionGroupID || positionGroupID.isEmpty() ? false : _positionGroupMap.containsKey - (positionGroupID); + return null != positionGroupID && _positionGroupMap.containsKey (positionGroupID); } /** @@ -221,8 +222,8 @@ public boolean containsPositionGroup ( * @return The Position Group */ - public org.drip.xva.topology.PositionGroup positionGroup ( - final java.lang.String positionGroupID) + public PositionGroup positionGroup ( + final String positionGroupID) { return containsPositionGroup (positionGroupID) ? _positionGroupMap.get (positionGroupID) : null; } @@ -233,7 +234,7 @@ public org.drip.xva.topology.PositionGroup positionGroup ( * @return The Overnight Label */ - public org.drip.state.identifier.OvernightLabel overnightLabel() + public OvernightLabel overnightLabel() { return _collateralGroupSpecification.overnightLabel(); } @@ -244,7 +245,7 @@ public org.drip.state.identifier.OvernightLabel overnightLabel() * @return The CSA Label */ - public org.drip.state.identifier.CSALabel csaLabel() + public CSALabel csaLabel() { return _collateralGroupSpecification.csaLabel(); } diff --git a/src/main/java/org/drip/xva/topology/CreditDebtGroup.java b/src/main/java/org/drip/xva/topology/CreditDebtGroup.java index 6742ce7c25a6..9ec67f8d744c 100644 --- a/src/main/java/org/drip/xva/topology/CreditDebtGroup.java +++ b/src/main/java/org/drip/xva/topology/CreditDebtGroup.java @@ -1,11 +1,24 @@ package org.drip.xva.topology; +import java.util.Map; + +import org.drip.analytics.support.CaseInsensitiveHashMap; +import org.drip.state.identifier.CSALabel; +import org.drip.state.identifier.EntityHazardLabel; +import org.drip.state.identifier.EntityRecoveryLabel; +import org.drip.state.identifier.OvernightLabel; +import org.drip.xva.proto.CreditDebtGroupSpecification; +import org.drip.xva.proto.ObjectSpecification; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,11 +130,10 @@ * @author Lakshmi Krishnamurthy */ -public class CreditDebtGroup extends org.drip.xva.proto.ObjectSpecification +public class CreditDebtGroup extends ObjectSpecification { - private org.drip.xva.proto.CreditDebtGroupSpecification _creditDebtGroupSpecification = null; - private java.util.Map _collateralGroupMap = - null; + private Map _collateralGroupMap = null; + private CreditDebtGroupSpecification _creditDebtGroupSpecification = null; /** * CreditDebtGroup Constructor @@ -130,27 +142,22 @@ public class CreditDebtGroup extends org.drip.xva.proto.ObjectSpecification * @param name CreditDebtGroup Name * @param creditDebtGroupSpecification The CreditDebtGroup Specification * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public CreditDebtGroup ( - final java.lang.String id, - final java.lang.String name, - final org.drip.xva.proto.CreditDebtGroupSpecification creditDebtGroupSpecification) - throws java.lang.Exception + final String id, + final String name, + final CreditDebtGroupSpecification creditDebtGroupSpecification) + throws Exception { - super ( - id, - name - ); - - if (null == (_creditDebtGroupSpecification = creditDebtGroupSpecification)) - { - throw new java.lang.Exception ("CreditDebtGroup Constructor => Invalid Inputs"); + super (id, name); + + if (null == (_creditDebtGroupSpecification = creditDebtGroupSpecification)) { + throw new Exception ("CreditDebtGroup Constructor => Invalid Inputs"); } - _collateralGroupMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + _collateralGroupMap = new CaseInsensitiveHashMap(); } /** @@ -159,7 +166,7 @@ public CreditDebtGroup ( * @return The Credit Debt Group Specification */ - public org.drip.xva.proto.CreditDebtGroupSpecification creditDebtGroupSpecification() + public CreditDebtGroupSpecification creditDebtGroupSpecification() { return _creditDebtGroupSpecification; } @@ -170,7 +177,7 @@ public org.drip.xva.proto.CreditDebtGroupSpecification creditDebtGroupSpecificat * @return The Collateral Group Map */ - public java.util.Map collateralGroupMap() + public Map collateralGroupMap() { return _collateralGroupMap; } @@ -184,17 +191,13 @@ public java.util.Map co */ public boolean addCollateralGroup ( - final org.drip.xva.topology.CollateralGroup collateralGroup) + final CollateralGroup collateralGroup) { - if (null == collateralGroup) - { + if (null == collateralGroup) { return false; } - _collateralGroupMap.put ( - collateralGroup.id(), - collateralGroup - ); + _collateralGroupMap.put (collateralGroup.id(), collateralGroup); return true; } @@ -208,10 +211,9 @@ public boolean addCollateralGroup ( */ public boolean containsCollateralGroup ( - final java.lang.String collateralGroupID) + final String collateralGroupID) { - return null == collateralGroupID || collateralGroupID.isEmpty() ? false : - _collateralGroupMap.containsKey (collateralGroupID); + return null != collateralGroupID && _collateralGroupMap.containsKey (collateralGroupID); } /** @@ -222,11 +224,11 @@ public boolean containsCollateralGroup ( * @return The Collateral Group */ - public org.drip.xva.topology.CollateralGroup collateralGroup ( - final java.lang.String collateralGroupID) + public CollateralGroup collateralGroup ( + final String collateralGroupID) { - return containsCollateralGroup (collateralGroupID) ? _collateralGroupMap.get (collateralGroupID) : - null; + return containsCollateralGroup (collateralGroupID) ? + _collateralGroupMap.get (collateralGroupID) : null; } /** @@ -235,7 +237,7 @@ public org.drip.xva.topology.CollateralGroup collateralGroup ( * @return The Dealer Hazard Label */ - public org.drip.state.identifier.EntityHazardLabel dealerHazardLabel() + public EntityHazardLabel dealerHazardLabel() { return _creditDebtGroupSpecification.dealerHazardLabel(); } @@ -246,7 +248,7 @@ public org.drip.state.identifier.EntityHazardLabel dealerHazardLabel() * @return The Client Hazard Label */ - public org.drip.state.identifier.EntityHazardLabel clientPartyHazardLabel() + public EntityHazardLabel clientPartyHazardLabel() { return _creditDebtGroupSpecification.clientHazardLabel(); } @@ -257,7 +259,7 @@ public org.drip.state.identifier.EntityHazardLabel clientPartyHazardLabel() * @return The Dealer Senior Recovery Label */ - public org.drip.state.identifier.EntityRecoveryLabel dealerSeniorRecoveryLabel() + public EntityRecoveryLabel dealerSeniorRecoveryLabel() { return _creditDebtGroupSpecification.dealerSeniorRecoveryLabel(); } @@ -268,7 +270,7 @@ public org.drip.state.identifier.EntityRecoveryLabel dealerSeniorRecoveryLabel() * @return The Dealer Subordinate Recovery Label */ - public org.drip.state.identifier.EntityRecoveryLabel dealerSubordinateRecoveryLabel() + public EntityRecoveryLabel dealerSubordinateRecoveryLabel() { return _creditDebtGroupSpecification.dealerSubordinateRecoveryLabel(); } @@ -279,7 +281,7 @@ public org.drip.state.identifier.EntityRecoveryLabel dealerSubordinateRecoveryLa * @return The Client Senior Recovery Label */ - public org.drip.state.identifier.EntityRecoveryLabel clientRecoveryLabel() + public EntityRecoveryLabel clientRecoveryLabel() { return _creditDebtGroupSpecification.clientRecoveryLabel(); } @@ -290,25 +292,17 @@ public org.drip.state.identifier.EntityRecoveryLabel clientRecoveryLabel() * @return The Overnight Label Map */ - public java.util.Map overnightLabelMap() + public Map overnightLabelMap() { - java.util.Map overnightLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry - collateralGroupMapEntry : _collateralGroupMap.entrySet()) - { - org.drip.state.identifier.OvernightLabel overnightLabel = - collateralGroupMapEntry.getValue().overnightLabel(); - - java.lang.String overnightLabelFQN = overnightLabel.fullyQualifiedName(); - - if (!overnightLabelMap.containsKey (overnightLabelFQN)) - { - overnightLabelMap.put ( - overnightLabelFQN, - overnightLabel - ); + Map overnightLabelMap = new CaseInsensitiveHashMap(); + + for (Map.Entry collateralGroupMapEntry : _collateralGroupMap.entrySet()) { + OvernightLabel overnightLabel = collateralGroupMapEntry.getValue().overnightLabel(); + + String overnightLabelFQN = overnightLabel.fullyQualifiedName(); + + if (!overnightLabelMap.containsKey (overnightLabelFQN)) { + overnightLabelMap.put (overnightLabelFQN, overnightLabel); } } @@ -321,24 +315,17 @@ public java.util.Map * @return The CSA Label Map */ - public java.util.Map csaLabelMap() + public Map csaLabelMap() { - java.util.Map csaLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map csaLabelMap = new CaseInsensitiveHashMap(); - for (java.util.Map.Entry - collateralGroupMapEntry : _collateralGroupMap.entrySet()) - { + for (Map.Entry collateralGroupMapEntry : _collateralGroupMap.entrySet()) { org.drip.state.identifier.CSALabel csaLabel = collateralGroupMapEntry.getValue().csaLabel(); - java.lang.String csaLabelFQN = csaLabel.fullyQualifiedName(); + String csaLabelFQN = csaLabel.fullyQualifiedName(); - if (!csaLabelMap.containsKey (csaLabelFQN)) - { - csaLabelMap.put ( - csaLabelFQN, - csaLabel - ); + if (!csaLabelMap.containsKey (csaLabelFQN)) { + csaLabelMap.put (csaLabelFQN, csaLabel); } } diff --git a/src/main/java/org/drip/xva/topology/FundingGroup.java b/src/main/java/org/drip/xva/topology/FundingGroup.java index ac0916bb22d8..1675b3707b52 100644 --- a/src/main/java/org/drip/xva/topology/FundingGroup.java +++ b/src/main/java/org/drip/xva/topology/FundingGroup.java @@ -1,11 +1,25 @@ package org.drip.xva.topology; +import java.util.Map; + +import org.drip.analytics.support.CaseInsensitiveHashMap; +import org.drip.state.identifier.CSALabel; +import org.drip.state.identifier.EntityFundingLabel; +import org.drip.state.identifier.EntityHazardLabel; +import org.drip.state.identifier.EntityRecoveryLabel; +import org.drip.state.identifier.OvernightLabel; +import org.drip.xva.proto.FundingGroupSpecification; +import org.drip.xva.proto.ObjectSpecification; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -117,11 +131,10 @@ * @author Lakshmi Krishnamurthy */ -public class FundingGroup extends org.drip.xva.proto.ObjectSpecification +public class FundingGroup extends ObjectSpecification { - private org.drip.xva.proto.FundingGroupSpecification _fundingGroupSpecification = null; - private java.util.Map _creditDebtGroupMap = - null; + private Map _creditDebtGroupMap = null; + private FundingGroupSpecification _fundingGroupSpecification = null; /** * FundingGroup Constructor @@ -130,27 +143,22 @@ public class FundingGroup extends org.drip.xva.proto.ObjectSpecification * @param name FundingGroup Name * @param fundingGroupSpecification Funding Group Specification * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public FundingGroup ( - final java.lang.String id, - final java.lang.String name, - final org.drip.xva.proto.FundingGroupSpecification fundingGroupSpecification) - throws java.lang.Exception + final String id, + final String name, + final FundingGroupSpecification fundingGroupSpecification) + throws Exception { - super ( - id, - name - ); - - if (null == (_fundingGroupSpecification = fundingGroupSpecification)) - { - throw new java.lang.Exception ("FundingGroup Constructor => Invalid Inputs"); + super (id, name); + + if (null == (_fundingGroupSpecification = fundingGroupSpecification)) { + throw new Exception ("FundingGroup Constructor => Invalid Inputs"); } - _creditDebtGroupMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + _creditDebtGroupMap = new CaseInsensitiveHashMap(); } /** @@ -159,7 +167,7 @@ public FundingGroup ( * @return The Funding Group Specification */ - public org.drip.xva.proto.FundingGroupSpecification fundingGroupSpecification() + public FundingGroupSpecification fundingGroupSpecification() { return _fundingGroupSpecification; } @@ -170,7 +178,7 @@ public org.drip.xva.proto.FundingGroupSpecification fundingGroupSpecification() * @return The Credit Debt Group Map */ - public java.util.Map creditDebtGroupMap() + public Map creditDebtGroupMap() { return _creditDebtGroupMap; } @@ -184,17 +192,13 @@ public java.util.Map cr */ public boolean addCreditDebtGroup ( - final org.drip.xva.topology.CreditDebtGroup creditDebtGroup) + final CreditDebtGroup creditDebtGroup) { - if (null == creditDebtGroup) - { + if (null == creditDebtGroup) { return false; } - _creditDebtGroupMap.put ( - creditDebtGroup.id(), - creditDebtGroup - ); + _creditDebtGroupMap.put (creditDebtGroup.id(), creditDebtGroup); return true; } @@ -208,10 +212,9 @@ public boolean addCreditDebtGroup ( */ public boolean containsCreditDebtGroup ( - final java.lang.String creditDebtGroupID) + final String creditDebtGroupID) { - return null == creditDebtGroupID || creditDebtGroupID.isEmpty() ? false : - _creditDebtGroupMap.containsKey (creditDebtGroupID); + return null != creditDebtGroupID && _creditDebtGroupMap.containsKey (creditDebtGroupID); } /** @@ -222,8 +225,8 @@ public boolean containsCreditDebtGroup ( * @return The CreditDebtGroup Instance */ - public org.drip.xva.topology.CreditDebtGroup creditDebtGroup ( - final java.lang.String creditDebtGroupID) + public CreditDebtGroup creditDebtGroup ( + final String creditDebtGroupID) { return containsCreditDebtGroup (creditDebtGroupID) ? _creditDebtGroupMap.get (creditDebtGroupID) : null; @@ -235,7 +238,7 @@ public org.drip.xva.topology.CreditDebtGroup creditDebtGroup ( * @return The Dealer Senior Funding Label */ - public org.drip.state.identifier.EntityFundingLabel dealerSeniorFundingLabel() + public EntityFundingLabel dealerSeniorFundingLabel() { return _fundingGroupSpecification.dealerSeniorFundingLabel(); } @@ -246,7 +249,7 @@ public org.drip.state.identifier.EntityFundingLabel dealerSeniorFundingLabel() * @return The Client Funding Label */ - public org.drip.state.identifier.EntityFundingLabel clientFundingLabel() + public EntityFundingLabel clientFundingLabel() { return _fundingGroupSpecification.clientFundingLabel(); } @@ -257,7 +260,7 @@ public org.drip.state.identifier.EntityFundingLabel clientFundingLabel() * @return The Dealer Subordinate Funding Label */ - public org.drip.state.identifier.EntityFundingLabel dealerSubordinateFundingLabel() + public EntityFundingLabel dealerSubordinateFundingLabel() { return _fundingGroupSpecification.dealerSubordinateFundingLabel(); } @@ -268,31 +271,22 @@ public org.drip.state.identifier.EntityFundingLabel dealerSubordinateFundingLabe * @return The Overnight Label Map */ - public java.util.Map overnightLabelMap() + public Map overnightLabelMap() { - java.util.Map overnightLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map overnightLabelMap = new CaseInsensitiveHashMap(); - for (java.util.Map.Entry - creditDebtGroupEntry : _creditDebtGroupMap.entrySet()) - { - java.util.Map collateralGroupMap = + for (Map.Entry creditDebtGroupEntry : _creditDebtGroupMap.entrySet()) { + Map collateralGroupMap = creditDebtGroupEntry.getValue().collateralGroupMap(); - for (java.util.Map.Entry - collateralGroupMapEntry : collateralGroupMap.entrySet()) + for (Map.Entry collateralGroupMapEntry : collateralGroupMap.entrySet()) { - org.drip.state.identifier.OvernightLabel overnightLabel = - collateralGroupMapEntry.getValue().overnightLabel(); + OvernightLabel overnightLabel = collateralGroupMapEntry.getValue().overnightLabel(); - java.lang.String overnightLabelFQN = overnightLabel.fullyQualifiedName(); + String overnightLabelFQN = overnightLabel.fullyQualifiedName(); - if (!overnightLabelMap.containsKey (overnightLabelFQN)) - { - overnightLabelMap.put ( - overnightLabelFQN, - overnightLabel - ); + if (!overnightLabelMap.containsKey (overnightLabelFQN)) { + overnightLabelMap.put (overnightLabelFQN, overnightLabel); } } } @@ -306,30 +300,22 @@ public java.util.Map * @return The CSA Label Map */ - public java.util.Map csaLabelMap() + public Map csaLabelMap() { - java.util.Map csaLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map csaLabelMap = new CaseInsensitiveHashMap(); - for (java.util.Map.Entry - creditDebtGroupEntry : _creditDebtGroupMap.entrySet()) - { - java.util.Map collateralGroupMap = + for (Map.Entry creditDebtGroupEntry : _creditDebtGroupMap.entrySet()) { + Map collateralGroupMap = creditDebtGroupEntry.getValue().collateralGroupMap(); - for (java.util.Map.Entry - collateralGroupMapEntry : collateralGroupMap.entrySet()) + for (Map.Entry collateralGroupMapEntry : collateralGroupMap.entrySet()) { - org.drip.state.identifier.CSALabel csaLabel = collateralGroupMapEntry.getValue().csaLabel(); + CSALabel csaLabel = collateralGroupMapEntry.getValue().csaLabel(); - java.lang.String csaLabelFQN = csaLabel.fullyQualifiedName(); + String csaLabelFQN = csaLabel.fullyQualifiedName(); - if (!csaLabelMap.containsKey (csaLabelFQN)) - { - csaLabelMap.put ( - csaLabelFQN, - csaLabel - ); + if (!csaLabelMap.containsKey (csaLabelFQN)) { + csaLabelMap.put (csaLabelFQN, csaLabel); } } } @@ -343,26 +329,18 @@ public java.util.Map csaLa * @return The Dealer Hazard Label Map */ - public java.util.Map - dealerHazardLabelMap() + public Map dealerHazardLabelMap() { - java.util.Map dealerHazardLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); + Map dealerHazardLabelMap = + new CaseInsensitiveHashMap(); - for (java.util.Map.Entry - creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) - { - org.drip.state.identifier.EntityHazardLabel dealerHazardLabel = - creditDebtGroupMapEntry.getValue().dealerHazardLabel(); + for (Map.Entry creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) { + EntityHazardLabel dealerHazardLabel = creditDebtGroupMapEntry.getValue().dealerHazardLabel(); - java.lang.String dealerHazardLabelFQN = dealerHazardLabel.fullyQualifiedName(); + String dealerHazardLabelFQN = dealerHazardLabel.fullyQualifiedName(); - if (!dealerHazardLabelMap.containsKey (dealerHazardLabelFQN)) - { - dealerHazardLabelMap.put ( - dealerHazardLabelFQN, - dealerHazardLabel - ); + if (!dealerHazardLabelMap.containsKey (dealerHazardLabelFQN)) { + dealerHazardLabelMap.put (dealerHazardLabelFQN, dealerHazardLabel); } } @@ -375,26 +353,19 @@ public java.util.Map csaLa * @return The Client Hazard Label Map */ - public java.util.Map - clientHazardLabelMap() + public Map clientHazardLabelMap() { - java.util.Map clientHazardLabelMap = - new org.drip.analytics.support.CaseInsensitiveHashMap(); + Map clientHazardLabelMap = + new CaseInsensitiveHashMap(); - for (java.util.Map.Entry - creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) - { - org.drip.state.identifier.EntityHazardLabel clientHazardLabel = + for (Map.Entry creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) { + EntityHazardLabel clientHazardLabel = creditDebtGroupMapEntry.getValue().clientPartyHazardLabel(); - java.lang.String clientHazardLabelFQN = clientHazardLabel.fullyQualifiedName(); + String clientHazardLabelFQN = clientHazardLabel.fullyQualifiedName(); - if (!clientHazardLabelMap.containsKey (clientHazardLabelFQN)) - { - clientHazardLabelMap.put ( - clientHazardLabelFQN, - clientHazardLabel - ); + if (!clientHazardLabelMap.containsKey (clientHazardLabelFQN)) { + clientHazardLabelMap.put (clientHazardLabelFQN, clientHazardLabel); } } @@ -407,27 +378,19 @@ public java.util.Map csaLa * @return The Dealer Senior Recovery Label Map */ - public java.util.Map - dealerSeniorRecoveryLabelMap() + public Map dealerSeniorRecoveryLabelMap() { - java.util.Map - dealerSeniorRecoveryLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry - creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) - { - org.drip.state.identifier.EntityRecoveryLabel dealerSeniorRecoveryLabel = + Map dealerSeniorRecoveryLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) { + EntityRecoveryLabel dealerSeniorRecoveryLabel = creditDebtGroupMapEntry.getValue().dealerSeniorRecoveryLabel(); - java.lang.String dealerSeniorRecoveryLabelFQN = dealerSeniorRecoveryLabel.fullyQualifiedName(); + String dealerSeniorRecoveryLabelFQN = dealerSeniorRecoveryLabel.fullyQualifiedName(); - if (!dealerSeniorRecoveryLabelMap.containsKey (dealerSeniorRecoveryLabelFQN)) - { - dealerSeniorRecoveryLabelMap.put ( - dealerSeniorRecoveryLabelFQN, - dealerSeniorRecoveryLabel - ); + if (!dealerSeniorRecoveryLabelMap.containsKey (dealerSeniorRecoveryLabelFQN)) { + dealerSeniorRecoveryLabelMap.put (dealerSeniorRecoveryLabelFQN, dealerSeniorRecoveryLabel); } } @@ -440,27 +403,19 @@ public java.util.Map csaLa * @return The Client Recovery Label Map */ - public java.util.Map - clientRecoveryLabelMap() + public Map clientRecoveryLabelMap() { - java.util.Map clientRecoveryLabelMap - = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry - creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) - { - org.drip.state.identifier.EntityRecoveryLabel clientRecoveryLabel = + Map clientRecoveryLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) { + EntityRecoveryLabel clientRecoveryLabel = creditDebtGroupMapEntry.getValue().clientRecoveryLabel(); - java.lang.String clientRecoveryLabelFQN = clientRecoveryLabel.fullyQualifiedName(); + String clientRecoveryLabelFQN = clientRecoveryLabel.fullyQualifiedName(); - if (!clientRecoveryLabelMap.containsKey (clientRecoveryLabelFQN)) - { - clientRecoveryLabelMap.put ( - clientRecoveryLabelFQN, - clientRecoveryLabel - ); + if (!clientRecoveryLabelMap.containsKey (clientRecoveryLabelFQN)) { + clientRecoveryLabelMap.put (clientRecoveryLabelFQN, clientRecoveryLabel); } } @@ -473,26 +428,20 @@ public java.util.Map csaLa * @return The Dealer Subordinate Recovery Label Map */ - public java.util.Map - dealerSubordinateRecoveryLabelMap() + public Map dealerSubordinateRecoveryLabelMap() { - java.util.Map - dealerSubordinateRecoveryLabelMap = new - org.drip.analytics.support.CaseInsensitiveHashMap(); - - for (java.util.Map.Entry - creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) - { - org.drip.state.identifier.EntityRecoveryLabel dealerSubordinateRecoveryLabel = + Map dealerSubordinateRecoveryLabelMap = + new CaseInsensitiveHashMap(); + + for (Map.Entry creditDebtGroupMapEntry : _creditDebtGroupMap.entrySet()) { + EntityRecoveryLabel dealerSubordinateRecoveryLabel = creditDebtGroupMapEntry.getValue().dealerSubordinateRecoveryLabel(); - if (null != dealerSubordinateRecoveryLabel) - { - java.lang.String dealerSubordinateRecoveryLabelFQN = + if (null != dealerSubordinateRecoveryLabel) { + String dealerSubordinateRecoveryLabelFQN = dealerSubordinateRecoveryLabel.fullyQualifiedName(); - if (!dealerSubordinateRecoveryLabelMap.containsKey (dealerSubordinateRecoveryLabelFQN)) - { + if (!dealerSubordinateRecoveryLabelMap.containsKey (dealerSubordinateRecoveryLabelFQN)) { dealerSubordinateRecoveryLabelMap.put ( dealerSubordinateRecoveryLabelFQN, dealerSubordinateRecoveryLabel diff --git a/src/main/java/org/drip/xva/vertex/AlbaneseAndersen.java b/src/main/java/org/drip/xva/vertex/AlbaneseAndersen.java index 27b1afc282fe..1e4357054e4e 100644 --- a/src/main/java/org/drip/xva/vertex/AlbaneseAndersen.java +++ b/src/main/java/org/drip/xva/vertex/AlbaneseAndersen.java @@ -1,11 +1,17 @@ package org.drip.xva.vertex; +import org.drip.analytics.date.JulianDate; +import org.drip.xva.hypothecation.CollateralGroupVertex; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -118,7 +124,7 @@ * @author Lakshmi Krishnamurthy */ -public class AlbaneseAndersen extends org.drip.xva.hypothecation.CollateralGroupVertex +public class AlbaneseAndersen extends CollateralGroupVertex { /** @@ -129,22 +135,17 @@ public class AlbaneseAndersen extends org.drip.xva.hypothecation.CollateralGroup * @param tradePayment The Trade Payment at the Path Vertex Time Node * @param variationMarginPosting The Variation Margin Posting at the Path Vertex Time Node * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public AlbaneseAndersen ( - final org.drip.analytics.date.JulianDate vertexDate, + final JulianDate vertexDate, final double variationMarginEstimate, final double tradePayment, final double variationMarginPosting) - throws java.lang.Exception + throws Exception { - super ( - vertexDate, - variationMarginEstimate, - tradePayment, - variationMarginPosting - ); + super (vertexDate, variationMarginEstimate, tradePayment, variationMarginPosting); } @Override public double credit() diff --git a/src/main/java/org/drip/xva/vertex/BurgardKjaer.java b/src/main/java/org/drip/xva/vertex/BurgardKjaer.java index 1b9554233931..55399974c931 100644 --- a/src/main/java/org/drip/xva/vertex/BurgardKjaer.java +++ b/src/main/java/org/drip/xva/vertex/BurgardKjaer.java @@ -1,11 +1,19 @@ package org.drip.xva.vertex; +import org.drip.analytics.date.JulianDate; +import org.drip.xva.derivative.ReplicationPortfolioVertexDealer; +import org.drip.xva.hypothecation.CollateralGroupVertex; +import org.drip.xva.hypothecation.CollateralGroupVertexCloseOut; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -118,11 +126,11 @@ * @author Lakshmi Krishnamurthy */ -public class BurgardKjaer extends org.drip.xva.hypothecation.CollateralGroupVertex +public class BurgardKjaer extends CollateralGroupVertex { - private org.drip.xva.vertex.BurgardKjaerExposure _burgardKjaerVertexExposure = null; - private org.drip.xva.hypothecation.CollateralGroupVertexCloseOut _collateralGroupCloseOut = null; - private org.drip.xva.derivative.ReplicationPortfolioVertexDealer _dealerReplicationPortfolioVertex = null; + private BurgardKjaerExposure _burgardKjaerVertexExposure = null; + private CollateralGroupVertexCloseOut _collateralGroupCloseOut = null; + private ReplicationPortfolioVertexDealer _dealerReplicationPortfolioVertex = null; /** * BurgardKjaer Constructor @@ -134,30 +142,24 @@ public class BurgardKjaer extends org.drip.xva.hypothecation.CollateralGroupVert * @param collateralGroupCloseOut The Collateral Group Vertex Close Out Instance * @param dealerReplicationPortfolioVertex The Dealer Replication Portfolio Vertex Instance * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public BurgardKjaer ( - final org.drip.analytics.date.JulianDate anchorDate, + final JulianDate anchorDate, final double forward, final double accrued, - final org.drip.xva.vertex.BurgardKjaerExposure burgardKjaerVertexExposure, - final org.drip.xva.hypothecation.CollateralGroupVertexCloseOut collateralGroupCloseOut, - final org.drip.xva.derivative.ReplicationPortfolioVertexDealer dealerReplicationPortfolioVertex) - throws java.lang.Exception + final BurgardKjaerExposure burgardKjaerVertexExposure, + final CollateralGroupVertexCloseOut collateralGroupCloseOut, + final ReplicationPortfolioVertexDealer dealerReplicationPortfolioVertex) + throws Exception { - super ( - anchorDate, - forward, - accrued, - burgardKjaerVertexExposure.variationMarginPosting() - ); + super (anchorDate, forward, accrued, burgardKjaerVertexExposure.variationMarginPosting()); if (null == (_burgardKjaerVertexExposure = burgardKjaerVertexExposure) || null == (_collateralGroupCloseOut = collateralGroupCloseOut) || - null == (_dealerReplicationPortfolioVertex = dealerReplicationPortfolioVertex)) - { - throw new java.lang.Exception ("BurgardKjaer Constructor => Invalid Inputs"); + null == (_dealerReplicationPortfolioVertex = dealerReplicationPortfolioVertex)) { + throw new Exception ("BurgardKjaer Constructor => Invalid Inputs"); } } @@ -215,7 +217,7 @@ public double hedgeError() * @return The Dealer Replication Potrfolio Instance */ - public org.drip.xva.derivative.ReplicationPortfolioVertexDealer dealerReplicationPortfolio() + public ReplicationPortfolioVertexDealer dealerReplicationPortfolio() { return _dealerReplicationPortfolioVertex; } diff --git a/src/main/java/org/drip/xva/vertex/BurgardKjaerBuilder.java b/src/main/java/org/drip/xva/vertex/BurgardKjaerBuilder.java index 5e104ddf57d6..4c68fd68208c 100644 --- a/src/main/java/org/drip/xva/vertex/BurgardKjaerBuilder.java +++ b/src/main/java/org/drip/xva/vertex/BurgardKjaerBuilder.java @@ -1,11 +1,24 @@ package org.drip.xva.vertex; +import org.drip.analytics.date.JulianDate; +import org.drip.exposure.universe.MarketEdge; +import org.drip.exposure.universe.MarketVertex; +import org.drip.exposure.universe.MarketVertexEntity; +import org.drip.numerical.common.NumberUtil; +import org.drip.xva.definition.CloseOut; +import org.drip.xva.derivative.ReplicationPortfolioVertexDealer; +import org.drip.xva.hypothecation.CollateralGroupVertexCloseOut; +import org.drip.xva.hypothecation.CollateralGroupVertexExposure; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -132,32 +145,23 @@ public class BurgardKjaerBuilder * @return The Burgard Kjaer Dealer Portfolio Vertex */ - public static final org.drip.xva.vertex.BurgardKjaer Initial ( - final org.drip.analytics.date.JulianDate anchorDate, + public static final BurgardKjaer Initial ( + final JulianDate anchorDate, final double forward, - final org.drip.exposure.universe.MarketVertex marketVertex, - final org.drip.xva.definition.CloseOut closeOutScheme) + final MarketVertex marketVertex, + final CloseOut closeOutScheme) { - if (null == marketVertex) - { + if (null == marketVertex) { return null; } - org.drip.xva.hypothecation.CollateralGroupVertexCloseOut collateralGroupVertexCloseOut = - org.drip.xva.hypothecation.CollateralGroupVertexCloseOut.Standard ( - closeOutScheme, - forward, - 0. - ); + CollateralGroupVertexCloseOut collateralGroupVertexCloseOut = + CollateralGroupVertexCloseOut.Standard (closeOutScheme, forward, 0.); - org.drip.xva.vertex.BurgardKjaerExposure burgardKjaerVertexExposure = - org.drip.xva.vertex.BurgardKjaerExposure.Initial ( - forward, - collateralGroupVertexCloseOut - ); + BurgardKjaerExposure burgardKjaerVertexExposure = + BurgardKjaerExposure.Initial (forward, collateralGroupVertexCloseOut); - if (null == burgardKjaerVertexExposure) - { + if (null == burgardKjaerVertexExposure) { return null; } @@ -165,7 +169,7 @@ public static final org.drip.xva.vertex.BurgardKjaer Initial ( double dealerDefaultCloseOut = collateralGroupVertexCloseOut.dealer(); - org.drip.exposure.universe.MarketVertexEntity dealerMarketVertex = marketVertex.dealer(); + MarketVertexEntity dealerMarketVertex = marketVertex.dealer(); double dealerSubordinateFundingMarketVertex = dealerMarketVertex.subordinateFundingReplicator(); @@ -186,24 +190,21 @@ public static final org.drip.xva.vertex.BurgardKjaer Initial ( dealerSurvival * clientSurvival * marketVertex.csaSpread() * burgardKjaerVertexExposure.variationMarginPosting(); - try - { - return new org.drip.xva.vertex.BurgardKjaer ( + try { + return new BurgardKjaer ( anchorDate, forward, 0., burgardKjaerVertexExposure, collateralGroupVertexCloseOut, - new org.drip.xva.derivative.ReplicationPortfolioVertexDealer ( + new ReplicationPortfolioVertexDealer ( (fundingExposure + dealerSubordinateRecoveryRate * adjustedExposure - dealerDefaultCloseOut) / (dealerSeniorRecoveryRate - dealerSubordinateRecoveryRate) / dealerMarketVertex.seniorFundingReplicator(), (fundingExposure + dealerSeniorRecoveryRate * adjustedExposure - dealerDefaultCloseOut) / (dealerSubordinateRecoveryRate - dealerSeniorRecoveryRate) / dealerSubordinateFundingMarketVertex ) ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -222,18 +223,15 @@ public static final org.drip.xva.vertex.BurgardKjaer Initial ( * @return The Burgard Kjaer Dealer Portfolio Vertex */ - public static final org.drip.xva.vertex.BurgardKjaer DealerPortfolioBuilder ( - final org.drip.analytics.date.JulianDate anchorDate, - final org.drip.xva.hypothecation.CollateralGroupVertexExposure collateralGroupVertexExposure, - final org.drip.exposure.universe.MarketEdge marketEdge, - final org.drip.xva.hypothecation.CollateralGroupVertexCloseOut collateralGroupVertexCloseOut, - final org.drip.xva.vertex.BurgardKjaerExposure burgardKjaerVertexExposure) + public static final BurgardKjaer DealerPortfolioBuilder ( + final JulianDate anchorDate, + final CollateralGroupVertexExposure collateralGroupVertexExposure, + final MarketEdge marketEdge, + final CollateralGroupVertexCloseOut collateralGroupVertexCloseOut, + final BurgardKjaerExposure burgardKjaerVertexExposure) { - if (null == collateralGroupVertexExposure || - null == marketEdge || - null == collateralGroupVertexCloseOut || - null == burgardKjaerVertexExposure) - { + if (null == collateralGroupVertexExposure || null == marketEdge || + null == collateralGroupVertexCloseOut || null == burgardKjaerVertexExposure) { return null; } @@ -241,13 +239,14 @@ public static final org.drip.xva.vertex.BurgardKjaer DealerPortfolioBuilder ( double dealerDefaultCloseOut = collateralGroupVertexCloseOut.dealer(); - org.drip.exposure.universe.MarketVertex marketVertexStart = marketEdge.start(); + MarketVertex marketVertexStart = marketEdge.start(); - org.drip.exposure.universe.MarketVertex marketVertexFinish = marketEdge.finish(); + MarketVertex marketVertexFinish = marketEdge.finish(); - org.drip.exposure.universe.MarketVertexEntity dealerMarketVertexFinish = marketVertexFinish.dealer(); + MarketVertexEntity dealerMarketVertexFinish = marketVertexFinish.dealer(); - double dealerSubordinateFundingMarketVertexFinish = dealerMarketVertexFinish.subordinateFundingReplicator(); + double dealerSubordinateFundingMarketVertexFinish = + dealerMarketVertexFinish.subordinateFundingReplicator(); double dealerSurvivalFinish = dealerMarketVertexFinish.survivalProbability(); @@ -257,29 +256,28 @@ public static final org.drip.xva.vertex.BurgardKjaer DealerPortfolioBuilder ( double clientSurvivalFinish = marketVertexFinish.client().survivalProbability(); - double incrementalDealerSurvival = dealerSurvivalFinish - - (null == marketVertexStart ? 1. : marketVertexStart.dealer().survivalProbability()); + double incrementalDealerSurvival = dealerSurvivalFinish - ( + null == marketVertexStart ? 1. : marketVertexStart.dealer().survivalProbability() + ); - double adjustedExposure = - collateralGroupVertexExposure.uncollateralized() + - dealerSurvivalFinish * - (clientSurvivalFinish - - (null == marketVertexStart ? 1. : marketVertexStart.client().survivalProbability())) * - burgardKjaerVertexExposure.credit() + + double adjustedExposure = collateralGroupVertexExposure.uncollateralized() + dealerSurvivalFinish * ( + clientSurvivalFinish - ( + null == marketVertexStart ? 1. : marketVertexStart.client().survivalProbability() + ) + ) * burgardKjaerVertexExposure.credit() + clientSurvivalFinish * incrementalDealerSurvival * burgardKjaerVertexExposure.debt() + clientSurvivalFinish * incrementalDealerSurvival * fundingExposure - dealerSurvivalFinish * clientSurvivalFinish * marketVertexFinish.csaSpread() * burgardKjaerVertexExposure.variationMarginPosting(); - try - { - return new org.drip.xva.vertex.BurgardKjaer ( + try { + return new BurgardKjaer ( anchorDate, collateralGroupVertexExposure.variationMarginEstimate(), collateralGroupVertexExposure.tradePayment(), burgardKjaerVertexExposure, collateralGroupVertexCloseOut, - new org.drip.xva.derivative.ReplicationPortfolioVertexDealer ( + new ReplicationPortfolioVertexDealer ( (fundingExposure + dealerSubordinateRecoveryRateFinish * adjustedExposure - dealerDefaultCloseOut) / (dealerSeniorRecoveryRateFinish - dealerSubordinateRecoveryRateFinish) / @@ -289,9 +287,7 @@ public static final org.drip.xva.vertex.BurgardKjaer DealerPortfolioBuilder ( dealerSubordinateFundingMarketVertexFinish ) ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -314,58 +310,47 @@ public static final org.drip.xva.vertex.BurgardKjaer DealerPortfolioBuilder ( * Bonds */ - public static final org.drip.xva.vertex.BurgardKjaer HedgeErrorDualBond ( - final org.drip.analytics.date.JulianDate anchorDate, + public static final BurgardKjaer HedgeErrorDualBond ( + final JulianDate anchorDate, final double exposure, final double realizedCashFlow, final double collateralBalance, final double hedgeError, - final org.drip.exposure.universe.MarketEdge marketEdge, - final org.drip.xva.definition.CloseOut closeOutScheme) + final MarketEdge marketEdge, + final CloseOut closeOutScheme) { - if (!org.drip.numerical.common.NumberUtil.IsValid (exposure) || - !org.drip.numerical.common.NumberUtil.IsValid (realizedCashFlow) || - !org.drip.numerical.common.NumberUtil.IsValid (collateralBalance) || - !org.drip.numerical.common.NumberUtil.IsValid (hedgeError)) - { + if (!NumberUtil.IsValid (exposure) || !NumberUtil.IsValid (realizedCashFlow) || + !NumberUtil.IsValid (collateralBalance) || !NumberUtil.IsValid (hedgeError)) { return null; } double uncollateralizedExposure = exposure + realizedCashFlow; double collateralizedExposure = uncollateralizedExposure - collateralBalance; - org.drip.xva.hypothecation.CollateralGroupVertexCloseOut collateralGroupVertexCloseOut = - org.drip.xva.hypothecation.CollateralGroupVertexCloseOut.Standard ( - closeOutScheme, + CollateralGroupVertexCloseOut collateralGroupVertexCloseOut = + CollateralGroupVertexCloseOut.Standard (closeOutScheme, uncollateralizedExposure, collateralBalance ); - if (null == collateralGroupVertexCloseOut) - { + if (null == collateralGroupVertexCloseOut) { return null; } - try - { + try { return DealerPortfolioBuilder ( anchorDate, - new org.drip.xva.hypothecation.CollateralGroupVertexExposure ( - exposure, - realizedCashFlow - ), + new CollateralGroupVertexExposure (exposure, realizedCashFlow), marketEdge, collateralGroupVertexCloseOut, - new org.drip.xva.vertex.BurgardKjaerExposure ( + new BurgardKjaerExposure ( collateralizedExposure - collateralGroupVertexCloseOut.client(), collateralizedExposure - collateralGroupVertexCloseOut.dealer(), hedgeError, collateralBalance ) ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -387,34 +372,28 @@ public static final org.drip.xva.vertex.BurgardKjaer HedgeErrorDualBond ( * Default using Two Bonds */ - public static final org.drip.xva.vertex.BurgardKjaer SemiReplicationDualBond ( + public static final BurgardKjaer SemiReplicationDualBond ( final org.drip.analytics.date.JulianDate anchorDate, final double exposure, final double realizedCashFlow, final double collateralBalance, - final org.drip.exposure.universe.MarketEdge marketEdge, - final org.drip.xva.definition.CloseOut closeOutScheme) + final MarketEdge marketEdge, + final CloseOut closeOutScheme) { - if (!org.drip.numerical.common.NumberUtil.IsValid (exposure) || - !org.drip.numerical.common.NumberUtil.IsValid (realizedCashFlow) || - !org.drip.numerical.common.NumberUtil.IsValid (collateralBalance)) - { + if (!NumberUtil.IsValid (exposure) || !NumberUtil.IsValid (realizedCashFlow) || + !NumberUtil.IsValid (collateralBalance)) { return null; } double uncollateralizedExposure = exposure + realizedCashFlow; double collateralizedExposure = uncollateralizedExposure - collateralBalance; - try - { + try { return DealerPortfolioBuilder ( anchorDate, - new org.drip.xva.hypothecation.CollateralGroupVertexExposure ( - exposure, - realizedCashFlow - ), + new CollateralGroupVertexExposure (exposure, realizedCashFlow), marketEdge, - org.drip.xva.hypothecation.CollateralGroupVertexCloseOut.Standard ( + CollateralGroupVertexCloseOut.Standard ( closeOutScheme, uncollateralizedExposure, collateralBalance @@ -426,9 +405,7 @@ public static final org.drip.xva.vertex.BurgardKjaer SemiReplicationDualBond ( collateralBalance ) ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -448,45 +425,32 @@ public static final org.drip.xva.vertex.BurgardKjaer SemiReplicationDualBond ( * @return The Standard Instance of BurgardKjaerVertex using using a Fully Collateralized Strategy */ - public static final org.drip.xva.vertex.BurgardKjaer GoldPlatedTwoWayCSA ( + public static final BurgardKjaer GoldPlatedTwoWayCSA ( final org.drip.analytics.date.JulianDate anchorDate, final double exposure, final double realizedCashFlow, - final org.drip.exposure.universe.MarketEdge marketEdge, - final org.drip.xva.definition.CloseOut closeOutScheme) + final MarketEdge marketEdge, + final CloseOut closeOutScheme) { - if (!org.drip.numerical.common.NumberUtil.IsValid (exposure) || - !org.drip.numerical.common.NumberUtil.IsValid (realizedCashFlow)) - { + if (!NumberUtil.IsValid (exposure) || !NumberUtil.IsValid (realizedCashFlow)) { return null; } double uncollateralizedExposure = exposure + realizedCashFlow; - try - { + try { return DealerPortfolioBuilder ( anchorDate, - new org.drip.xva.hypothecation.CollateralGroupVertexExposure ( - exposure, - realizedCashFlow - ), + new CollateralGroupVertexExposure (exposure, realizedCashFlow), marketEdge, - org.drip.xva.hypothecation.CollateralGroupVertexCloseOut.Standard ( + CollateralGroupVertexCloseOut.Standard ( closeOutScheme, uncollateralizedExposure, uncollateralizedExposure ), - new org.drip.xva.vertex.BurgardKjaerExposure ( - 0., - 0., - 0., - uncollateralizedExposure - ) + new BurgardKjaerExposure (0., 0., 0., uncollateralizedExposure) ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -505,46 +469,38 @@ public static final org.drip.xva.vertex.BurgardKjaer GoldPlatedTwoWayCSA ( * @return The Standard Instance of BurgardKjaerVertex using One Way CSA */ - public static final org.drip.xva.vertex.BurgardKjaer OneWayCSA ( - final org.drip.analytics.date.JulianDate anchorDate, + public static final BurgardKjaer OneWayCSA ( + final JulianDate anchorDate, final double exposure, final double realizedCashFlow, - final org.drip.exposure.universe.MarketEdge marketEdge, - final org.drip.xva.definition.CloseOut closeOutScheme) + final MarketEdge marketEdge, + final CloseOut closeOutScheme) { - if (!org.drip.numerical.common.NumberUtil.IsValid (exposure) || - !org.drip.numerical.common.NumberUtil.IsValid (realizedCashFlow)) - { + if (!NumberUtil.IsValid (exposure) || !NumberUtil.IsValid (realizedCashFlow)) { return null; } double uncollateralizedExposure = exposure + realizedCashFlow; double collateralBalance = 0. > uncollateralizedExposure ? uncollateralizedExposure : 0.; - try - { + try { return DealerPortfolioBuilder ( anchorDate, - new org.drip.xva.hypothecation.CollateralGroupVertexExposure ( - exposure, - realizedCashFlow - ), + new CollateralGroupVertexExposure (exposure, realizedCashFlow), marketEdge, - org.drip.xva.hypothecation.CollateralGroupVertexCloseOut.Standard ( + CollateralGroupVertexCloseOut.Standard ( closeOutScheme, uncollateralizedExposure, collateralBalance ), - new org.drip.xva.vertex.BurgardKjaerExposure ( + new BurgardKjaerExposure ( 0. < uncollateralizedExposure ? uncollateralizedExposure : 0., 0., 0. < uncollateralizedExposure ? uncollateralizedExposure : 0., collateralBalance ) ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -563,21 +519,19 @@ public static final org.drip.xva.vertex.BurgardKjaer OneWayCSA ( * @return The Standard Instance of BurgardKjaerVertex using the "Set Off" Legal Agreement Scheme */ - public static final org.drip.xva.vertex.BurgardKjaer SetOff ( - final org.drip.analytics.date.JulianDate anchorDate, + public static final BurgardKjaer SetOff ( + final JulianDate anchorDate, final double exposure, final double realizedCashFlow, final double collateralBalance, - final org.drip.exposure.universe.MarketEdge marketEdge) + final MarketEdge marketEdge) { - if (!org.drip.numerical.common.NumberUtil.IsValid (exposure) || - !org.drip.numerical.common.NumberUtil.IsValid (realizedCashFlow) || - !org.drip.numerical.common.NumberUtil.IsValid (collateralBalance)) - { + if (!NumberUtil.IsValid (exposure) || !NumberUtil.IsValid (realizedCashFlow) || + !NumberUtil.IsValid (collateralBalance)) { return null; } - org.drip.exposure.universe.MarketVertex marketVertexFinish = marketEdge.finish(); + MarketVertex marketVertexFinish = marketEdge.finish(); double dealerSeniorRecoveryRateFinish = marketVertexFinish.dealer().seniorRecoveryRate(); @@ -585,29 +539,23 @@ public static final org.drip.xva.vertex.BurgardKjaer SetOff ( double collateralizedExposure = exposure + realizedCashFlow - collateralBalance; - try - { + try { return DealerPortfolioBuilder ( anchorDate, - new org.drip.xva.hypothecation.CollateralGroupVertexExposure ( - exposure, - realizedCashFlow - ), + new CollateralGroupVertexExposure (exposure, realizedCashFlow), marketEdge, - new org.drip.xva.hypothecation.CollateralGroupVertexCloseOut ( + new CollateralGroupVertexCloseOut ( collateralizedExposure * dealerSeniorRecoveryRateFinish, collateralizedExposure * clientRecoveryFinish ), - new org.drip.xva.vertex.BurgardKjaerExposure ( + new BurgardKjaerExposure ( collateralizedExposure * (1. - clientRecoveryFinish), collateralizedExposure * (1. - dealerSeniorRecoveryRateFinish), 0., collateralBalance ) ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/org/drip/xva/vertex/BurgardKjaerExposure.java b/src/main/java/org/drip/xva/vertex/BurgardKjaerExposure.java index bb1012b0a04f..9907c3d040c0 100644 --- a/src/main/java/org/drip/xva/vertex/BurgardKjaerExposure.java +++ b/src/main/java/org/drip/xva/vertex/BurgardKjaerExposure.java @@ -1,11 +1,18 @@ package org.drip.xva.vertex; +import org.drip.numerical.common.NumberUtil; +import org.drip.xva.hypothecation.CollateralGroupVertexCloseOut; +import org.drip.xva.hypothecation.CollateralGroupVertexExposureComponent; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -119,12 +126,12 @@ * @author Lakshmi Krishnamurthy */ -public class BurgardKjaerExposure implements org.drip.xva.hypothecation.CollateralGroupVertexExposureComponent +public class BurgardKjaerExposure implements CollateralGroupVertexExposureComponent { - private double _debt = java.lang.Double.NaN; - private double _credit = java.lang.Double.NaN; - private double _funding = java.lang.Double.NaN; - private double _collateralBalance = java.lang.Double.NaN; + private double _debt = Double.NaN; + private double _credit = Double.NaN; + private double _funding = Double.NaN; + private double _collateralBalance = Double.NaN; /** * Generate an Initial Instance of Burgard Kjaer Vertex Exposure @@ -137,11 +144,9 @@ public class BurgardKjaerExposure implements org.drip.xva.hypothecation.Collater public static final BurgardKjaerExposure Initial ( final double uncollateralizedExposure, - final org.drip.xva.hypothecation.CollateralGroupVertexCloseOut collateralGroupVertexCloseOut) + final CollateralGroupVertexCloseOut collateralGroupVertexCloseOut) { - if (!org.drip.numerical.common.NumberUtil.IsValid (uncollateralizedExposure) || - null == collateralGroupVertexCloseOut) - { + if (!NumberUtil.IsValid (uncollateralizedExposure) || null == collateralGroupVertexCloseOut) { return null; } @@ -153,9 +158,7 @@ public static final BurgardKjaerExposure Initial ( 0., 0. ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -170,7 +173,7 @@ public static final BurgardKjaerExposure Initial ( * @param funding The Funding Exposure of the Collateral Group * @param collateralBalance The Collateral Balance of the Collateral Group * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public BurgardKjaerExposure ( @@ -178,14 +181,12 @@ public BurgardKjaerExposure ( final double debt, final double funding, final double collateralBalance) - throws java.lang.Exception + throws Exception { - if (!org.drip.numerical.common.NumberUtil.IsValid (_credit = credit) || - !org.drip.numerical.common.NumberUtil.IsValid (_debt = debt) || - !org.drip.numerical.common.NumberUtil.IsValid (_funding = funding) || - !org.drip.numerical.common.NumberUtil.IsValid (_collateralBalance = collateralBalance)) - { - throw new java.lang.Exception ("BurgardKjaerExposure Constructor => Invalid Inputs"); + if (!NumberUtil.IsValid (_credit = credit) || !NumberUtil.IsValid (_debt = debt) || + !NumberUtil.IsValid (_funding = funding) || + !NumberUtil.IsValid (_collateralBalance = collateralBalance)) { + throw new Exception ("BurgardKjaerExposure Constructor => Invalid Inputs"); } }