diff --git a/modules/product/src/main/java/com/opengamma/strata/product/swap/type/InflationRateSwapLegConvention.java b/modules/product/src/main/java/com/opengamma/strata/product/swap/type/InflationRateSwapLegConvention.java index b77f99a509..d0f3998105 100644 --- a/modules/product/src/main/java/com/opengamma/strata/product/swap/type/InflationRateSwapLegConvention.java +++ b/modules/product/src/main/java/com/opengamma/strata/product/swap/type/InflationRateSwapLegConvention.java @@ -113,24 +113,52 @@ public final class InflationRateSwapLegConvention private final BusinessDayAdjustment accrualBusinessDayAdjustment; //------------------------------------------------------------------------- + + /** + * Obtains a convention based on the specified index, defaulting the PriceIndexCalculationMethod to MONTHLY. + *

+ * The standard market convention for an Inflation rate leg is based on the index. + * Use the {@linkplain #builder() builder} for unusual conventions. + * + * @param index the index, the market convention values are extracted from the index + * @param lag the lag between the price index and the accrual date, typically a number of months + * @param businessDayAdjustment the business day + * @return the convention + * @deprecated Use of() method which takes {@link PriceIndexCalculationMethod} parameter + */ + @Deprecated + public static InflationRateSwapLegConvention of( + PriceIndex index, + Period lag, + BusinessDayAdjustment businessDayAdjustment) { + return of(index, lag, PriceIndexCalculationMethod.MONTHLY, businessDayAdjustment); + } + /** * Obtains a convention based on the specified index. *

* The standard market convention for an Inflation rate leg is based on the index. * Use the {@linkplain #builder() builder} for unusual conventions. - * + * * @param index the index, the market convention values are extracted from the index * @param lag the lag between the price index and the accrual date, typically a number of months - * @param businessDayAdjustment the business day + * @param priceIndexCalculationMethod the price index calculation method, typically interpolated or monthly + * @param businessDayAdjustment the business day * @return the convention */ public static InflationRateSwapLegConvention of( PriceIndex index, Period lag, + PriceIndexCalculationMethod priceIndexCalculationMethod, BusinessDayAdjustment businessDayAdjustment) { - return new InflationRateSwapLegConvention(index, lag, PriceIndexCalculationMethod.MONTHLY, false, - DaysAdjustment.NONE, businessDayAdjustment); + return new InflationRateSwapLegConvention( + index, + lag, + priceIndexCalculationMethod, + false, + DaysAdjustment.NONE, + businessDayAdjustment); } //------------------------------------------------------------------------- @@ -140,9 +168,10 @@ private static void applyDefaults(Builder builder) { } //------------------------------------------------------------------------- + /** * Gets the currency of the leg from the index. - * + * * @return the currency */ public Currency getCurrency() { @@ -150,6 +179,7 @@ public Currency getCurrency() { } //------------------------------------------------------------------------- + /** * Creates a leg based on this convention. *

@@ -158,10 +188,10 @@ public Currency getCurrency() { * If the leg is 'Pay', the fixed rate is paid to the counterparty. * If the leg is 'Receive', the fixed rate is received from the counterparty. * - * @param startDate the start date - * @param endDate the end date - * @param payReceive determines if the leg is to be paid or received - * @param notional the business day adjustment to apply to accrual schedule dates + * @param startDate the start date + * @param endDate the end date + * @param payReceive determines if the leg is to be paid or received + * @param notional the business day adjustment to apply to accrual schedule dates * @return the leg */ public RateCalculationSwapLeg toLeg( diff --git a/modules/product/src/main/java/com/opengamma/strata/product/swap/type/StandardFixedInflationSwapConventions.java b/modules/product/src/main/java/com/opengamma/strata/product/swap/type/StandardFixedInflationSwapConventions.java index e3a3f931ed..6751811ff8 100644 --- a/modules/product/src/main/java/com/opengamma/strata/product/swap/type/StandardFixedInflationSwapConventions.java +++ b/modules/product/src/main/java/com/opengamma/strata/product/swap/type/StandardFixedInflationSwapConventions.java @@ -28,6 +28,7 @@ import com.opengamma.strata.basics.index.PriceIndices; import com.opengamma.strata.basics.schedule.Frequency; import com.opengamma.strata.product.swap.CompoundingMethod; +import com.opengamma.strata.product.swap.PriceIndexCalculationMethod; /** * Fixed-Inflation swap conventions. @@ -51,7 +52,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "GBP-FIXED-ZC-GB-HCIP", fixedLegZcConvention(GBP, GBLO), - InflationRateSwapLegConvention.of(PriceIndices.GB_HICP, LAG_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)), + InflationRateSwapLegConvention.of( + PriceIndices.GB_HICP, + LAG_2M, + PriceIndexCalculationMethod.MONTHLY, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)), DaysAdjustment.ofBusinessDays(2, GBLO)); /** @@ -62,7 +67,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "GBP-FIXED-ZC-GB-RPI", fixedLegZcConvention(GBP, GBLO), - InflationRateSwapLegConvention.of(PriceIndices.GB_RPI, LAG_2M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)), + InflationRateSwapLegConvention.of( + PriceIndices.GB_RPI, + LAG_2M, + PriceIndexCalculationMethod.MONTHLY, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)), DaysAdjustment.ofBusinessDays(2, GBLO)); /** @@ -73,7 +82,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "GBP-FIXED-ZC-GB-RPIX", fixedLegZcConvention(GBP, GBLO), - InflationRateSwapLegConvention.of(PriceIndices.GB_RPIX, LAG_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)), + InflationRateSwapLegConvention.of( + PriceIndices.GB_RPIX, + LAG_2M, + PriceIndexCalculationMethod.MONTHLY, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO)), DaysAdjustment.ofBusinessDays(2, GBLO)); /** @@ -84,7 +97,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "CHF-FIXED-ZC-CH-CPI", fixedLegZcConvention(CHF, CHZU), - InflationRateSwapLegConvention.of(PriceIndices.CH_CPI, LAG_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, CHZU)), + InflationRateSwapLegConvention.of( + PriceIndices.CH_CPI, + LAG_3M, + PriceIndexCalculationMethod.MONTHLY, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, CHZU)), DaysAdjustment.ofBusinessDays(2, CHZU)); /** @@ -95,7 +112,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "EUR-FIXED-ZC-EU-AI-CPI", fixedLegZcConvention(EUR, EUTA), - InflationRateSwapLegConvention.of(PriceIndices.EU_AI_CPI, LAG_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA)), + InflationRateSwapLegConvention.of( + PriceIndices.EU_AI_CPI, + LAG_3M, + PriceIndexCalculationMethod.MONTHLY, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA)), DaysAdjustment.ofBusinessDays(2, EUTA)); /** @@ -106,7 +127,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "EUR-FIXED-ZC-EU-EXT-CPI", fixedLegZcConvention(EUR, EUTA), - InflationRateSwapLegConvention.of(PriceIndices.EU_EXT_CPI, LAG_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA)), + InflationRateSwapLegConvention.of( + PriceIndices.EU_EXT_CPI, + LAG_3M, + PriceIndexCalculationMethod.MONTHLY, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, EUTA)), DaysAdjustment.ofBusinessDays(2, EUTA)); /** @@ -117,7 +142,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "JPY-FIXED-ZC-JP-CPI", fixedLegZcConvention(JPY, JPTO), - InflationRateSwapLegConvention.of(PriceIndices.JP_CPI_EXF, LAG_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, JPTO)), + InflationRateSwapLegConvention.of( + PriceIndices.JP_CPI_EXF, + LAG_3M, + PriceIndexCalculationMethod.INTERPOLATED_JAPAN, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, JPTO)), DaysAdjustment.ofBusinessDays(2, JPTO)); /** @@ -128,7 +157,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "USD-FIXED-ZC-US-CPI", fixedLegZcConvention(USD, USNY), - InflationRateSwapLegConvention.of(PriceIndices.US_CPI_U, LAG_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, USNY)), + InflationRateSwapLegConvention.of( + PriceIndices.US_CPI_U, + LAG_3M, + PriceIndexCalculationMethod.INTERPOLATED, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, USNY)), DaysAdjustment.ofBusinessDays(2, USNY)); /** @@ -139,7 +172,11 @@ final class StandardFixedInflationSwapConventions { ImmutableFixedInflationSwapConvention.of( "EUR-FIXED-ZC-FR-CPI", fixedLegZcConvention(EUR, EUTA), - InflationRateSwapLegConvention.of(PriceIndices.FR_EXT_CPI, LAG_3M, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, FRPA)), + InflationRateSwapLegConvention.of( + PriceIndices.FR_EXT_CPI, + LAG_3M, + PriceIndexCalculationMethod.MONTHLY, + BusinessDayAdjustment.of(MODIFIED_FOLLOWING, FRPA)), DaysAdjustment.ofBusinessDays(2, EUTA)); // Create a zero-coupon fixed leg convention diff --git a/modules/product/src/test/java/com/opengamma/strata/product/swap/type/FixedInflationSwapConventionTest.java b/modules/product/src/test/java/com/opengamma/strata/product/swap/type/FixedInflationSwapConventionTest.java index 8f633839b5..29ca7d4978 100644 --- a/modules/product/src/test/java/com/opengamma/strata/product/swap/type/FixedInflationSwapConventionTest.java +++ b/modules/product/src/test/java/com/opengamma/strata/product/swap/type/FixedInflationSwapConventionTest.java @@ -22,6 +22,7 @@ import static com.opengamma.strata.product.common.BuySell.BUY; import static com.opengamma.strata.product.common.PayReceive.PAY; import static com.opengamma.strata.product.common.PayReceive.RECEIVE; +import static com.opengamma.strata.product.swap.PriceIndexCalculationMethod.MONTHLY; import static org.testng.Assert.assertEquals; import java.time.LocalDate; @@ -56,9 +57,9 @@ public class FixedInflationSwapConventionTest { private static final FixedRateSwapLegConvention FIXED = fixedLegZcConvention(GBP, GBLO); private static final FixedRateSwapLegConvention FIXED2 = FixedRateSwapLegConvention.of(GBP, ACT_365F, P3M, BDA_MOD_FOLLOW); - private static final InflationRateSwapLegConvention INFL = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, BDA_MOD_FOLLOW); - private static final InflationRateSwapLegConvention INFL2 = InflationRateSwapLegConvention.of(GB_RPI, LAG_3M, BDA_MOD_FOLLOW); - private static final InflationRateSwapLegConvention INFL3 = InflationRateSwapLegConvention.of(GB_RPIX, LAG_3M, BDA_MOD_FOLLOW); + private static final InflationRateSwapLegConvention INFL = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, MONTHLY, BDA_MOD_FOLLOW); + private static final InflationRateSwapLegConvention INFL2 = InflationRateSwapLegConvention.of(GB_RPI, LAG_3M, MONTHLY, BDA_MOD_FOLLOW); + private static final InflationRateSwapLegConvention INFL3 = InflationRateSwapLegConvention.of(GB_RPIX, LAG_3M, MONTHLY, BDA_MOD_FOLLOW); //------------------------------------------------------------------------- public void test_of() { diff --git a/modules/product/src/test/java/com/opengamma/strata/product/swap/type/FixedInflationSwapTemplateTest.java b/modules/product/src/test/java/com/opengamma/strata/product/swap/type/FixedInflationSwapTemplateTest.java index 0a4e6c906c..ca33022f5b 100644 --- a/modules/product/src/test/java/com/opengamma/strata/product/swap/type/FixedInflationSwapTemplateTest.java +++ b/modules/product/src/test/java/com/opengamma/strata/product/swap/type/FixedInflationSwapTemplateTest.java @@ -25,6 +25,8 @@ import static com.opengamma.strata.product.common.BuySell.BUY; import static com.opengamma.strata.product.common.PayReceive.PAY; import static com.opengamma.strata.product.common.PayReceive.RECEIVE; +import static com.opengamma.strata.product.swap.PriceIndexCalculationMethod.INTERPOLATED; +import static com.opengamma.strata.product.swap.PriceIndexCalculationMethod.MONTHLY; import static org.testng.Assert.assertEquals; import java.time.LocalDate; @@ -58,8 +60,8 @@ public class FixedInflationSwapTemplateTest { FixedRateSwapLegConvention.of(GBP, ACT_360, P6M, BDA_FOLLOW); private static final FixedRateSwapLegConvention FIXED2 = FixedRateSwapLegConvention.of(USD, ACT_365F, P3M, BDA_MOD_FOLLOW); - private static final InflationRateSwapLegConvention INFL = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, BDA_MOD_FOLLOW); - private static final InflationRateSwapLegConvention INFL2 = InflationRateSwapLegConvention.of(US_CPI_U, LAG_3M, BDA_MOD_FOLLOW); + private static final InflationRateSwapLegConvention INFL = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, MONTHLY, BDA_MOD_FOLLOW); + private static final InflationRateSwapLegConvention INFL2 = InflationRateSwapLegConvention.of(US_CPI_U, LAG_3M, INTERPOLATED, BDA_MOD_FOLLOW); private static final FixedInflationSwapConvention CONV = ImmutableFixedInflationSwapConvention.of( NAME, FIXED, diff --git a/modules/product/src/test/java/com/opengamma/strata/product/swap/type/InflationRateSwapLegConventionTest.java b/modules/product/src/test/java/com/opengamma/strata/product/swap/type/InflationRateSwapLegConventionTest.java index d427718435..2ce5928585 100644 --- a/modules/product/src/test/java/com/opengamma/strata/product/swap/type/InflationRateSwapLegConventionTest.java +++ b/modules/product/src/test/java/com/opengamma/strata/product/swap/type/InflationRateSwapLegConventionTest.java @@ -14,6 +14,7 @@ import static com.opengamma.strata.collect.TestHelper.coverBeanEquals; import static com.opengamma.strata.collect.TestHelper.coverImmutableBean; import static com.opengamma.strata.product.common.PayReceive.PAY; +import static com.opengamma.strata.product.swap.PriceIndexCalculationMethod.MONTHLY; import static org.testng.Assert.assertEquals; import java.time.LocalDate; @@ -44,10 +45,10 @@ public class InflationRateSwapLegConventionTest { //------------------------------------------------------------------------- public void test_of() { - InflationRateSwapLegConvention test = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, BDA_MOD_FOLLOW); + InflationRateSwapLegConvention test = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, MONTHLY, BDA_MOD_FOLLOW); assertEquals(test.getIndex(), GB_HICP); assertEquals(test.getLag(), LAG_3M); - assertEquals(test.getIndexCalculationMethod(), PriceIndexCalculationMethod.MONTHLY); + assertEquals(test.getIndexCalculationMethod(), MONTHLY); assertEquals(test.isNotionalExchange(), false); assertEquals(test.getCurrency(), GBP); } @@ -59,7 +60,7 @@ public void test_builder() { .build(); assertEquals(test.getIndex(), GB_HICP); assertEquals(test.getLag(), LAG_3M); - assertEquals(test.getIndexCalculationMethod(), PriceIndexCalculationMethod.MONTHLY); + assertEquals(test.getIndexCalculationMethod(), MONTHLY); assertEquals(test.isNotionalExchange(), false); assertEquals(test.getCurrency(), GBP); } @@ -85,7 +86,7 @@ public void test_builderAllSpecified() { //------------------------------------------------------------------------- public void test_toLeg() { - InflationRateSwapLegConvention base = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, BDA_MOD_FOLLOW); + InflationRateSwapLegConvention base = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, MONTHLY, BDA_MOD_FOLLOW); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg( @@ -107,7 +108,7 @@ public void test_toLeg() { .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) - .calculation(InflationRateCalculation.of(GB_HICP, 3, PriceIndexCalculationMethod.MONTHLY)) + .calculation(InflationRateCalculation.of(GB_HICP, 3, MONTHLY)) .build(); assertEquals(test, expected); } @@ -129,7 +130,7 @@ public void coverage() { } public void test_serialization() { - InflationRateSwapLegConvention test = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, BDA_MOD_FOLLOW); + InflationRateSwapLegConvention test = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, MONTHLY, BDA_MOD_FOLLOW); assertSerialization(test); }