/** * Creates a curve group using a curve group definition and some existing curves. * <p> * If there are curves named in the definition which are not present in the curves the group is built using * whatever curves are available. * <p> * If there are multiple curves with the same name in the curves one of them is arbitrarily chosen. * <p> * Multiple curves with the same name are allowed to support the use case where the list contains the same * curve multiple times. This means the caller doesn't have to filter the input curves to remove duplicates. * * @param curveGroupDefinition the definition of a curve group * @param curves some curves * @return a curve group built from the definition and the list of curves */ public static RatesCurveGroup ofCurves(RatesCurveGroupDefinition curveGroupDefinition, Curve... curves) { return ofCurves(curveGroupDefinition, Arrays.asList(curves)); }
RatesCurveGroup curveGroup = RatesCurveGroup.ofCurves(groupDefinition, entry.getValue().values()); builder.put(entry.getKey(), curveGroup);
public void test_ofCurves_duplicateCurveName() { RatesCurveGroupDefinition definition = RatesCurveGroupDefinition.builder() .name(CurveGroupName.of("group")) .addForwardCurve(IBOR_NAME, USD_LIBOR_1M, USD_LIBOR_2M) .build(); RatesCurveGroup group = RatesCurveGroup.ofCurves(definition, IBOR_CURVE, IBOR_CURVE); assertThat(group.findForwardCurve(USD_LIBOR_1M)).hasValue(IBOR_CURVE); assertThat(group.findForwardCurve(USD_LIBOR_2M)).hasValue(IBOR_CURVE); }
public void test_ofCurves() { RatesCurveGroupDefinition definition = RatesCurveGroupDefinition.builder() .name(CurveGroupName.of("group")) .addCurve(DISCOUNT_NAME, GBP, GBP_LIBOR_1M) .addForwardCurve(IBOR_NAME, USD_LIBOR_1M, USD_LIBOR_2M) .addForwardCurve(OVERNIGHT_NAME, EUR_EONIA) .build(); RatesCurveGroup group = RatesCurveGroup.ofCurves(definition, DISCOUNT_CURVE, OVERNIGHT_CURVE, IBOR_CURVE); assertThat(group.findDiscountCurve(GBP)).hasValue(DISCOUNT_CURVE); assertThat(group.findForwardCurve(USD_LIBOR_1M)).hasValue(IBOR_CURVE); assertThat(group.findForwardCurve(USD_LIBOR_2M)).hasValue(IBOR_CURVE); assertThat(group.findForwardCurve(EUR_EONIA)).hasValue(OVERNIGHT_CURVE); }