Beispiel #1
0
        static CalibrationDiscountingSimpleEurStdTenorsTest()
        {
            for (int i = 0; i < DSC_NB_OIS_NODES; i++)
            {
                DSC_NODES[i] = FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(DSC_OIS_TENORS[i]), EUR_FIXED_1Y_EONIA_OIS), QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])));
            }
            for (int i = 0; i < FWD3_NB_IRS_NODES; i++)
            {
                FWD3_NODES[i] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(FWD3_IRS_TENORS[i]), EUR_FIXED_1Y_EURIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i])));
            }
            for (int i = 0; i < FWD6_NB_IRS_NODES; i++)
            {
                FWD6_NODES[i] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(FWD6_IRS_TENORS[i]), EUR_FIXED_1Y_EURIBOR_6M), QuoteId.of(StandardId.of(SCHEME, FWD6_ID_VALUE[i])));
            }
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE);

            for (int i = 0; i < DSC_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])), DSC_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < FWD3_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i])), FWD3_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < FWD6_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, FWD6_ID_VALUE[i])), FWD6_MARKET_QUOTES[i]);
            }
            ALL_QUOTES = builder.build();
        }
Beispiel #2
0
        /// <summary>
        /// Test that inputs are correctly built from market data.
        /// </summary>
        public virtual void build()
        {
            FraCurveNode node1x4 = fraNode(1, "a");
            FraCurveNode node2x5 = fraNode(2, "b");
            FraCurveNode node3x6 = fraNode(3, "c");

            InterpolatedNodalCurveDefinition curveDefn = InterpolatedNodalCurveDefinition.builder().name(CurveName.of("curve")).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(DayCounts.ACT_ACT_ISDA).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).nodes(node1x4, node2x5, node3x6).build();

            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("curve group")).addDiscountCurve(curveDefn, Currency.USD).build();

            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupDefn.Name, groupDefn).build();

            QuoteId idA = QuoteId.of(StandardId.of("test", "a"));
            QuoteId idB = QuoteId.of(StandardId.of("test", "b"));
            QuoteId idC = QuoteId.of(StandardId.of("test", "c"));

            ScenarioMarketData marketData = ImmutableScenarioMarketData.builder(VAL_DATE).addValue(idA, 1d).addValue(idB, 2d).addValue(idC, 3d).build();

            RatesCurveInputsMarketDataFunction marketDataFunction = new RatesCurveInputsMarketDataFunction();
            RatesCurveInputsId curveInputsId        = RatesCurveInputsId.of(groupDefn.Name, curveDefn.Name, ObservableSource.NONE);
            MarketDataBox <RatesCurveInputs> result = marketDataFunction.build(curveInputsId, marketDataConfig, marketData, REF_DATA);

            RatesCurveInputs curveInputs = result.SingleValue;

            assertThat(curveInputs.MarketData.get(idA)).isEqualTo(1d);
            assertThat(curveInputs.MarketData.get(idB)).isEqualTo(2d);
            assertThat(curveInputs.MarketData.get(idC)).isEqualTo(3d);

            IList <ParameterMetadata> expectedMetadata = ImmutableList.of(node1x4.metadata(VAL_DATE, REF_DATA), node2x5.metadata(VAL_DATE, REF_DATA), node3x6.metadata(VAL_DATE, REF_DATA));

            assertThat(curveInputs.CurveMetadata.ParameterMetadata).hasValue(expectedMetadata);
        }
        internal static FixedIborSwapCurveNode fixedIborSwapNode(Tenor tenor, string id)
        {
            QuoteId quoteId = QuoteId.of(StandardId.of(TEST_SCHEME, id));
            FixedIborSwapTemplate template = FixedIborSwapTemplate.of(Period.ZERO, tenor, SWAP_CONVENTION);

            return(FixedIborSwapCurveNode.of(template, quoteId));
        }
Beispiel #4
0
        //-------------------------------------------------------------------------
        private static FraCurveNode fraNode(int startTenor, string marketDataId)
        {
            Period      periodToStart = Period.ofMonths(startTenor);
            FraTemplate template      = FraTemplate.of(periodToStart, IborIndices.USD_LIBOR_3M);

            return(FraCurveNode.of(template, QuoteId.of(StandardId.of("test", marketDataId))));
        }
Beispiel #5
0
        static CalibrationDiscountingSimple1Test()
        {
            IBOR_INDICES.Add(USD_LIBOR_3M);
            DSC_NAMES[ALL_CURVE_NAME] = USD;
            IDX_NAMES[ALL_CURVE_NAME] = IBOR_INDICES;
            ALL_NODES[0] = IborFixingDepositCurveNode.of(IborFixingDepositTemplate.of(USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[0])));
            for (int i = 0; i < FWD3_NB_FRA_NODES; i++)
            {
                ALL_NODES[i + 1] = FraCurveNode.of(FraTemplate.of(FWD3_FRA_TENORS[i], USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[1])));
            }
            for (int i = 0; i < FWD3_NB_IRS_NODES; i++)
            {
                ALL_NODES[i + 1 + FWD3_NB_FRA_NODES] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(FWD3_IRS_TENORS[i]), USD_FIXED_6M_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i])));
            }
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE);

            for (int i = 0; i < FWD3_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i])), FWD3_MARKET_QUOTES[i]);
            }
            ALL_QUOTES = builder.build();
            IList <CurveNode[]> groupNodes = new List <CurveNode[]>();

            groupNodes.Add(ALL_NODES);
            CURVES_NODES.Add(groupNodes);
            IList <CurveMetadata> groupMetadata = new List <CurveMetadata>();

            groupMetadata.Add(DefaultCurveMetadata.builder().curveName(ALL_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).build());
            CURVES_METADATA.Add(groupMetadata);
        }
        internal static FraCurveNode fraNode(int startMonths, string id)
        {
            Period  periodToStart = Period.ofMonths(startMonths);
            QuoteId quoteId       = QuoteId.of(StandardId.of(TEST_SCHEME, id));

            return(FraCurveNode.of(FraTemplate.of(periodToStart, IborIndices.USD_LIBOR_3M), quoteId));
        }
Beispiel #7
0
        static IsdaCompliantIndexCurveCalibratorTest()
        {
            ImmutableList.Builder <StandardId> legalEntityIdsbuilder = ImmutableList.builder();
            ImmutableMarketDataBuilder         marketDataBuilder     = ImmutableMarketData.builder(VALUATION_DATE);
            ImmutableMarketDataBuilder         marketDataPsBuilder   = ImmutableMarketData.builder(VALUATION_DATE);

            for (int?i = 0; i.Value < INDEX_SIZE; ++i)
            {
                StandardId             legalEntityId = StandardId.of("OG", "ABC" + i.ToString());
                LegalEntityInformation information   = DEFAULTED_NAMES.contains(i) ? LegalEntityInformation.isDefaulted(legalEntityId) : LegalEntityInformation.isNotDefaulted(legalEntityId);
                legalEntityIdsbuilder.add(legalEntityId);
                marketDataBuilder.addValue(LegalEntityInformationId.of(legalEntityId), information);
                marketDataPsBuilder.addValue(LegalEntityInformationId.of(legalEntityId), information);
            }
            LEGAL_ENTITIES = legalEntityIdsbuilder.build();
            ImmutableList.Builder <CdsIndexIsdaCreditCurveNode> curveNodesBuilder   = ImmutableList.builder();
            ImmutableList.Builder <CdsIndexIsdaCreditCurveNode> curveNodesPsBuilder = ImmutableList.builder();
            for (int i = 0; i < NUM_PILLARS; ++i)
            {
                QuoteId     id   = QuoteId.of(StandardId.of("OG", INDEX_TENORS[i].ToString()));
                CdsTemplate temp = TenorCdsTemplate.of(INDEX_TENORS[i], CONVENTION);
                curveNodesBuilder.add(CdsIndexIsdaCreditCurveNode.ofPointsUpfront(temp, id, INDEX_ID, LEGAL_ENTITIES, COUPON));
                curveNodesPsBuilder.add(CdsIndexIsdaCreditCurveNode.ofParSpread(temp, id, INDEX_ID, LEGAL_ENTITIES));
                marketDataBuilder.addValue(id, PUF_QUOTES[i]);
                marketDataPsBuilder.addValue(id, PS_QUOTES[i]);
            }
            CURVE_NODES    = curveNodesBuilder.build();
            MARKET_DATA    = marketDataBuilder.build();
            CURVE_NODES_PS = curveNodesPsBuilder.build();
            MARKET_DATA_PS = marketDataPsBuilder.build();
        }
        static CalibrationDiscountingSmithWilsonTest()
        {
            IBOR_INDICES.Add(GBP_LIBOR_6M);
            DSC_NAMES[CURVE_NAME] = GBP;
            IDX_NAMES[CURVE_NAME] = IBOR_INDICES;
            for (int i = 0; i < FWD6_NB_NODES; i++)
            {
                ALL_NODES[i]  = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(FWD6_IRS_TENORS[i]), GBP_FIXED_6M_LIBOR_6M), QuoteId.of(StandardId.of(SCHEME, FWD6_ID_VALUE[i])));
                NODE_TIMES[i] = CURVE_DC.relativeYearFraction(VAL_DATE, ALL_NODES[i].date(VAL_DATE, REF_DATA));
            }
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE);

            for (int i = 0; i < FWD6_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, FWD6_ID_VALUE[i])), FWD6_MARKET_QUOTES[i]);
            }
            ALL_QUOTES = builder.build();
            IList <CurveNode[]> groupNodes = new List <CurveNode[]>();

            groupNodes.Add(ALL_NODES);
            CURVES_NODES.Add(groupNodes);
            IList <CurveMetadata> groupMetadata = new List <CurveMetadata>();

            groupMetadata.Add(DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).dayCount(CURVE_DC).build());
            CURVES_METADATA.Add(groupMetadata);
        }
Beispiel #9
0
        //-------------------------------------------------------------------------
        // loads a single curves CSV file
        // requestedDate can be null, meaning load all dates
        private static IList <CurveDefinition> parseSingle(CharSource resource, IDictionary <CurveName, LoadedCurveSettings> settingsMap)
        {
            CsvFile csv = CsvFile.of(resource, true);
            IDictionary <CurveName, IList <CurveNode> > allNodes = new Dictionary <CurveName, IList <CurveNode> >();

            foreach (CsvRow row in csv.rows())
            {
                string curveNameStr      = row.getField(CURVE_NAME);
                string label             = row.getField(CURVE_LABEL);
                string symbologyQuoteStr = row.getField(CURVE_SYMBOLOGY_QUOTE);
                string tickerQuoteStr    = row.getField(CURVE_TICKER_QUOTE);
                string fieldQuoteStr     = row.getField(CURVE_FIELD_QUOTE);
                string typeStr           = row.getField(CURVE_TYPE);
                string conventionStr     = row.getField(CURVE_CONVENTION);
                string timeStr           = row.getField(CURVE_TIME);
                string dateStr           = row.findField(CURVE_DATE).orElse("");
                string minGapStr         = row.findField(CURVE_MIN_GAP).orElse("");
                string clashActionStr    = row.findField(CURVE_CLASH_ACTION).orElse("");
                string spreadStr         = row.findField(CURVE_SPREAD).orElse("");

                CurveName          curveName       = CurveName.of(curveNameStr);
                StandardId         quoteStandardId = StandardId.of(symbologyQuoteStr, tickerQuoteStr);
                FieldName          quoteField      = fieldQuoteStr.Length == 0 ? FieldName.MARKET_VALUE : FieldName.of(fieldQuoteStr);
                QuoteId            quoteId         = QuoteId.of(quoteStandardId, quoteField);
                double             spread          = spreadStr.Length == 0 ? 0d : double.Parse(spreadStr);
                CurveNodeDate      date            = parseDate(dateStr);
                CurveNodeDateOrder order           = parseDateOrder(minGapStr, clashActionStr);

                IList <CurveNode> curveNodes = allNodes.computeIfAbsent(curveName, k => new List <CurveNode>());
                curveNodes.Add(createCurveNode(typeStr, conventionStr, timeStr, label, quoteId, spread, date, order));
            }
            return(buildCurveDefinition(settingsMap, allNodes));
        }
Beispiel #10
0
        static CalibrationZeroRateUsdEur2OisFxTest()
        {
            DSC_NAMES[USD_DSCON_CURVE_NAME] = USD;
            ISet <Index> usdFedFundSet = new HashSet <Index>();

            usdFedFundSet.Add(USD_FED_FUND);
            IDX_NAMES[USD_DSCON_CURVE_NAME] = usdFedFundSet;
            USD_DSC_NODES[0] = TermDepositCurveNode.of(TermDepositTemplate.of(Period.ofDays(1), USD_SHORT_DEPOSIT_T0), QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[0])));
            USD_DSC_NODES[1] = TermDepositCurveNode.of(TermDepositTemplate.of(Period.ofDays(1), USD_SHORT_DEPOSIT_T1), QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[1])));
            for (int i = 0; i < USD_DSC_NB_OIS_NODES; i++)
            {
                USD_DSC_NODES[USD_DSC_NB_DEPO_NODES + i] = FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(USD_DSC_OIS_TENORS[i]), USD_FIXED_1Y_FED_FUND_OIS), QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[USD_DSC_NB_DEPO_NODES + i])));
            }
            for (int i = 0; i < EUR_DSC_NB_FX_NODES; i++)
            {
                EUR_DSC_NODES[i] = FxSwapCurveNode.of(FxSwapTemplate.of(EUR_DSC_FX_TENORS[i], EUR_USD), QuoteId.of(StandardId.of(SCHEME, EUR_DSC_ID_VALUE[i])));
            }
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE);

            for (int i = 0; i < USD_DSC_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[i])), USD_DSC_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < EUR_DSC_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, EUR_DSC_ID_VALUE[i])), EUR_DSC_MARKET_QUOTES[i]);
            }
            builder.addValue(FxRateId.of(EUR, USD), FX_RATE_EUR_USD);
            ALL_QUOTES = builder.build();
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(SecurityTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            Security security = refData.getValue(trade.SecurityId);
            QuoteId  id       = QuoteId.of(trade.SecurityId.StandardId);

            return(FunctionRequirements.builder().valueRequirements(ImmutableSet.of(id)).outputCurrencies(security.Currency).build());
        }
Beispiel #12
0
        // loads a single CSV file, filtering by date
        private static void parseSingle(System.Predicate <LocalDate> datePredicate, CharSource resource, IDictionary <LocalDate, ImmutableMap.Builder <QuoteId, double> > mutableMap)
        {
            try
            {
                CsvFile csv = CsvFile.of(resource, true);
                foreach (CsvRow row in csv.rows())
                {
                    string    dateText = row.getField(DATE_FIELD);
                    LocalDate date     = LoaderUtils.parseDate(dateText);
                    if (datePredicate(date))
                    {
                        string symbologyStr = row.getField(SYMBOLOGY_FIELD);
                        string tickerStr    = row.getField(TICKER_FIELD);
                        string fieldNameStr = row.getField(FIELD_NAME_FIELD);
                        string valueStr     = row.getField(VALUE_FIELD);

                        double     value     = Convert.ToDouble(valueStr);
                        StandardId id        = StandardId.of(symbologyStr, tickerStr);
                        FieldName  fieldName = fieldNameStr.Length == 0 ? FieldName.MARKET_VALUE : FieldName.of(fieldNameStr);

                        ImmutableMap.Builder <QuoteId, double> builderForDate = mutableMap.computeIfAbsent(date, k => ImmutableMap.builder());
                        builderForDate.put(QuoteId.of(id, fieldName), value);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new System.ArgumentException(Messages.format("Error processing resource as CSV file: {}", resource), ex);
            }
        }
        static CalibrationZeroRateAndDiscountFactorUsd2OisIrsTest()
        {
            DSC_NAMES[DSCON_CURVE_NAME] = USD;
            ISet <Index> usdFedFundSet = new HashSet <Index>();

            usdFedFundSet.Add(USD_FED_FUND);
            IDX_NAMES[DSCON_CURVE_NAME] = usdFedFundSet;
            ISet <Index> usdLibor3Set = new HashSet <Index>();

            usdLibor3Set.Add(USD_LIBOR_3M);
            IDX_NAMES[FWD3_CURVE_NAME] = usdLibor3Set;
            double fixingValue = 0.002345;
            LocalDateDoubleTimeSeries tsBdUsdLibor3M = LocalDateDoubleTimeSeries.builder().put(VAL_DATE_BD, fixingValue).build();
            LocalDate fixingDateHo = LocalDate.of(2015, 12, 24);
            LocalDateDoubleTimeSeries tsHoUsdLibor3M = LocalDateDoubleTimeSeries.builder().put(fixingDateHo, fixingValue).build();

            TS_BD_LIBOR3M = ImmutableMarketData.builder(VAL_DATE_BD).addTimeSeries(IndexQuoteId.of(USD_LIBOR_3M), tsBdUsdLibor3M).build();
            TS_HO_LIBOR3M = ImmutableMarketData.builder(VAL_DATE_HO).addTimeSeries(IndexQuoteId.of(USD_LIBOR_3M), tsHoUsdLibor3M).build();
            for (int i = 0; i < DSC_NB_OIS_NODES; i++)
            {
                DSC_NODES[i] = FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(DSC_OIS_TENORS[i]), USD_FIXED_1Y_FED_FUND_OIS), QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])));
            }
            FWD3_NODES[0] = IborFixingDepositCurveNode.of(IborFixingDepositTemplate.of(USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[0])));
            for (int i = 0; i < FWD3_NB_FRA_NODES; i++)
            {
                FWD3_NODES[i + 1] = FraCurveNode.of(FraTemplate.of(FWD3_FRA_TENORS[i], USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i + 1])));
            }
            for (int i = 0; i < FWD3_NB_IRS_NODES; i++)
            {
                FWD3_NODES[i + 1 + FWD3_NB_FRA_NODES] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(FWD3_IRS_TENORS[i]), USD_FIXED_6M_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i + 1 + FWD3_NB_FRA_NODES])));
            }
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE_BD);

            for (int i = 0; i < FWD3_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i])), FWD3_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < DSC_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])), DSC_MARKET_QUOTES[i]);
            }
            ALL_QUOTES_BD = builder.build();
            IList <CurveNode[]> groupDsc = new List <CurveNode[]>();

            groupDsc.Add(DSC_NODES);
            CURVES_NODES.Add(groupDsc);
            IList <CurveNode[]> groupFwd3 = new List <CurveNode[]>();

            groupFwd3.Add(FWD3_NODES);
            CURVES_NODES.Add(groupFwd3);
            IList <CurveMetadata> groupDsc = new List <CurveMetadata>();

            groupDsc.Add(DefaultCurveMetadata.builder().curveName(DSCON_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).build());
            CURVES_METADATA.Add(groupDsc);
            IList <CurveMetadata> groupFwd3 = new List <CurveMetadata>();

            groupFwd3.Add(DefaultCurveMetadata.builder().curveName(FWD3_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).build());
            CURVES_METADATA.Add(groupFwd3);
        }
        static CalibrationZeroRateUsdOisIrsEurFxXCcyIrsTest()
        {
            USD_DSC_NODES[0] = TermDepositCurveNode.of(TermDepositTemplate.of(Period.ofDays(1), USD_SHORT_DEPOSIT_T0), QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[0])));
            USD_DSC_NODES[1] = TermDepositCurveNode.of(TermDepositTemplate.of(Period.ofDays(1), USD_SHORT_DEPOSIT_T1), QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[1])));
            for (int i = 0; i < USD_DSC_NB_OIS_NODES; i++)
            {
                USD_DSC_NODES[2 + i] = FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(USD_DSC_OIS_TENORS[i]), USD_FIXED_1Y_FED_FUND_OIS), QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[2 + i])));
            }
            USD_FWD3_NODES[0] = IborFixingDepositCurveNode.of(IborFixingDepositTemplate.of(USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, USD_FWD3_ID_VALUE[0])));
            for (int i = 0; i < USD_FWD3_NB_FRA_NODES; i++)
            {
                USD_FWD3_NODES[i + 1] = FraCurveNode.of(FraTemplate.of(USD_FWD3_FRA_TENORS[i], USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, USD_FWD3_ID_VALUE[i + 1])));
            }
            for (int i = 0; i < USD_FWD3_NB_IRS_NODES; i++)
            {
                USD_FWD3_NODES[i + 1 + USD_FWD3_NB_FRA_NODES] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(USD_FWD3_IRS_TENORS[i]), USD_FIXED_6M_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, USD_FWD3_ID_VALUE[i + 1 + USD_FWD3_NB_FRA_NODES])));
            }
            for (int i = 0; i < EUR_DSC_NB_FX_NODES; i++)
            {
                EUR_DSC_NODES[i] = FxSwapCurveNode.of(FxSwapTemplate.of(EUR_DSC_FX_TENORS[i], EUR_USD), QuoteId.of(StandardId.of(SCHEME, EUR_DSC_ID_VALUE[i])));
            }
            for (int i = 0; i < EUR_DSC_NB_XCCY_NODES; i++)
            {
                EUR_DSC_NODES[EUR_DSC_NB_FX_NODES + i] = XCcyIborIborSwapCurveNode.of(XCcyIborIborSwapTemplate.of(Tenor.of(EUR_DSC_XCCY_TENORS[i]), EUR_EURIBOR_3M_USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, EUR_DSC_ID_VALUE[EUR_DSC_NB_FX_NODES + i])));
            }
            EUR_FWD3_NODES[0] = IborFixingDepositCurveNode.of(IborFixingDepositTemplate.of(EUR_EURIBOR_3M), QuoteId.of(StandardId.of(SCHEME, EUR_FWD3_ID_VALUE[0])));
            for (int i = 0; i < EUR_FWD3_NB_FRA_NODES; i++)
            {
                EUR_FWD3_NODES[i + 1] = FraCurveNode.of(FraTemplate.of(EUR_FWD3_FRA_TENORS[i], EUR_EURIBOR_3M), QuoteId.of(StandardId.of(SCHEME, EUR_FWD3_ID_VALUE[i + 1])));
            }
            for (int i = 0; i < EUR_FWD3_NB_IRS_NODES; i++)
            {
                EUR_FWD3_NODES[i + 1 + EUR_FWD3_NB_FRA_NODES] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(EUR_FWD3_IRS_TENORS[i]), EUR_FIXED_1Y_EURIBOR_3M), QuoteId.of(StandardId.of(SCHEME, EUR_FWD3_ID_VALUE[i + 1 + EUR_FWD3_NB_FRA_NODES])));
            }
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE);

            for (int i = 0; i < USD_DSC_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[i])), USD_DSC_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < USD_FWD3_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, USD_FWD3_ID_VALUE[i])), USD_FWD3_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < EUR_DSC_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, EUR_DSC_ID_VALUE[i])), EUR_DSC_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < EUR_FWD3_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, EUR_FWD3_ID_VALUE[i])), EUR_FWD3_MARKET_QUOTES[i]);
            }
            builder.addValue(QuoteId.of(StandardId.of(SCHEME, EUR_USD_ID_VALUE)), FX_RATE_EUR_USD);
            builder.addValue(FxRateId.of(EUR, USD), FxRate.of(EUR, USD, FX_RATE_EUR_USD));
            ALL_QUOTES = builder.build();
        }
        private void calibration_market_quote_sensitivity_check(System.Func <ImmutableMarketData, RatesProvider> calibrator, double shift)
        {
            double notional = 100_000_000.0;
            double fx       = 1.1111;
            double fxPts    = 0.0012;
            ResolvedFxSwapTrade            trade  = EUR_USD.createTrade(VAL_DATE, Period.ofWeeks(6), Period.ofMonths(5), BuySell.BUY, notional, fx, fxPts, REF_DATA).resolve(REF_DATA);
            RatesProvider                  result = CALIBRATOR.calibrate(CURVE_GROUP_CONFIG, ALL_QUOTES, REF_DATA);
            PointSensitivities             pts    = FX_PRICER.presentValueSensitivity(trade.Product, result);
            CurrencyParameterSensitivities ps     = result.parameterSensitivity(pts);
            CurrencyParameterSensitivities mqs    = MQC.sensitivity(ps, result);
            double pvUsd = FX_PRICER.presentValue(trade.Product, result).getAmount(USD).Amount;
            double pvEur = FX_PRICER.presentValue(trade.Product, result).getAmount(EUR).Amount;

            double[] mqsUsd1Computed = mqs.getSensitivity(USD_DSCON_CURVE_NAME, USD).Sensitivity.toArray();
            for (int i = 0; i < USD_DSC_NB_NODES; i++)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> map = new java.util.HashMap<>(ALL_QUOTES.getValues());
                IDictionary <MarketDataId <object>, object> map = new Dictionary <MarketDataId <object>, object>(ALL_QUOTES.Values);
                map[QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[i]))] = USD_DSC_MARKET_QUOTES[i] + shift;
                ImmutableMarketData marketData = ImmutableMarketData.of(VAL_DATE, map);
                RatesProvider       rpShifted  = calibrator(marketData);
                double pvS = FX_PRICER.presentValue(trade.Product, rpShifted).getAmount(USD).Amount;
                assertEquals(mqsUsd1Computed[i], (pvS - pvUsd) / shift, TOLERANCE_PV_DELTA);
            }
            double[] mqsUsd2Computed = mqs.getSensitivity(USD_DSCON_CURVE_NAME, EUR).Sensitivity.toArray();
            for (int i = 0; i < USD_DSC_NB_NODES; i++)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> map = new java.util.HashMap<>(ALL_QUOTES.getValues());
                IDictionary <MarketDataId <object>, object> map = new Dictionary <MarketDataId <object>, object>(ALL_QUOTES.Values);
                map[QuoteId.of(StandardId.of(SCHEME, USD_DSC_ID_VALUE[i]))] = USD_DSC_MARKET_QUOTES[i] + shift;
                ImmutableMarketData marketData = ImmutableMarketData.of(VAL_DATE, map);
                RatesProvider       rpShifted  = calibrator(marketData);
                double pvS = FX_PRICER.presentValue(trade.Product, rpShifted).getAmount(EUR).Amount;
                assertEquals(mqsUsd2Computed[i], (pvS - pvEur) / shift, TOLERANCE_PV_DELTA);
            }
            double[] mqsEur1Computed = mqs.getSensitivity(EUR_DSC_CURVE_NAME, USD).Sensitivity.toArray();
            for (int i = 0; i < EUR_DSC_NB_NODES; i++)
            {
                assertEquals(mqsEur1Computed[i], 0.0, TOLERANCE_PV_DELTA);
            }
            double[] mqsEur2Computed = mqs.getSensitivity(EUR_DSC_CURVE_NAME, EUR).Sensitivity.toArray();
            for (int i = 0; i < EUR_DSC_NB_NODES; i++)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> map = new java.util.HashMap<>(ALL_QUOTES.getValues());
                IDictionary <MarketDataId <object>, object> map = new Dictionary <MarketDataId <object>, object>(ALL_QUOTES.Values);
                map[QuoteId.of(StandardId.of(SCHEME, EUR_DSC_ID_VALUE[i]))] = EUR_DSC_MARKET_QUOTES[i] + shift;
                ImmutableMarketData marketData = ImmutableMarketData.of(VAL_DATE, map);
                RatesProvider       rpShifted  = calibrator(marketData);
                double pvS = FX_PRICER.presentValue(trade.Product, rpShifted).getAmount(EUR).Amount;
                assertEquals(mqsEur2Computed[i], (pvS - pvEur) / shift, TOLERANCE_PV_DELTA, "Node " + i);
            }
        }
        //-------------------------------------------------------------------------
        public virtual void test_requirementsAndCurrency()
        {
            GenericSecurityPositionCalculationFunction function = new GenericSecurityPositionCalculationFunction();
            ISet <Measure>       measures = function.supportedMeasures();
            FunctionRequirements reqs     = function.requirements(TRADE, measures, PARAMS, REF_DATA);

            assertThat(reqs.OutputCurrencies).containsOnly(CURRENCY);
            assertThat(reqs.ValueRequirements).isEqualTo(ImmutableSet.of(QuoteId.of(SEC_ID.StandardId)));
            assertThat(reqs.TimeSeriesRequirements).Empty;
            assertThat(function.naturalCurrency(TRADE, REF_DATA)).isEqualTo(CURRENCY);
        }
        //-------------------------------------------------------------------------
        private static ImmutableCreditRatesProvider createRatesProvider(LocalDate tradeDate, LocalDate snapDate, double rateScale, double recoveryRate)
        {
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(snapDate);

            for (int j = 0; j < NUM_INSTRUMENTS; j++)
            {
                builder.addValue(QuoteId.of(StandardId.of("OG", ID_VALUES[j])), RATES[j] * rateScale);
            }
            ImmutableMarketData       quotes          = builder.build();
            IsdaCreditCurveDefinition curveDefinition = IsdaCreditCurveDefinition.of(CurveName.of("yield"), EUR, tradeDate, ACT_365F, DSC_NODES, false, false);
            IsdaCreditDiscountFactors yc = IsdaCompliantDiscountCurveCalibrator.standard().calibrate(curveDefinition, quotes, REF_DATA);

            return(ImmutableCreditRatesProvider.builder().valuationDate(tradeDate).discountCurves(ImmutableMap.of(EUR, yc)).recoveryRateCurves(ImmutableMap.of(LEGAL_ENTITY, ConstantRecoveryRates.of(LEGAL_ENTITY, tradeDate, recoveryRate))).creditCurves(ImmutableMap.of()).build());
        }
        public virtual void parSpreadTest()
        {
            LocalDate   valuationDate    = LocalDate.of(2013, 2, 27);
            DoubleArray ycTime           = DoubleArray.ofUnsafe(new double[] { 0.09041095890410959, 0.1726027397260274, 0.26301369863013696, 0.5123287671232877, 0.7616438356164383, 1.010958904109589, 2.008219178082192, 3.008219178082192, 4.008219178082192, 5.008219178082192, 6.008219178082192, 7.013698630136987, 8.01095890410959, 9.01095890410959, 10.01095890410959, 12.01917808219178, 15.016438356164384, 20.01917808219178, 25.021917808219175, 30.027397260273972 });
            DoubleArray ycRate           = DoubleArray.ofUnsafe(new double[] { 0.0020651105531615476, 0.0024506037920717797, 0.0028872269869485313, 0.004599628230463427, 0.006160809466806469, 0.0075703969168129295, 0.003965128877560435, 0.005059104202201957, 0.0069669135253734825, 0.009361825469323602, 0.011916895611422482, 0.014311922779901886, 0.016519187063048578, 0.018512121993907647, 0.020289623737560873, 0.02329885162861984, 0.026399509889410745, 0.029087919732133784, 0.03037740056662963, 0.03110021763406523 });
            IsdaCreditDiscountFactors yc = IsdaCreditDiscountFactors.of(EUR, valuationDate, CurveName.of("yc_usd"), ycTime, ycRate, ACT_365F);

            double[] timeNodeExp   = new double[] { 0.5616438356164384, 1.0575342465753426, 2.0575342465753423, 3.0602739726027397, 4.06027397260274, 5.06027397260274, 6.06027397260274, 7.063013698630137, 8.063013698630137, 9.063013698630137, 10.063013698630137 };
            double[] rateNodeExp   = new double[] { 0.00876054089781935, 0.011037345646850688, 0.015955126945240167, 0.020617953392829177, 0.025787811343896218, 0.030329992053915133, 0.03313419899444371, 0.03528129159875671, 0.03675340516560903, 0.037946169956317416, 0.038951101800190346 };
            double[] rateNodeExpMf = new double[] { 0.008754510260229803, 0.011030502992814844, 0.01594817866773906, 0.02060947097554756, 0.025776720596175737, 0.030316032527460755, 0.03311839631615255, 0.03526404051997617, 0.03673513322394772, 0.03792689865945585, 0.03893107891569398 };
            ImmutableCreditRatesProvider ratesProvider = ImmutableCreditRatesProvider.builder().valuationDate(valuationDate).discountCurves(ImmutableMap.of(EUR, yc)).recoveryRateCurves(ImmutableMap.of(LEGAL_ENTITY, ConstantRecoveryRates.of(LEGAL_ENTITY, valuationDate, 0.25))).creditCurves(ImmutableMap.of()).build();
            LocalDate startDate = LocalDate.of(2012, 12, 20);

            LocalDate[] pillarDates = new LocalDate[] { LocalDate.of(2013, 9, 20), LocalDate.of(2014, 3, 20), LocalDate.of(2015, 3, 20), LocalDate.of(2016, 3, 20), LocalDate.of(2017, 3, 20), LocalDate.of(2018, 3, 20), LocalDate.of(2019, 3, 20), LocalDate.of(2020, 3, 20), LocalDate.of(2021, 3, 20), LocalDate.of(2022, 3, 20), LocalDate.of(2023, 3, 20) };
            int         nPillars    = pillarDates.Length;
            ImmutableMarketDataBuilder     builderCredit = ImmutableMarketData.builder(valuationDate);
            IList <CdsIsdaCreditCurveNode> nodes         = new List <CdsIsdaCreditCurveNode>(nPillars);

            double[] quotes = new double[] { 0.006485, 0.008163, 0.011763, 0.015136, 0.018787, 0.021905, 0.023797, 0.025211, 0.02617, 0.026928, 0.027549 };
            for (int i = 0; i < nPillars; ++i)
            {
                CdsConvention conv = ImmutableCdsConvention.of("conv", EUR, ACT_360, Frequency.P3M, BUS_ADJ, CDS_SETTLE_STD);
                CdsTemplate   temp = DatesCdsTemplate.of(startDate, pillarDates[i], conv);
                QuoteId       id   = QuoteId.of(StandardId.of("OG", pillarDates[i].ToString()));
                nodes.Add(CdsIsdaCreditCurveNode.ofParSpread(temp, id, LEGAL_ENTITY));
                builderCredit.addValue(id, quotes[i]);
            }
            ImmutableMarketData              marketData      = builderCredit.build();
            IsdaCreditCurveDefinition        curveDefinition = IsdaCreditCurveDefinition.of(CurveName.of("zz"), EUR, valuationDate, ACT_365F, nodes, true, true);
            LegalEntitySurvivalProbabilities cc = BUILDER_ISDA.calibrate(curveDefinition, marketData, ratesProvider, REF_DATA);
            NodalCurve resCurve = ((IsdaCreditDiscountFactors)cc.SurvivalProbabilities).Curve;

            for (int i = 0; i < nPillars; ++i)
            {
                ParameterMetadata param = resCurve.getParameterMetadata(i);
                assertTrue(param is ResolvedTradeParameterMetadata);
                ResolvedTradeParameterMetadata tradeParam = (ResolvedTradeParameterMetadata)param;
                assertTrue(tradeParam.Trade is ResolvedCdsTrade);
            }
            assertTrue(DoubleArrayMath.fuzzyEquals(resCurve.XValues.toArray(), timeNodeExp, TOL));
            assertTrue(DoubleArrayMath.fuzzyEquals(resCurve.YValues.toArray(), rateNodeExp, TOL));
            testJacobian(BUILDER_ISDA, cc, ratesProvider, nodes, quotes, 1d, EPS);
            LegalEntitySurvivalProbabilities ccMf = BUILDER_MARKIT.calibrate(curveDefinition, marketData, ratesProvider, REF_DATA);
            NodalCurve resCurveMf = ((IsdaCreditDiscountFactors)ccMf.SurvivalProbabilities).Curve;

            assertTrue(DoubleArrayMath.fuzzyEquals(resCurveMf.XValues.toArray(), timeNodeExp, TOL));
            assertTrue(DoubleArrayMath.fuzzyEquals(resCurveMf.YValues.toArray(), rateNodeExpMf, TOL));
            testJacobian(BUILDER_MARKIT, ccMf, ratesProvider, nodes, quotes, 1d, EPS);
        }
Beispiel #19
0
        private void calibration_market_quote_sensitivity_check(System.Func <MarketData, RatesProvider> calibrator, double shift)
        {
            double                         notional = 100_000_000.0;
            double                         spread   = 0.0050;
            SwapTrade                      trade    = IborIborSwapConventions.USD_LIBOR_3M_LIBOR_6M.createTrade(VAL_DATE, Period.ofMonths(8), Tenor.TENOR_7Y, BuySell.BUY, notional, spread, REF_DATA);
            RatesProvider                  result   = calibrator(ALL_QUOTES);
            ResolvedSwap                   product  = trade.Product.resolve(REF_DATA);
            PointSensitivityBuilder        pts      = SWAP_PRICER.presentValueSensitivity(product, result);
            CurrencyParameterSensitivities ps       = result.parameterSensitivity(pts.build());
            CurrencyParameterSensitivities mqs      = MQC.sensitivity(ps, result);
            double                         pv0      = SWAP_PRICER.presentValue(product, result).getAmount(USD).Amount;

            double[] mqsDscComputed = mqs.getSensitivity(DSCON_CURVE_NAME, USD).Sensitivity.toArray();
            for (int i = 0; i < DSC_NB_NODES; i++)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> map = new java.util.HashMap<>(ALL_QUOTES.getValues());
                IDictionary <MarketDataId <object>, object> map = new Dictionary <MarketDataId <object>, object>(ALL_QUOTES.Values);
                map[QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i]))] = DSC_MARKET_QUOTES[i] + shift;
                ImmutableMarketData marketData = ImmutableMarketData.of(VAL_DATE, map);
                RatesProvider       rpShifted  = calibrator(marketData);
                double pvS = SWAP_PRICER.presentValue(product, rpShifted).getAmount(USD).Amount;
                assertEquals(mqsDscComputed[i], (pvS - pv0) / shift, TOLERANCE_PV_DELTA, "DSC - node " + i);
            }
            double[] mqsFwd3Computed = mqs.getSensitivity(FWD3_CURVE_NAME, USD).Sensitivity.toArray();
            for (int i = 0; i < FWD3_NB_NODES; i++)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> map = new java.util.HashMap<>(ALL_QUOTES.getValues());
                IDictionary <MarketDataId <object>, object> map = new Dictionary <MarketDataId <object>, object>(ALL_QUOTES.Values);
                map[QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i]))] = FWD3_MARKET_QUOTES[i] + shift;
                ImmutableMarketData marketData = ImmutableMarketData.of(VAL_DATE, map);
                RatesProvider       rpShifted  = calibrator(marketData);
                double pvS = SWAP_PRICER.presentValue(product, rpShifted).getAmount(USD).Amount;
                assertEquals(mqsFwd3Computed[i], (pvS - pv0) / shift, TOLERANCE_PV_DELTA, "FWD3 - node " + i);
            }
            double[] mqsFwd6Computed = mqs.getSensitivity(FWD6_CURVE_NAME, USD).Sensitivity.toArray();
            for (int i = 0; i < FWD6_NB_NODES; i++)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> map = new java.util.HashMap<>(ALL_QUOTES.getValues());
                IDictionary <MarketDataId <object>, object> map = new Dictionary <MarketDataId <object>, object>(ALL_QUOTES.Values);
                map[QuoteId.of(StandardId.of(SCHEME, FWD6_ID_VALUE[i]))] = FWD6_MARKET_QUOTES[i] + shift;
                ImmutableMarketData marketData = ImmutableMarketData.of(VAL_DATE, map);
                RatesProvider       rpShifted  = calibrator(marketData);
                double pvS = SWAP_PRICER.presentValue(product, rpShifted).getAmount(USD).Amount;
                assertEquals(mqsFwd6Computed[i], (pvS - pv0) / shift, TOLERANCE_PV_DELTA, "FWD6 - node " + i);
            }
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            OvernightFuture product = target.Product;
            QuoteId         quoteId = QuoteId.of(target.Product.SecurityId.StandardId, FieldName.SETTLEMENT_PRICE);
            OvernightIndex  index   = product.Index;

            // use lookup to build requirements
            RatesMarketDataLookup ratesLookup = parameters.getParameter(typeof(RatesMarketDataLookup));
            FunctionRequirements  ratesReqs   = ratesLookup.requirements(ImmutableSet.of(), ImmutableSet.of(index));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableSet<com.opengamma.strata.data.MarketDataId<?>> valueReqs = com.google.common.collect.ImmutableSet.builder<com.opengamma.strata.data.MarketDataId<?>>().add(quoteId).addAll(ratesReqs.getValueRequirements()).build();
            ImmutableSet <MarketDataId <object> > valueReqs = ImmutableSet.builder <MarketDataId <object> >().add(quoteId).addAll(ratesReqs.ValueRequirements).build();

            return(ratesReqs.toBuilder().valueRequirements(valueReqs).build());
        }
 static BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecificationTest()
 {
     ImmutableList.Builder <FxOptionVolatilitiesNode> nodeBuilder = ImmutableList.builder();
     ImmutableList.Builder <QuoteId> quoteIdBuilder = ImmutableList.builder();
     for (int i = 0; i < TENORS.Count; ++i)
     {
         for (int j = 0; j < STRIKES.Count; ++j)
         {
             QuoteId quoteId = QuoteId.of(StandardId.of("OG", GBP_USD.ToString() + "_" + TENORS[i].ToString() + "_" + STRIKES[j]));
             nodeBuilder.add(FxOptionVolatilitiesNode.of(GBP_USD, SPOT_OFFSET, BDA, ValueType.BLACK_VOLATILITY, quoteId, TENORS[i], SimpleStrike.of(STRIKES[j])));
             quoteIdBuilder.add(quoteId);
         }
     }
     NODES     = nodeBuilder.build();
     QUOTE_IDS = quoteIdBuilder.build();
 }
Beispiel #22
0
        static CalibrationInflationUsdTest()
        {
            DSC_NAMES[DSCON_CURVE_NAME] = USD;
            ISet <Index> usdFedFundSet = new HashSet <Index>();

            usdFedFundSet.Add(USD_FED_FUND);
            IDX_NAMES[DSCON_CURVE_NAME] = usdFedFundSet;
            ISet <Index> usdLibor3Set = new HashSet <Index>();

            usdLibor3Set.Add(USD_LIBOR_3M);
            IDX_NAMES[CPI_CURVE_NAME] = usdLibor3Set;
            for (int i = 0; i < DSC_NB_DEPO_NODES; i++)
            {
                BusinessDayAdjustment bda        = BusinessDayAdjustment.of(FOLLOWING, USNY);
                TermDepositConvention convention = ImmutableTermDepositConvention.of("USD-Dep", USD, bda, ACT_360, DaysAdjustment.ofBusinessDays(DSC_DEPO_OFFSET[i], USNY));
                DSC_NODES[i] = TermDepositCurveNode.of(TermDepositTemplate.of(Period.ofDays(1), convention), QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])));
            }
            for (int i = 0; i < DSC_NB_OIS_NODES; i++)
            {
                DSC_NODES[DSC_NB_DEPO_NODES + i] = FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(DSC_OIS_TENORS[i]), USD_FIXED_1Y_FED_FUND_OIS), QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[DSC_NB_DEPO_NODES + i])));
            }
            for (int i = 0; i < CPI_NB_NODES; i++)
            {
                CPI_NODES[i] = FixedInflationSwapCurveNode.builder().template(FixedInflationSwapTemplate.of(Tenor.of(CPI_TENORS[i]), FixedInflationSwapConventions.USD_FIXED_ZC_US_CPI)).rateId(QuoteId.of(StandardId.of(SCHEME, CPI_ID_VALUE[i]))).date(CurveNodeDate.LAST_FIXING).build();
            }
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE);

            for (int i = 0; i < DSC_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])), DSC_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < CPI_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, CPI_ID_VALUE[i])), CPI_MARKET_QUOTES[i]);
            }
            builder.addTimeSeries(IndexQuoteId.of(US_CPI_U), TS_USD_CPI);
            ALL_QUOTES = builder.build();
            IList <CurveNode[]> groupDsc = new List <CurveNode[]>();

            groupDsc.Add(DSC_NODES);
            CURVES_NODES.Add(groupDsc);
            IList <CurveNode[]> groupCpi = new List <CurveNode[]>();

            groupCpi.Add(CPI_NODES);
            CURVES_NODES.Add(groupCpi);
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            BondFuture product  = target.Product;
            QuoteId    quoteId  = QuoteId.of(product.SecurityId.StandardId, FieldName.SETTLEMENT_PRICE);
            Currency   currency = product.Currency;

            // use lookup to build requirements
            FunctionRequirements freqs = FunctionRequirements.builder().valueRequirements(quoteId).outputCurrencies(currency).build();
            LegalEntityDiscountingMarketDataLookup ledLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));

            foreach (FixedCouponBond bond in product.DeliveryBasket)
            {
                freqs = freqs.combinedWith(ledLookup.requirements(bond.SecurityId, bond.LegalEntityId, bond.Currency));
            }
            return(freqs);
        }
Beispiel #24
0
        /// <summary>
        /// Test that the curve node requirements are extracted and returned.
        /// </summary>
        public virtual void requirements()
        {
            FraCurveNode node1x4 = fraNode(1, "a");
            FraCurveNode node2x5 = fraNode(2, "b");
            FraCurveNode node3x6 = fraNode(3, "c");

            InterpolatedNodalCurveDefinition curve = InterpolatedNodalCurveDefinition.builder().name(CurveName.of("curve")).interpolator(CurveInterpolators.DOUBLE_QUADRATIC).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).nodes(node1x4, node2x5, node3x6).build();

            RatesCurveGroupDefinition groupDefn = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("curve group")).addDiscountCurve(curve, Currency.USD).build();

            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(groupDefn.Name, groupDefn).build();

            RatesCurveInputsMarketDataFunction marketDataFunction = new RatesCurveInputsMarketDataFunction();
            RatesCurveInputsId     curveInputsId = RatesCurveInputsId.of(groupDefn.Name, curve.Name, ObservableSource.NONE);
            MarketDataRequirements requirements  = marketDataFunction.requirements(curveInputsId, marketDataConfig);

            assertThat(requirements.Observables).contains(QuoteId.of(StandardId.of("test", "a"))).contains(QuoteId.of(StandardId.of("test", "b"))).contains(QuoteId.of(StandardId.of("test", "c")));
        }
Beispiel #25
0
        public static MarketData allQuotes(LocalDate valuationDate, double[] dscOisQuotes, string[] dscIdValues, double[] fwd3MarketQuotes, string[] fwd3IdValue, double[] fwd6MarketQuotes, string[] fwd6IdValue)
        {
            /* All quotes for the curve calibration */
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(valuationDate);

            for (int i = 0; i < dscOisQuotes.Length; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, dscIdValues[i])), dscOisQuotes[i]);
            }
            for (int i = 0; i < fwd3MarketQuotes.Length; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, fwd3IdValue[i])), fwd3MarketQuotes[i]);
            }
            for (int i = 0; i < fwd6MarketQuotes.Length; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, fwd6IdValue[i])), fwd6MarketQuotes[i]);
            }
            return(builder.build());
        }
        public virtual void pufTest()
        {
            LocalDate   valuationDate    = LocalDate.of(2013, 4, 10);
            DoubleArray ycTime           = DoubleArray.ofUnsafe(new double[] { 0.09041095890410959, 0.1726027397260274, 0.2547945205479452, 0.5123287671232877, 0.7616438356164383, 1.010958904109589, 2.008219178082192, 3.008219178082192, 4.008219178082192, 5.008219178082192, 6.008219178082192, 7.013698630136987, 8.01095890410959, 9.01095890410959, 10.01095890410959, 12.01917808219178, 15.016438356164384, 20.01917808219178, 25.021917808219175, 30.027397260273972 });
            DoubleArray ycRate           = DoubleArray.ofUnsafe(new double[] { 0.0020205071813561414, 0.0024226927083852126, 0.00280147037504029, 0.004449041082144009, 0.005821804782808804, 0.007254879152733453, 0.00378133614924816, 0.004815163234294319, 0.006576302084547871, 0.00884241431837336, 0.011358805989279104, 0.013793391727035883, 0.016014197840890115, 0.01801564209277191, 0.019757164421290663, 0.022773295945438254, 0.025862337032619587, 0.02848646344754061, 0.029753383126110852, 0.03045277462637107 });
            IsdaCreditDiscountFactors yc = IsdaCreditDiscountFactors.of(EUR, valuationDate, CurveName.of("yc_usd"), ycTime, ycRate, ACT_365F);

            double[] timeNodeExp   = new double[] { 0.19452054794520549, 0.4465753424657534, 0.6958904109589041, 0.9424657534246575, 1.1945205479452055, 1.4465753424657535, 1.6958904109589041, 1.9424657534246574, 2.1945205479452055, 2.4465753424657533, 2.695890410958904, 2.9452054794520546, 3.197260273972603, 3.4493150684931506, 3.6986301369863015, 3.9452054794520546, 4.197260273972603, 4.449315068493151, 4.698630136986301, 4.945205479452055, 5.197260273972603, 5.449315068493151, 5.698630136986301, 5.945205479452055, 6.197260273972603, 6.449315068493151, 6.698630136986301, 6.947945205479452, 7.2, 7.4520547945205475, 7.701369863013698, 7.947945205479452, 8.2, 8.452054794520548, 8.7013698630137, 8.947945205479453, 9.2, 9.452054794520548, 9.7013698630137, 9.947945205479453, 10.2 };
            double[] rateNodeExp   = new double[] { 0.11219168510100914, 0.11085321179769615, 0.11753783265486063, 0.11806409789291543, 0.12007843111645247, 0.12273722191216528, 0.12541993298405366, 0.12773640093265545, 0.1290535220739981, 0.13294183149211675, 0.13659302947963856, 0.13988488561043758, 0.1429469312254705, 0.14606538453369572, 0.14916286828444447, 0.15219682906227, 0.1548315745851032, 0.158141193071526, 0.16163981714033765, 0.1650400193930357, 0.1682351993447916, 0.1683744003954113, 0.168657453080796, 0.16915067878510565, 0.1694852880010724, 0.16990705130936645, 0.1704456138969621, 0.17105852486248443, 0.1717088423125347, 0.1727906445582425, 0.17407566745397665, 0.17547300248653266, 0.17679395545074758, 0.17769841457372118, 0.1788064602071617, 0.18001498257267778, 0.18123747758791092, 0.18253661761388457, 0.18406319235262744, 0.18582983758830868, 0.18750386499176422 };
            double[] rateNodeExpMf = new double[] { 0.11107220823737506, 0.11011543264900588, 0.11685607164947402, 0.11742079953945683, 0.1194445192166302, 0.12220026187805585, 0.12494798294628297, 0.12731185688090763, 0.12860146674492023, 0.1325216904413876, 0.1362014254649678, 0.13951646788193767, 0.14254141853655264, 0.14567581048732742, 0.1487851622438674, 0.15182838855605538, 0.15442415754322128, 0.15774061191016645, 0.16124288871765308, 0.1646451035564102, 0.167796451103847, 0.16794456750248196, 0.16823438468063495, 0.1687328171292339, 0.16904360885724334, 0.16947020572961907, 0.17001201556723175, 0.17062724832190826, 0.17125190473373603, 0.17233319414449558, 0.17361785479583028, 0.1750136127341691, 0.17630530410589512, 0.17720871748506664, 0.17831270423353415, 0.17951604233911425, 0.18070939732103264, 0.18200162521943403, 0.18351891000003046, 0.1852740041292825, 0.18691086960422418 };
            ImmutableCreditRatesProvider ratesProvider = ImmutableCreditRatesProvider.builder().valuationDate(valuationDate).discountCurves(ImmutableMap.of(EUR, yc)).recoveryRateCurves(ImmutableMap.of(LEGAL_ENTITY, ConstantRecoveryRates.of(LEGAL_ENTITY, valuationDate, 0.4))).creditCurves(ImmutableMap.of()).build();
            LocalDate startDate = LocalDate.of(2013, 3, 20);

            LocalDate[] pillarDate = new LocalDate[] { LocalDate.of(2013, 6, 20), LocalDate.of(2013, 9, 20), LocalDate.of(2013, 12, 20), LocalDate.of(2014, 3, 20), LocalDate.of(2014, 6, 20), LocalDate.of(2014, 9, 20), LocalDate.of(2014, 12, 20), LocalDate.of(2015, 3, 20), LocalDate.of(2015, 6, 20), LocalDate.of(2015, 9, 20), LocalDate.of(2015, 12, 20), LocalDate.of(2016, 3, 20), LocalDate.of(2016, 6, 20), LocalDate.of(2016, 9, 20), LocalDate.of(2016, 12, 20), LocalDate.of(2017, 3, 20), LocalDate.of(2017, 6, 20), LocalDate.of(2017, 9, 20), LocalDate.of(2017, 12, 20), LocalDate.of(2018, 3, 20), LocalDate.of(2018, 6, 20), LocalDate.of(2018, 9, 20), LocalDate.of(2018, 12, 20), LocalDate.of(2019, 3, 20), LocalDate.of(2019, 6, 20), LocalDate.of(2019, 9, 20), LocalDate.of(2019, 12, 20), LocalDate.of(2020, 3, 20), LocalDate.of(2020, 6, 20), LocalDate.of(2020, 9, 20), LocalDate.of(2020, 12, 20), LocalDate.of(2021, 3, 20), LocalDate.of(2021, 6, 20), LocalDate.of(2021, 9, 20), LocalDate.of(2021, 12, 20), LocalDate.of(2022, 3, 20), LocalDate.of(2022, 6, 20), LocalDate.of(2022, 9, 20), LocalDate.of(2022, 12, 20), LocalDate.of(2023, 3, 20), LocalDate.of(2023, 6, 20) };
            int         nPillars   = pillarDate.Length;
            double      coupon     = 500d * ONE_BP;
            ImmutableMarketDataBuilder     builderCredit = ImmutableMarketData.builder(valuationDate);
            IList <CdsIsdaCreditCurveNode> nodes         = new List <CdsIsdaCreditCurveNode>(nPillars);

            double[] quotes = new double[] { 0.32, 0.69, 1.32, 1.79, 2.36, 3.01, 3.7, 4.39, 5.02, 5.93, 6.85, 7.76, 8.67, 9.6, 10.53, 11.45, 12.33, 13.29, 14.26, 15.2, 16.11, 16.62, 17.12, 17.62, 18.09, 18.55, 19, 19.44, 19.87, 20.33, 20.79, 21.24, 21.67, 22.04, 22.41, 22.77, 23.12, 23.46, 23.8, 24.14, 24.46 };
            for (int i = 0; i < nPillars; ++i)
            {
                CdsConvention conv = ImmutableCdsConvention.of("conv", EUR, ACT_360, Frequency.P3M, BUS_ADJ, CDS_SETTLE_STD);
                CdsTemplate   temp = DatesCdsTemplate.of(startDate, pillarDate[i], conv);
                QuoteId       id   = QuoteId.of(StandardId.of("OG", pillarDate[i].ToString()));
                nodes.Add(CdsIsdaCreditCurveNode.ofPointsUpfront(temp, id, LEGAL_ENTITY, coupon));
                builderCredit.addValue(id, quotes[i] * ONE_PC);
            }
            ImmutableMarketData              marketData      = builderCredit.build();
            IsdaCreditCurveDefinition        curveDefinition = IsdaCreditCurveDefinition.of(CurveName.of("cc"), EUR, valuationDate, ACT_365F, nodes, true, false);
            LegalEntitySurvivalProbabilities cc = BUILDER_ISDA.calibrate(curveDefinition, marketData, ratesProvider, REF_DATA);
            NodalCurve resCurve = ((IsdaCreditDiscountFactors)cc.SurvivalProbabilities).Curve;

            assertTrue(DoubleArrayMath.fuzzyEquals(resCurve.XValues.toArray(), timeNodeExp, TOL));
            assertTrue(DoubleArrayMath.fuzzyEquals(resCurve.YValues.toArray(), rateNodeExp, TOL));
            testJacobian(BUILDER_ISDA, cc, ratesProvider, nodes, quotes, ONE_PC, EPS);
            LegalEntitySurvivalProbabilities ccMf = BUILDER_MARKIT.calibrate(curveDefinition, marketData, ratesProvider, REF_DATA);
            NodalCurve resCurveMf = ((IsdaCreditDiscountFactors)ccMf.SurvivalProbabilities).Curve;

            assertTrue(DoubleArrayMath.fuzzyEquals(resCurveMf.XValues.toArray(), timeNodeExp, TOL));
            assertTrue(DoubleArrayMath.fuzzyEquals(resCurveMf.YValues.toArray(), rateNodeExpMf, TOL));
            testJacobian(BUILDER_MARKIT, ccMf, ratesProvider, nodes, quotes, ONE_PC, EPS);
        }
        //-------------------------------------------------------------------------
        public virtual void duplicateInputDataKeys()
        {
            FxSwapTemplate  template1               = FxSwapTemplate.of(Period.ofMonths(1), FxSwapConventions.EUR_USD);
            FxSwapTemplate  template2               = FxSwapTemplate.of(Period.ofMonths(2), FxSwapConventions.EUR_USD);
            QuoteId         pointsKey1a             = QuoteId.of(StandardId.of("test", "1a"));
            QuoteId         pointsKey1b             = QuoteId.of(StandardId.of("test", "1b"));
            QuoteId         pointsKey2a             = QuoteId.of(StandardId.of("test", "2a"));
            QuoteId         pointsKey2b             = QuoteId.of(StandardId.of("test", "2b"));
            FxSwapCurveNode node1a                  = FxSwapCurveNode.of(template1, pointsKey1a);
            FxSwapCurveNode node1b                  = FxSwapCurveNode.of(template2, pointsKey1b);
            FxSwapCurveNode node2                   = FxSwapCurveNode.of(template1, pointsKey2a);
            FxSwapCurveNode node2b                  = FxSwapCurveNode.of(template2, pointsKey2b);
            CurveName       curveName1              = CurveName.of("curve1");
            InterpolatedNodalCurveDefinition curve1 = InterpolatedNodalCurveDefinition.builder().name(curveName1).nodes(node1a, node1b).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_360).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.LINEAR).extrapolatorRight(CurveExtrapolators.LINEAR).build();
            CurveName curveName2 = CurveName.of("curve2");
            InterpolatedNodalCurveDefinition curve2   = InterpolatedNodalCurveDefinition.builder().name(curveName2).nodes(node2, node2b).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_360).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.LINEAR).extrapolatorRight(CurveExtrapolators.LINEAR).build();
            CurveGroupName            curveGroupName  = CurveGroupName.of("group");
            RatesCurveGroupDefinition groupDefinition = RatesCurveGroupDefinition.builder().name(curveGroupName).addDiscountCurve(curve1, Currency.EUR).addDiscountCurve(curve2, Currency.USD).build();

            RatesCurveGroupMarketDataFunction fn = new RatesCurveGroupMarketDataFunction();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> marketDataMap1 = com.google.common.collect.ImmutableMap.of(com.opengamma.strata.data.FxRateId.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD), com.opengamma.strata.basics.currency.FxRate.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD, 1.01), pointsKey1a, 0.1d, pointsKey1b, 0.2d);
            IDictionary <MarketDataId <object>, object> marketDataMap1 = ImmutableMap.of(FxRateId.of(Currency.EUR, Currency.USD), FxRate.of(Currency.EUR, Currency.USD, 1.01), pointsKey1a, 0.1d, pointsKey1b, 0.2d);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> marketDataMap2 = com.google.common.collect.ImmutableMap.of(com.opengamma.strata.data.FxRateId.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD), com.opengamma.strata.basics.currency.FxRate.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD, 1.01), pointsKey2a, 0.1d, pointsKey2b, 0.2d);
            IDictionary <MarketDataId <object>, object> marketDataMap2 = ImmutableMap.of(FxRateId.of(Currency.EUR, Currency.USD), FxRate.of(Currency.EUR, Currency.USD, 1.01), pointsKey2a, 0.1d, pointsKey2b, 0.2d);
            RatesCurveInputs            curveInputs1 = RatesCurveInputs.of(marketDataMap1, DefaultCurveMetadata.of("curve1"));
            RatesCurveInputs            curveInputs2 = RatesCurveInputs.of(marketDataMap2, DefaultCurveMetadata.of("curve2"));
            ImmutableScenarioMarketData marketData   = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)).addValue(RatesCurveInputsId.of(curveGroupName, curveName1, ObservableSource.NONE), curveInputs1).addValue(RatesCurveInputsId.of(curveGroupName, curveName2, ObservableSource.NONE), curveInputs2).build();

            fn.buildCurveGroup(groupDefinition, CALIBRATOR, marketData, REF_DATA, ObservableSource.NONE);

            // This has a duplicate key with a different value which should fail
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, Object> badMarketDataMap = com.google.common.collect.ImmutableMap.of(com.opengamma.strata.data.FxRateId.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD), com.opengamma.strata.basics.currency.FxRate.of(com.opengamma.strata.basics.currency.Currency.EUR, com.opengamma.strata.basics.currency.Currency.USD, 1.02), pointsKey2a, 0.2d);
            IDictionary <MarketDataId <object>, object> badMarketDataMap = ImmutableMap.of(FxRateId.of(Currency.EUR, Currency.USD), FxRate.of(Currency.EUR, Currency.USD, 1.02), pointsKey2a, 0.2d);
            RatesCurveInputs   badCurveInputs = RatesCurveInputs.of(badMarketDataMap, DefaultCurveMetadata.of("curve2"));
            ScenarioMarketData badMarketData  = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)).addValue(RatesCurveInputsId.of(curveGroupName, curveName1, ObservableSource.NONE), curveInputs1).addValue(RatesCurveInputsId.of(curveGroupName, curveName2, ObservableSource.NONE), badCurveInputs).build();
            string             msg            = "Multiple unequal values found for identifier .*\\. Values: .* and .*";

            assertThrowsIllegalArg(() => fn.buildCurveGroup(groupDefinition, CALIBRATOR, badMarketData, REF_DATA, ObservableSource.NONE), msg);
        }
        /// <summary>
        /// Start from a generic zero-coupon curve. Compute the (inverse) Jacobian matrix using linear projection to a small
        /// number of points and the Jacobian utility. Compare the direct Jacobian obtained by calibrating a curve
        /// based on the trades with market quotes computed from the zero-coupon curve.
        /// </summary>
        public virtual void with_rebucketing_one_curve()
        {
            /* Create trades */
            IList <ResolvedTrade> trades    = new List <ResolvedTrade>();
            IList <LocalDate>     nodeDates = new List <LocalDate>();

            double[] marketQuotes = new double[TENORS_STD_1.Length];
            for (int looptenor = 0; looptenor < TENORS_STD_1.Length; looptenor++)
            {
                ResolvedSwapTrade t0 = EUR_FIXED_1Y_EURIBOR_6M.createTrade(VALUATION_DATE, TENORS_STD_1[looptenor], BuySell.BUY, 1.0, 0.0, REF_DATA).resolve(REF_DATA);
                marketQuotes[looptenor] = MARKET_QUOTE.value(t0, MULTICURVE_EUR_SINGLE_INPUT);
                ResolvedSwapTrade t = EUR_FIXED_1Y_EURIBOR_6M.createTrade(VALUATION_DATE, TENORS_STD_1[looptenor], BuySell.BUY, 1.0, marketQuotes[looptenor], REF_DATA).resolve(REF_DATA);
                nodeDates.Add(t.Product.EndDate);
                trades.Add(t);
            }
            System.Func <ResolvedTrade, CurrencyParameterSensitivities> sensitivityFunction = (t) => CurveSensitivityUtils.linearRebucketing(MULTICURVE_EUR_SINGLE_INPUT.parameterSensitivity(PRICER_SWAP_PRODUCT.parRateSensitivity(((ResolvedSwapTrade)t).Product, MULTICURVE_EUR_SINGLE_INPUT).build()), nodeDates, VALUATION_DATE);

            /* Market quotes for comparison */
            IDictionary <QuoteId, double> mqCmp = new Dictionary <QuoteId, double>();

            for (int looptenor = 0; looptenor < TENORS_STD_1.Length; looptenor++)
            {
                mqCmp[QuoteId.of(StandardId.of(OG_TICKER, TICKERS_STD_1[looptenor]))] = marketQuotes[looptenor];
            }
            ImmutableMarketData marketQuotesObject = ImmutableMarketData.of(VALUATION_DATE, mqCmp);
            RatesProvider       multicurveCmp      = CALIBRATOR.calibrate(GROUPS_IN_1, marketQuotesObject, REF_DATA);

            /* Comparison */
            DoubleMatrix jiComputed = CurveSensitivityUtils.jacobianFromMarketQuoteSensitivities(LIST_CURVE_NAMES_1, trades, sensitivityFunction);
            DoubleMatrix jiExpected = multicurveCmp.findData(EUR_SINGLE_NAME).get().Metadata.findInfo(CurveInfoType.JACOBIAN).get().JacobianMatrix;

            assertEquals(jiComputed.rowCount(), jiExpected.rowCount());
            assertEquals(jiComputed.columnCount(), jiExpected.columnCount());
            for (int i = 0; i < jiComputed.rowCount(); i++)
            {
                for (int j = 0; j < jiComputed.columnCount(); j++)
                {
                    assertEquals(jiComputed.get(i, j), jiExpected.get(i, j), TOLERANCE_JAC_APPROX);
                    // The comparison is not perfect due to the incoherences introduced by the re-bucketing
                }
            }
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification test1 = BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification.builder().name(VOL_NAME).currencyPair(GBP_USD).dayCount(ACT_365F).nodes(NODES).timeInterpolator(PCHIP).timeExtrapolatorLeft(LINEAR).timeExtrapolatorRight(LINEAR).strikeInterpolator(PCHIP).strikeExtrapolatorLeft(LINEAR).strikeExtrapolatorRight(LINEAR).build();

            coverImmutableBean(test1);
            CurrencyPair eurUsd = CurrencyPair.of(EUR, USD);

            ImmutableList.Builder <FxOptionVolatilitiesNode> nodeBuilder = ImmutableList.builder();
            for (int i = 0; i < TENORS.Count; ++i)
            {
                for (int j = 0; j < STRIKES.Count; ++j)
                {
                    QuoteId quoteId = QuoteId.of(StandardId.of("OG", eurUsd.ToString() + "_" + TENORS[i].ToString() + "_" + STRIKES[j]));
                    nodeBuilder.add(FxOptionVolatilitiesNode.of(eurUsd, SPOT_OFFSET, BDA, ValueType.BLACK_VOLATILITY, quoteId, TENORS[i], SimpleStrike.of(STRIKES[j])));
                }
            }
            BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification test2 = BlackFxOptionInterpolatedNodalSurfaceVolatilitiesSpecification.builder().name(FxOptionVolatilitiesName.of("other")).currencyPair(eurUsd).dayCount(ACT_360).nodes(nodeBuilder.build()).timeInterpolator(DOUBLE_QUADRATIC).strikeInterpolator(DOUBLE_QUADRATIC).build();

            coverBeanEquals(test1, test2);
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            BondFutureOption option = target.Product;
            BondFuture       future = option.UnderlyingFuture;

            // use lookup to build requirements
            QuoteId optionQuoteId      = QuoteId.of(option.SecurityId.StandardId, FieldName.SETTLEMENT_PRICE);
            FunctionRequirements freqs = FunctionRequirements.builder().valueRequirements(optionQuoteId).outputCurrencies(future.Currency, option.Currency).build();
            LegalEntityDiscountingMarketDataLookup ledLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));

            foreach (FixedCouponBond bond in future.DeliveryBasket)
            {
                freqs = freqs.combinedWith(ledLookup.requirements(bond.SecurityId, bond.LegalEntityId, bond.Currency));
            }
            BondFutureOptionMarketDataLookup optionLookup = parameters.getParameter(typeof(BondFutureOptionMarketDataLookup));
            FunctionRequirements             optionReqs   = optionLookup.requirements(future.SecurityId);

            return(freqs.combinedWith(optionReqs));
        }