Esempio n. 1
0
        // modified sensitivity function - CombinedCurve involved
        private CurrencyParameterSensitivities sensiCombinedFnBond(ImmutableLegalEntityDiscountingProvider provider)
        {
            CurrencyParameterSensitivities sensi = CurrencyParameterSensitivities.empty();
            double sum = sumCombine(provider);
            // repo curves
            ImmutableMap <Pair <RepoGroup, Currency>, DiscountFactors> mapCurrency = provider.RepoCurves;

            foreach (KeyValuePair <Pair <RepoGroup, Currency>, DiscountFactors> entry in mapCurrency.entrySet())
            {
                CombinedCurve          curveComb      = (CombinedCurve)getCurve(entry.Value);
                InterpolatedNodalCurve baseCurveInt   = checkInterpolated(curveComb.BaseCurve);
                InterpolatedNodalCurve spreadCurveInt = checkInterpolated(curveComb.SpreadCurve);
                sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(baseCurveInt.Name, USD, DoubleArray.of(baseCurveInt.ParameterCount, i => 2d * sum * baseCurveInt.XValues.get(i))));
                sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(spreadCurveInt.Name, USD, DoubleArray.of(spreadCurveInt.ParameterCount, i => 2d * sum * spreadCurveInt.XValues.get(i))));
            }
            // issuer curves
            ImmutableMap <Pair <LegalEntityGroup, Currency>, DiscountFactors> mapIndex = provider.IssuerCurves;

            foreach (KeyValuePair <Pair <LegalEntityGroup, Currency>, DiscountFactors> entry in mapIndex.entrySet())
            {
                CombinedCurve          curveComb      = (CombinedCurve)getCurve(entry.Value);
                InterpolatedNodalCurve baseCurveInt   = checkInterpolated(curveComb.BaseCurve);
                InterpolatedNodalCurve spreadCurveInt = checkInterpolated(curveComb.SpreadCurve);
                sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(baseCurveInt.Name, USD, DoubleArray.of(baseCurveInt.ParameterCount, i => 2d * sum * baseCurveInt.XValues.get(i))));
                sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(spreadCurveInt.Name, USD, DoubleArray.of(spreadCurveInt.ParameterCount, i => 2d * sum * spreadCurveInt.XValues.get(i))));
            }
            return(sensi);
        }
Esempio n. 2
0
        private double sumCombine(ImmutableLegalEntityDiscountingProvider provider)
        {
            double result = 0d;
            // repo curves
            ImmutableMap <Pair <RepoGroup, Currency>, DiscountFactors> mapCurrency = provider.RepoCurves;

            foreach (KeyValuePair <Pair <RepoGroup, Currency>, DiscountFactors> entry in mapCurrency.entrySet())
            {
                CombinedCurve curve = (CombinedCurve)getCurve(entry.Value);
                result += sumSingle((InterpolatedNodalCurve)curve.split().get(0));
                result += sumSingle((InterpolatedNodalCurve)curve.split().get(1));
            }
            // issuer curves
            ImmutableMap <Pair <LegalEntityGroup, Currency>, DiscountFactors> mapIndex = provider.IssuerCurves;

            foreach (KeyValuePair <Pair <LegalEntityGroup, Currency>, DiscountFactors> entry in mapIndex.entrySet())
            {
                CombinedCurve curve = (CombinedCurve)getCurve(entry.Value);
                result += sumSingle((InterpolatedNodalCurve)curve.split().get(0));
                result += sumSingle((InterpolatedNodalCurve)curve.split().get(1));
            }
            return(result);
        }
Esempio n. 3
0
        // modified sensitivity function - CombinedCurve involved
        private CurrencyParameterSensitivities sensiCombinedFn(ImmutableRatesProvider provider)
        {
            CurrencyParameterSensitivities sensi = CurrencyParameterSensitivities.empty();
            double sum = sumCombine(provider);
            // Currency
            ImmutableMap <Currency, Curve> mapCurrency = provider.DiscountCurves;

            foreach (KeyValuePair <Currency, Curve> entry in mapCurrency.entrySet())
            {
                CombinedCurve          curveComb      = (CombinedCurve)entry.Value;
                InterpolatedNodalCurve baseCurveInt   = checkInterpolated(curveComb.BaseCurve);
                InterpolatedNodalCurve spreadCurveInt = checkInterpolated(curveComb.SpreadCurve);
                sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(baseCurveInt.Name, USD, DoubleArray.of(baseCurveInt.ParameterCount, i => 2d * sum * baseCurveInt.XValues.get(i))));
                sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(spreadCurveInt.Name, USD, DoubleArray.of(spreadCurveInt.ParameterCount, i => 2d * sum * spreadCurveInt.XValues.get(i))));
            }
            // Index
            ImmutableMap <Index, Curve> mapIndex = provider.IndexCurves;

            foreach (KeyValuePair <Index, Curve> entry in mapIndex.entrySet())
            {
                if (entry.Value is CombinedCurve)
                {
                    CombinedCurve          curveComb      = (CombinedCurve)entry.Value;
                    InterpolatedNodalCurve baseCurveInt   = checkInterpolated(curveComb.BaseCurve);
                    InterpolatedNodalCurve spreadCurveInt = checkInterpolated(curveComb.SpreadCurve);
                    sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(baseCurveInt.Name, USD, DoubleArray.of(baseCurveInt.ParameterCount, i => 2d * sum * baseCurveInt.XValues.get(i))));
                    sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(spreadCurveInt.Name, USD, DoubleArray.of(spreadCurveInt.ParameterCount, i => 2d * sum * spreadCurveInt.XValues.get(i))));
                }
                else
                {
                    InterpolatedNodalCurve curveInt = checkInterpolated(entry.Value);
                    sensi = sensi.combinedWith(CurrencyParameterSensitivity.of(curveInt.Name, USD, DoubleArray.of(curveInt.ParameterCount, i => 2d * sum * curveInt.XValues.get(i))));
                }
            }
            return(sensi);
        }
Esempio n. 4
0
        public static ImmutableLegalEntityDiscountingProvider multiBondCombined(LocalDate valDate)
        {
            ImmutableMap <Pair <RepoGroup, Currency>, DiscountFactors>        repoCurves   = ImmutableMap.of(Pair.of(US_REPO_GROUP, USD), DiscountFactors.of(USD, valDate, CombinedCurve.of(USD_L3_BASE, US_REPO_CURVE)));
            ImmutableMap <Pair <LegalEntityGroup, Currency>, DiscountFactors> issuerCurves = ImmutableMap.of(Pair.of(US_ISSUER_1_GROUP, USD), DiscountFactors.of(USD, valDate, CombinedCurve.of(USD_L3_BASE, US_ISSUER_CURVE_1)), Pair.of(US_ISSUER_2_GROUP, USD), DiscountFactors.of(USD, valDate, CombinedCurve.of(USD_L3_BASE, US_ISSUER_CURVE_2)));

            ImmutableMap <LegalEntityId, RepoGroup>        repoGroups        = ImmutableMap.of(US_ISSUER_1_ID, US_REPO_GROUP, US_ISSUER_2_ID, US_REPO_GROUP, US_ISSUER_3_ID, US_REPO_GROUP);
            ImmutableMap <LegalEntityId, LegalEntityGroup> legalEntityGroups = ImmutableMap.of(US_ISSUER_1_ID, US_ISSUER_1_GROUP, US_ISSUER_2_ID, US_ISSUER_2_GROUP, US_ISSUER_3_ID, US_ISSUER_2_GROUP);

            return(ImmutableLegalEntityDiscountingProvider.builder().valuationDate(valDate).repoCurves(repoCurves).repoCurveGroups(repoGroups).issuerCurves(issuerCurves).issuerCurveGroups(legalEntityGroups).build());
        }