Exemplo n.º 1
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);
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        public virtual void test_initialGuess_wrongType()
        {
            FixedInflationSwapCurveNode node = FixedInflationSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            MarketData marketData            = ImmutableMarketData.builder(VAL_DATE).build();

            assertThrowsIllegalArg(() => node.initialGuess(marketData, ValueType.BLACK_VOLATILITY));
        }
        /// <summary>
        /// Tests the combinedWith method when the other set of market data is not an instance of ImmutableScenarioMarketData
        /// </summary>
        public virtual void test_combinedWithDifferentImpl()
        {
            LocalDateDoubleTimeSeries timeSeries1 = LocalDateDoubleTimeSeries.builder().put(date(2011, 3, 8), 1).put(date(2011, 3, 9), 2).put(date(2011, 3, 10), 3).build();

            LocalDateDoubleTimeSeries timeSeries2 = LocalDateDoubleTimeSeries.builder().put(date(2011, 3, 8), 10).put(date(2011, 3, 9), 20).put(date(2011, 3, 10), 30).build();

            LocalDateDoubleTimeSeries timeSeries2a = LocalDateDoubleTimeSeries.builder().put(date(2011, 3, 8), 1000).put(date(2011, 3, 9), 2000).put(date(2011, 3, 10), 3000).build();

            LocalDateDoubleTimeSeries timeSeries3 = LocalDateDoubleTimeSeries.builder().put(date(2011, 3, 8), 100).put(date(2011, 3, 9), 200).put(date(2011, 3, 10), 300).build();

            MarketData marketData = ImmutableMarketData.builder(LocalDate.of(2011, 3, 8)).addTimeSeries(TEST_ID1, timeSeries1).addTimeSeries(TEST_ID2, timeSeries2).addValue(TEST_ID1, 1.1).addValue(TEST_ID2, 1.2).build();

            RepeatedScenarioMarketData repeatedScenarioMarketData = RepeatedScenarioMarketData.of(3, marketData);

            ImmutableScenarioMarketData immutableScenarioMarketData = ImmutableScenarioMarketData.builder(LocalDate.of(2011, 3, 8)).addTimeSeries(TEST_ID2, timeSeries2a).addTimeSeries(TEST_ID3, timeSeries3).addBox(TEST_ID2, MarketDataBox.ofScenarioValues(2.0, 2.1, 2.2)).addBox(TEST_ID3, MarketDataBox.ofScenarioValues(3.0, 3.1, 3.2)).build();

            ScenarioMarketData combinedData = immutableScenarioMarketData.combinedWith(repeatedScenarioMarketData);

            assertThat(combinedData.ScenarioCount).isEqualTo(3);
            assertThat(combinedData.getValue(TEST_ID1).getValue(0)).isEqualTo(1.1);
            assertThat(combinedData.getValue(TEST_ID1).getValue(2)).isEqualTo(1.1);
            assertThat(combinedData.getValue(TEST_ID1).getValue(3)).isEqualTo(1.1);
            assertThat(combinedData.getValue(TEST_ID2)).isEqualTo(MarketDataBox.ofScenarioValues(2.0, 2.1, 2.2));
            assertThat(combinedData.getValue(TEST_ID3)).isEqualTo(MarketDataBox.ofScenarioValues(3.0, 3.1, 3.2));
            assertThat(combinedData.getTimeSeries(TEST_ID1)).isEqualTo(timeSeries1);
            assertThat(combinedData.getTimeSeries(TEST_ID2)).isEqualTo(timeSeries2a);
            assertThat(combinedData.getTimeSeries(TEST_ID3)).isEqualTo(timeSeries3);
        }
Exemplo n.º 5
0
        public virtual void test_quote_secenarioDefinition()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.calc.marketdata.PerturbationMapping<?>> perturbationMapping = new java.util.ArrayList<>();
            IList <PerturbationMapping <object> > perturbationMapping = new List <PerturbationMapping <object> >();
            int nScenarios = 3;

            foreach (KeyValuePair <QuoteId, double> entry in MARKET_QUOTES.entrySet())
            {
                DoubleArray shifts = DoubleArray.of(nScenarios, n => Math.Pow(0.9, n));
                ScenarioPerturbation <double> perturb = GenericDoubleShifts.of(ShiftType.SCALED, shifts);
                perturbationMapping.Add(PerturbationMapping.of(MarketDataFilter.ofId(entry.Key), perturb));
            }
            ScenarioDefinition    scenarioDefinition   = ScenarioDefinition.ofMappings(perturbationMapping);
            ScenarioMarketData    marketDataCalibrated = StandardComponents.marketDataFactory().createMultiScenario(REQUIREMENTS, SCENARIO_CONFIG, MARKET_DATA, REF_DATA, scenarioDefinition);
            Results               results = CALC_RUNNER.calculateMultiScenario(RULES, TARGETS, COLUMN, marketDataCalibrated, REF_DATA);
            CurrencyScenarioArray pvs     = results.get(0, 0, typeof(CurrencyScenarioArray)).Value;

            for (int i = 0; i < nScenarios; ++i)
            {
                ImmutableMap.Builder <QuoteId, double> builder = ImmutableMap.builder();
                foreach (KeyValuePair <QuoteId, double> entry in MARKET_QUOTES.entrySet())
                {
                    builder.put(entry.Key, entry.Value * Math.Pow(0.9, i));
                }
                ImmutableMarketData shiftedMarketData           = ImmutableMarketData.builder(VALUATION_DATE).addValueMap(builder.build()).addValueMap(MARKET_FX_QUOTES).build();
                MarketData          shiftedMarketDataCalibrated = StandardComponents.marketDataFactory().create(REQUIREMENTS, CONFIG, shiftedMarketData, REF_DATA);
                Results             shiftedResults = CALC_RUNNER.calculate(RULES, TARGETS, COLUMN, shiftedMarketDataCalibrated, REF_DATA);
                CurrencyAmount      pv             = shiftedResults.get(0, 0, typeof(CurrencyAmount)).Value;
                assertEquals(pvs.get(i), pv);
            }
        }
        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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Extracts the underlying quotes from the <seealso cref="RatesCurveInputs"/> instances and returns them in a map.
        /// </summary>
        /// <param name="valuationDate">  the valuation date </param>
        /// <param name="inputs">  input data for the curve </param>
        /// <param name="fixings">  the fixings </param>
        /// <returns> the underlying quotes from the input data </returns>
        private static MarketData inputsByKey(LocalDate valuationDate, IList <RatesCurveInputs> inputs, IDictionary <ObservableId, LocalDateDoubleTimeSeries> fixings)
        {
//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> marketDataMap = new java.util.HashMap<>();
            IDictionary <MarketDataId <object>, object> marketDataMap = new Dictionary <MarketDataId <object>, object>();

            foreach (RatesCurveInputs input in inputs)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<? extends com.opengamma.strata.data.MarketDataId<?>, ?> inputMarketData = input.getMarketData();
                IDictionary <MarketDataId <object>, ?> inputMarketData = input.MarketData;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.util.Map.Entry<? extends com.opengamma.strata.data.MarketDataId<?>, ?> entry : inputMarketData.entrySet())
                foreach (KeyValuePair <MarketDataId <object>, ?> entry in inputMarketData.SetOfKeyValuePairs())
                {
                    object existingValue = marketDataMap[entry.Key];

                    // If the same identifier is used by multiple different curves the corresponding market data value must be equal
                    if (existingValue == null)
                    {
                        marketDataMap[entry.Key] = entry.Value;
                    }
                    else if (!existingValue.Equals(entry.Value))
                    {
                        throw new System.ArgumentException(Messages.format("Multiple unequal values found for identifier {}. Values: {} and {}", entry.Key, existingValue, entry.Value));
                    }
                }
            }
            return(ImmutableMarketData.builder(valuationDate).values(marketDataMap).timeSeries(fixings).build());
        }
        protected internal virtual void testJacobian(IsdaCompliantCreditCurveCalibrator builder, LegalEntitySurvivalProbabilities curve, ImmutableCreditRatesProvider ratesProvider, IList <CdsIsdaCreditCurveNode> nodes, double[] quotes, double quoteScale, double eps)
        {
            LocalDate valuationDate      = curve.ValuationDate;
            int       nNode              = nodes.Count;
            IsdaCreditDiscountFactors df = (IsdaCreditDiscountFactors)curve.SurvivalProbabilities;
            CurveName name       = df.Curve.Name;
            int       nCurveNode = df.ParameterCount;

            for (int i = 0; i < nCurveNode; ++i)
            {
                double[] quotesUp = Arrays.copyOf(quotes, nNode);
                double[] quotesDw = Arrays.copyOf(quotes, nNode);
                quotesUp[i] += eps / quoteScale;
                quotesDw[i] -= eps / quoteScale;
                ImmutableMarketDataBuilder builderCreditUp = ImmutableMarketData.builder(valuationDate);
                ImmutableMarketDataBuilder builderCreditDw = ImmutableMarketData.builder(valuationDate);
                for (int j = 0; j < nNode; ++j)
                {
                    builderCreditUp.addValue(nodes[j].ObservableId, quotesUp[j] * quoteScale);
                    builderCreditDw.addValue(nodes[j].ObservableId, quotesDw[j] * quoteScale);
                }
                ImmutableMarketData       marketDataUp = builderCreditUp.build();
                ImmutableMarketData       marketDataDw = builderCreditDw.build();
                IsdaCreditDiscountFactors ccUp         = (IsdaCreditDiscountFactors)builder.calibrate(nodes, name, marketDataUp, ratesProvider, curve.SurvivalProbabilities.DayCount, curve.Currency, false, false, REF_DATA).SurvivalProbabilities;
                IsdaCreditDiscountFactors ccDw         = (IsdaCreditDiscountFactors)builder.calibrate(nodes, name, marketDataDw, ratesProvider, curve.SurvivalProbabilities.DayCount, curve.Currency, false, false, REF_DATA).SurvivalProbabilities;
                for (int j = 0; j < nNode; ++j)
                {
                    double computed = df.Curve.Metadata.findInfo(CurveInfoType.JACOBIAN).get().JacobianMatrix.get(j, i);
                    double expected = 0.5 * (ccUp.Curve.YValues.get(j) - ccDw.Curve.YValues.get(j)) / eps;
                    assertEquals(computed, expected, eps * 10d);
                }
            }
        }
Exemplo n.º 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();
        }
        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);
        }
        public virtual void test_initialGuess()
        {
            IborIborSwapCurveNode node = IborIborSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double     rate            = 0.035;
            MarketData marketData      = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();

            assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), 0d);
            assertEquals(node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), 1.0d);
        }
        static SyntheticRatesCurveCalibratorTest()
        {   // Fixing unnaturally high to see the difference in the calibration
            LocalDateDoubleTimeSeries tsEur3 = LocalDateDoubleTimeSeries.builder().put(VALUATION_DATE, 0.0200).build();
            LocalDateDoubleTimeSeries tsEur6 = LocalDateDoubleTimeSeries.builder().put(VALUATION_DATE, 0.0250).build();

            TS_LARGE[EUR_EURIBOR_3M] = tsEur3;
            TS_LARGE[EUR_EURIBOR_6M] = tsEur6;
            TS_LARGE_MD = ImmutableMarketData.builder(VALUATION_DATE).addTimeSeries(IndexQuoteId.of(EUR_EURIBOR_3M), tsEur3).addTimeSeries(IndexQuoteId.of(EUR_EURIBOR_6M), tsEur6).build();
        }
        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();
        }
        public virtual void test_initialGuess()
        {
            IborFixingDepositCurveNode node = IborFixingDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double     rate       = 0.035;
            MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();

            assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), rate);
            assertEquals(node.initialGuess(marketData, ValueType.FORWARD_RATE), rate);
            assertEquals(node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), Math.Exp(-rate * 0.25d), 1.0E-12);
        }
Exemplo n.º 16
0
        public virtual void test_initialGuess()
        {
            FixedOvernightSwapCurveNode node = FixedOvernightSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double     rate       = 0.035;
            MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();

            assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), rate);
            assertEquals(node.initialGuess(marketData, ValueType.FORWARD_RATE), rate);
            assertEquals(node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), Math.Exp(-rate * TENOR_10Y.Period.toTotalMonths() / 12d), 1.0E-12);
        }
Exemplo n.º 17
0
        public virtual void test_trade()
        {
            IborFutureCurveNode node   = IborFutureCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double          price      = 0.99;
            MarketData      marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, price).build();
            IborFutureTrade trade      = node.trade(1d, marketData, REF_DATA);
            IborFutureTrade expected   = TEMPLATE.createTrade(VAL_DATE, SecurityId.of(STANDARD_ID), 1L, 1.0, price + SPREAD, REF_DATA);

            assertEquals(trade, expected);
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Builds a market data snapshot from this environment.
        /// </summary>
        /// <param name="marketDataDate">  the date of the market data </param>
        /// <returns> the snapshot </returns>
        public virtual ImmutableMarketData buildSnapshot(LocalDate marketDataDate)
        {
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(marketDataDate);

            loadFixingSeries(builder);
            loadRatesCurves(builder, marketDataDate);
            loadQuotes(builder, marketDataDate);
            loadFxRates(builder);
            return(builder.build());
        }
        public virtual void test_initialGuess()
        {
            ThreeLegBasisSwapCurveNode node = ThreeLegBasisSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            LocalDate  valuationDate        = LocalDate.of(2015, 1, 22);
            double     rate       = 0.035;
            MarketData marketData = ImmutableMarketData.builder(valuationDate).addValue(QUOTE_ID, rate).build();

            assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), 0d);
            assertEquals(node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), 1.0d);
        }
        public virtual void test_trade()
        {
            ThreeLegBasisSwapCurveNode node = ThreeLegBasisSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double     rate       = 0.125;
            double     quantity   = -1234.56;
            MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();
            SwapTrade  trade      = node.trade(quantity, marketData, REF_DATA);
            SwapTrade  expected   = TEMPLATE.createTrade(VAL_DATE, BUY, -quantity, rate + SPREAD, REF_DATA);

            assertEquals(trade, expected);
        }
Exemplo n.º 21
0
        public virtual void test_trade()
        {
            FixedInflationSwapCurveNode node = FixedInflationSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            LocalDate  tradeDate             = LocalDate.of(2015, 1, 22);
            double     rate       = 0.125;
            double     quantity   = -1234.56;
            MarketData marketData = ImmutableMarketData.builder(tradeDate).addValue(QUOTE_ID, rate).build();
            SwapTrade  trade      = node.trade(quantity, marketData, REF_DATA);
            SwapTrade  expected   = TEMPLATE.createTrade(tradeDate, BUY, -quantity, rate + SPREAD, REF_DATA);

            assertEquals(trade, expected);
        }
        public virtual void test_metadata_last_fixing()
        {
            IborFixingDepositCurveNode node       = IborFixingDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD).withDate(CurveNodeDate.LAST_FIXING);
            ImmutableMarketData        marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, 0.0d).build();
            IborFixingDepositTrade     trade      = node.trade(1d, marketData, REF_DATA);
            ResolvedIborFixingDeposit  product    = trade.Product.resolve(REF_DATA);
            LocalDate fixingDate            = ((IborRateComputation)product.FloatingRate).FixingDate;
            DatedParameterMetadata metadata = node.metadata(VAL_DATE, REF_DATA);

            assertEquals(((TenorDateParameterMetadata)metadata).Date, fixingDate);
            assertEquals(((TenorDateParameterMetadata)metadata).Tenor.Period, TEMPLATE.DepositPeriod);
        }
Exemplo n.º 23
0
        public virtual void test_metadata_last_fixing()
        {
            IborFutureCurveNode    node       = IborFutureCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD, LABEL).withDate(CurveNodeDate.LAST_FIXING);
            ImmutableMarketData    marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, 0.0d).build();
            IborFutureTrade        trade      = node.trade(1d, marketData, REF_DATA);
            LocalDate              fixingDate = trade.Product.FixingDate;
            DatedParameterMetadata metadata   = node.metadata(VAL_DATE, REF_DATA);

            assertEquals(metadata.Date, fixingDate);
            LocalDate referenceDate = TEMPLATE.calculateReferenceDateFromTradeDate(VAL_DATE, REF_DATA);

            assertEquals(((YearMonthDateParameterMetadata)metadata).YearMonth, YearMonth.from(referenceDate));
        }
        public virtual void test_initialGuess()
        {
            FixedIborSwapCurveNode node = FixedIborSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double     rate             = 0.035;
            MarketData marketData       = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();

            assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), rate);
            assertEquals(node.initialGuess(marketData, ValueType.FORWARD_RATE), rate);
            double df = Math.Exp(-TENOR_10Y.get(ChronoUnit.YEARS) * rate);

            assertEquals(node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), df, TOLERANCE_DF);
            assertEquals(node.initialGuess(marketData, ValueType.PRICE_INDEX), 0d);
        }
        public virtual void test_metadata_last_fixing()
        {
            FraCurveNode           node          = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD).withDate(CurveNodeDate.LAST_FIXING);
            LocalDate              valuationDate = LocalDate.of(2015, 1, 22);
            ImmutableMarketData    marketData    = ImmutableMarketData.builder(valuationDate).addValue(QUOTE_ID, 0.0d).build();
            FraTrade               trade         = node.trade(1d, marketData, REF_DATA);
            ResolvedFra            resolved      = trade.Product.resolve(REF_DATA);
            LocalDate              fixingDate    = ((IborRateComputation)(resolved.FloatingRate)).FixingDate;
            DatedParameterMetadata metadata      = node.metadata(valuationDate, REF_DATA);

            assertEquals(((TenorDateParameterMetadata)metadata).Date, fixingDate);
            assertEquals(((TenorDateParameterMetadata)metadata).Tenor, TENOR_5M);
        }
Exemplo n.º 26
0
        public virtual void test_initialGuess()
        {
            IborFutureCurveNode node = IborFutureCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double     price         = 0.99;
            MarketData marketData    = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, price).build();

            assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), 1.0 - price, TOLERANCE_RATE);
            assertEquals(node.initialGuess(marketData, ValueType.FORWARD_RATE), 1.0 - price, TOLERANCE_RATE);
            double approximateMaturity = TEMPLATE.approximateMaturity(VAL_DATE);
            double df = Math.Exp(-approximateMaturity * (1.0 - price));

            assertEquals(node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), df, TOLERANCE_RATE);
            assertEquals(node.initialGuess(marketData, ValueType.UNKNOWN), 0.0d, TOLERANCE_RATE);
        }
Exemplo n.º 27
0
        public virtual void test_trade()
        {
            TermDepositCurveNode node          = TermDepositCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double           rate              = 0.035;
            MarketData       marketData        = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();
            TermDepositTrade trade             = node.trade(1d, marketData, REF_DATA);
            LocalDate        startDateExpected = PLUS_TWO_DAYS.adjust(VAL_DATE, REF_DATA);
            LocalDate        endDateExpected   = startDateExpected.plus(DEPOSIT_PERIOD);
            TermDeposit      depositExpected   = TermDeposit.builder().buySell(BuySell.BUY).currency(EUR).dayCount(ACT_360).startDate(startDateExpected).endDate(endDateExpected).notional(1.0d).businessDayAdjustment(BDA_MOD_FOLLOW).rate(rate + SPREAD).build();
            TradeInfo        tradeInfoExpected = TradeInfo.builder().tradeDate(VAL_DATE).build();

            assertEquals(trade.Product, depositExpected);
            assertEquals(trade.Info, tradeInfoExpected);
        }
Exemplo n.º 28
0
        public virtual void test_initialGuess()
        {
            FixedInflationSwapCurveNode node = FixedInflationSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            LocalDate valuationDate          = LocalDate.of(2015, 1, 22);
            double    rate               = 0.035;
            double    lastPriceIndex     = 123.4;
            LocalDateDoubleTimeSeries ts = LocalDateDoubleTimeSeries.builder().put(LocalDate.of(2024, 10, 31), lastPriceIndex).build();
            MarketData marketData        = ImmutableMarketData.builder(valuationDate).addValue(QUOTE_ID, rate).addTimeSeries(IndexQuoteId.of(PriceIndices.EU_EXT_CPI), ts).build();

            assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), rate);
            double priceIndexGuess = lastPriceIndex * Math.Pow(1.0d + rate, TENOR_10Y.get(ChronoUnit.YEARS));

            assertEquals(node.initialGuess(marketData, ValueType.PRICE_INDEX), priceIndexGuess, TOLERANCE_GUESS);
        }
        // obtains the data and calculates the grid of results
        private static void calculate(CalculationRunner runner)
        {
            // the trades that will have measures calculated
            IList <Trade> trades = createSwapTrades();

            // the columns, specifying the measures to be calculated
            IList <Column> columns = ImmutableList.of(Column.of(Measures.PRESENT_VALUE), Column.of(Measures.PAR_RATE), Column.of(Measures.PV01_MARKET_QUOTE_BUCKETED), Column.of(Measures.PV01_CALIBRATED_BUCKETED));

            // load quotes
            ImmutableMap <QuoteId, double> quotesCcp1 = QuotesCsvLoader.load(VAL_DATE, QUOTES_RESOURCE_CCP1);
            ImmutableMap <QuoteId, double> quotesCcp2 = QuotesCsvLoader.load(VAL_DATE, QUOTES_RESOURCE_CCP2);

            // load fixings
            ImmutableMap <ObservableId, LocalDateDoubleTimeSeries> fixings = FixingSeriesCsvLoader.load(FIXINGS_RESOURCE);

            // create the market data
            MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValueMap(quotesCcp1).addValueMap(quotesCcp2).addTimeSeriesMap(fixings).build();

            // the reference data, such as holidays and securities
            ReferenceData refData = ReferenceData.standard();

            // load the curve definition
            IDictionary <CurveGroupName, RatesCurveGroupDefinition> defnsCcp1 = RatesCalibrationCsvLoader.load(GROUPS_RESOURCE_CCP1, SETTINGS_RESOURCE_CCP1, CALIBRATION_RESOURCE_CCP1);
            IDictionary <CurveGroupName, RatesCurveGroupDefinition> defnsCcp2 = RatesCalibrationCsvLoader.load(GROUPS_RESOURCE_CCP2, SETTINGS_RESOURCE_CCP2, CALIBRATION_RESOURCE_CCP2);
            RatesCurveGroupDefinition curveGroupDefinitionCcp1 = defnsCcp1[CURVE_GROUP_NAME_CCP1].filtered(VAL_DATE, refData);
            RatesCurveGroupDefinition curveGroupDefinitionCcp2 = defnsCcp2[CURVE_GROUP_NAME_CCP2].filtered(VAL_DATE, refData);

            // the configuration that defines how to create the curves when a curve group is requested
            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(CURVE_GROUP_NAME_CCP1, curveGroupDefinitionCcp1).add(CURVE_GROUP_NAME_CCP2, curveGroupDefinitionCcp2).build();

            // the complete set of rules for calculating measures
            CalculationFunctions  functions       = StandardComponents.calculationFunctions();
            RatesMarketDataLookup ratesLookupCcp1 = RatesMarketDataLookup.of(curveGroupDefinitionCcp1);
            RatesMarketDataLookup ratesLookupCcp2 = RatesMarketDataLookup.of(curveGroupDefinitionCcp2);
            // choose RatesMarketDataLookup instance based on counterparty
            TradeCounterpartyCalculationParameter perCounterparty = TradeCounterpartyCalculationParameter.of(ImmutableMap.of(CCP1_ID, ratesLookupCcp1, CCP2_ID, ratesLookupCcp2), ratesLookupCcp1);
            CalculationRules rules = CalculationRules.of(functions, perCounterparty);

            // calibrate the curves and calculate the results
            MarketDataRequirements reqs = MarketDataRequirements.of(rules, trades, columns, refData);
            MarketData             calibratedMarketData = marketDataFactory().create(reqs, marketDataConfig, marketData, refData);
            Results results = runner.calculate(rules, trades, columns, calibratedMarketData, refData);

            // use the report runner to transform the engine results into a trade report
            ReportCalculationResults calculationResults = ReportCalculationResults.of(VAL_DATE, trades, columns, results, functions, refData);
            TradeReportTemplate      reportTemplate     = ExampleData.loadTradeReportTemplate("swap-report-template2");
            TradeReport tradeReport = TradeReport.of(calculationResults, reportTemplate);

            tradeReport.writeAsciiTable(System.out);
        }
        public virtual void test_initialGuess()
        {
            FraCurveNode node       = FraCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);
            double       rate       = 0.035;
            MarketData   marketData = ImmutableMarketData.builder(VAL_DATE).addValue(QUOTE_ID, rate).build();

            assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), rate);
            assertEquals(node.initialGuess(marketData, ValueType.FORWARD_RATE), rate);
            double approximateMaturity = TEMPLATE.PeriodToEnd.toTotalMonths() / 12.0d;
            double df = Math.Exp(-approximateMaturity * rate);

            assertEquals(node.initialGuess(marketData, ValueType.DISCOUNT_FACTOR), df);
            assertEquals(node.initialGuess(marketData, ValueType.PRICE_INDEX), 0d);
        }