public virtual void test_builder4() { RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_NAME1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build(); assertEquals(test.Name, CurveGroupName.of("Test")); assertEquals(test.Entries, ImmutableList.of(ENTRY3)); assertEquals(test.findEntry(CurveName.of("Test")), ENTRY3); assertEquals(test.findEntry(CurveName.of("Test2")), null); assertEquals(test.findEntry(CurveName.of("Rubbish")), null); }
public virtual void test_builder3() { RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addDiscountCurve(CURVE_NAME1, GBP).addForwardCurve(CURVE_NAME1, GBP_SONIA).addForwardCurve(CURVE_NAME1, GBP_LIBOR_1W).addForwardCurve(CURVE_NAME2, GBP_LIBOR_1M, GBP_LIBOR_3M).build(); assertEquals(test.Name, CurveGroupName.of("Test")); assertEquals(test.Entries, ImmutableList.of(ENTRY1, ENTRY2)); assertEquals(test.findEntry(CurveName.of("Test")), ENTRY1); assertEquals(test.findEntry(CurveName.of("Test2")), ENTRY2); assertEquals(test.findEntry(CurveName.of("Rubbish")), null); }
public virtual void test_builder_seasonality() { RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addSeasonality(CURVE_NAME_I, SEASONALITY_ADDITIVE_DEF).build(); assertEquals(test.Name, CurveGroupName.of("Test")); assertEquals(test.Entries, ImmutableList.of(ENTRY3)); assertEquals(test.findEntry(CurveName.of("Test")), ENTRY3); assertEquals(test.findEntry(CurveName.of("Test2")), null); assertEquals(test.findEntry(CurveName.of("Rubbish")), null); assertEquals(test.findCurveDefinition(CurveName.of("Test")), CURVE_DEFN1); assertEquals(test.findCurveDefinition(CurveName.of("Test2")), null); assertEquals(test.findCurveDefinition(CurveName.of("Rubbish")), null); ImmutableMap <CurveName, SeasonalityDefinition> seasonMap = test.SeasonalityDefinitions; assertTrue(seasonMap.size() == 1); assertEquals(seasonMap.get(CURVE_NAME_I), SEASONALITY_ADDITIVE_DEF); }
/// <summary> /// Obtains a generator from an existing provider and definition. /// </summary> /// <param name="knownProvider"> the underlying known provider </param> /// <param name="groupDefn"> the curve group definition </param> /// <param name="refData"> the reference data to use </param> /// <returns> the generator </returns> public static ImmutableRatesProviderGenerator of(ImmutableRatesProvider knownProvider, RatesCurveGroupDefinition groupDefn, ReferenceData refData) { IList <CurveDefinition> curveDefns = new List <CurveDefinition>(); IList <CurveMetadata> curveMetadata = new List <CurveMetadata>(); SetMultimap <CurveName, Currency> discountNames = HashMultimap.create(); SetMultimap <CurveName, Index> indexNames = HashMultimap.create(); foreach (CurveDefinition curveDefn in groupDefn.CurveDefinitions) { curveDefns.Add(curveDefn); curveMetadata.Add(curveDefn.metadata(knownProvider.ValuationDate, refData)); CurveName curveName = curveDefn.Name; // A curve group is guaranteed to include an entry for every definition RatesCurveGroupEntry entry = groupDefn.findEntry(curveName).get(); ISet <Currency> ccy = entry.DiscountCurrencies; discountNames.putAll(curveName, ccy); indexNames.putAll(curveName, entry.Indices); } return(new ImmutableRatesProviderGenerator(knownProvider, curveDefns, curveMetadata, discountNames, indexNames)); }