/** * Obtains a template based on the specified period and convention. * <p> * The near date is equal to the spot date. * The period from the spot date to the far date is specified * <p> * For example, a '6M' FX swap has a near leg on the spot date and a period from spot to the far date of 6 months * * @param periodToFar the period between the spot date and the far date * @param convention the market convention * @return the template */ public static FxSwapTemplate of(Period periodToFar, FxSwapConvention convention) { return FxSwapTemplate.builder() .periodToNear(Period.ZERO) .periodToFar(periodToFar) .convention(convention).build(); }
/** * Obtains a template based on the specified periods and convention. * <p> * Both the period from the spot date to the near date and far date are specified. * <p> * For example, a '3M x 6M' FX swap has a period from spot to the start date of 3 months and * a period from spot to the far date of 6 months * * @param periodToNear the period between the spot date and the near date * @param periodToFar the period between the spot date and the far date * @param convention the market convention * @return the template */ public static FxSwapTemplate of(Period periodToNear, Period periodToFar, FxSwapConvention convention) { return FxSwapTemplate.builder() .periodToNear(periodToNear) .periodToFar(periodToFar) .convention(convention).build(); }
public void test_builder_insufficientInfo() { assertThrowsIllegalArg(() -> FxSwapTemplate.builder().convention(CONVENTION).build()); assertThrowsIllegalArg(() -> FxSwapTemplate.builder().periodToNear(NEAR_PERIOD).build()); assertThrowsIllegalArg(() -> FxSwapTemplate.builder().periodToFar(FAR_PERIOD).build()); }