private static Amount CalculateCorrelatedSumWeights(Currency calculationCurrency, SensitivityRisk risk, List <MarginWeighting> weightingMargins, Dictionary <String, Decimal> thresholdFactors) { Amount sum = Amount.OfZero(calculationCurrency); foreach (MarginWeighting marginWeighting1 in weightingMargins) { foreach (MarginWeighting marginWeighting2 in weightingMargins) { Sensitivity sensitivity1 = marginWeighting1.Sensitivity; Sensitivity sensitivity2 = marginWeighting2.Sensitivity; if (sensitivity1 != sensitivity2) { Decimal thresholdFactor1 = thresholdFactors[sensitivity1.Qualifier]; Decimal thresholdFactor2 = thresholdFactors[sensitivity2.Qualifier]; Decimal concentration = Math.Min(thresholdFactor1, thresholdFactor2) / Math.Max(thresholdFactor1, thresholdFactor2); Decimal correlationSensitivity = ModelParameters.GetCorrelationSensitivity(risk, sensitivity1, sensitivity2); Decimal correlation = correlationSensitivity * concentration; sum += marginWeighting1.Value * marginWeighting2.Value * correlation; } } } return(sum); }
private static Amount CalculateCorrelatedSumWeights(Currency calculationCurrency, SensitivityRisk risk, List <MarginWeighting> weightingMargins) { Amount sum = Amount.OfZero(calculationCurrency); foreach (MarginWeighting marginWeighting1 in weightingMargins) { foreach (MarginWeighting marginWeighting2 in weightingMargins) { Sensitivity sensitivity1 = marginWeighting1.Sensitivity; Sensitivity sensitivity2 = marginWeighting2.Sensitivity; if (sensitivity1 != sensitivity2) { Decimal correlation = MathUtilities.Square(ModelParameters.GetCorrelationSensitivity(risk, sensitivity1, sensitivity2)); sum += marginWeighting1.Value * marginWeighting2.Value * correlation; } } } return(sum); }