Example #1
0
        private static Decimal CalculateThresholdFactor(Currency calculationCurrency, FxRatesProvider ratesProvider, SensitivityRisk risk, SensitivityCategory category, List <Sensitivity> sensitivities)
        {
            if ((risk == SensitivityRisk.Rates) && (category == SensitivityCategory.Delta))
            {
                sensitivities = sensitivities.Where(x => x.Subrisk != SensitivitySubrisk.CrossCurrencyBasis).ToList();

                if (sensitivities.Count == 0)
                {
                    return(1m);
                }
            }

            Amount sum = Amount.Abs(Amount.Sum(sensitivities.Select(x => x.Amount), calculationCurrency));

            IThresholdIdentifier thresholdIdentifier = sensitivities.Select(y => y.ThresholdIdentifier).Distinct().Single();
            Amount threshold = ratesProvider.Convert(ModelParameters.GetThreshold(risk, category, thresholdIdentifier), calculationCurrency);

            return(Math.Max(1m, MathUtilities.SquareRoot((sum / threshold).Value)));
        }