Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SXSD-8081: The CNY accrual schedule should not be adjusted inside of the payment period #19

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-examples</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<packaging>jar</packaging>
<name>Strata-Examples</name>
<description>Example code to demonstrate use of Strata</description>
Expand Down
2 changes: 1 addition & 1 deletion modules/basics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-basics</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/calc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-calc</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/collect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-collect</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-data</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-loader</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/market/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-market</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/math/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-math</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/measure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-measure</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<packaging>pom</packaging>
<name>Strata-Parent</name>
<description>OpenGamma Strata Parent</description>
Expand Down
2 changes: 1 addition & 1 deletion modules/pricer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-pricer</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-product</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,20 @@ public ResolvedSwapLeg resolve(ReferenceData refData) {

private boolean validPaymentAndAccrualFrequencyCombination() {
try {
if (paymentSchedule.getPaymentFrequency().isTerm()) {
return true;
}
paymentSchedule.getPaymentFrequency().exactDivide(accrualSchedule.getFrequency());
return true;
} catch (IllegalArgumentException ex) {
return false;
boolean isTermPayFrequency = paymentSchedule.getPaymentFrequency().isTerm();
boolean isWeekBased = accrualSchedule.getFrequency().isWeekBased();

// short-circuit if accrual frequency is week-based, since payment frequency driven approach
// should be used, even when payment freq == TERM
if (isWeekBased) {
return false;
}

// return false, unless payment frequency is TERM (where stubs can be used)
return isTermPayFrequency;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static com.opengamma.strata.basics.schedule.Frequency.P1W;
import static com.opengamma.strata.basics.schedule.Frequency.P2M;
import static com.opengamma.strata.basics.schedule.Frequency.P3M;
import static com.opengamma.strata.basics.schedule.Frequency.TERM;
import static com.opengamma.strata.basics.schedule.StubConvention.SMART_FINAL;
import static com.opengamma.strata.basics.schedule.StubConvention.SMART_INITIAL;
import static com.opengamma.strata.collect.TestHelper.assertSerialization;
Expand Down Expand Up @@ -868,6 +869,84 @@ public void test_inflation_fixed() {
assertThat(testExpand).isEqualTo(expected);
}

@Test
public void test_resolve_weeklyAccruals_termPayments_fixedRate() {
// test case
RateCalculationSwapLeg test = RateCalculationSwapLeg.builder()
.payReceive(PAY)
.accrualSchedule(PeriodicSchedule.builder()
.startDate(DATE_01_05)
.endDate(DATE_02_07)
.frequency(P1W)
.businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO))
.stubConvention(SMART_FINAL)
.build())
.paymentSchedule(PaymentSchedule.builder()
.paymentFrequency(TERM)
.paymentDateOffset(PLUS_TWO_DAYS)
.build())
.notionalSchedule(NotionalSchedule.of(GBP, 1000d))
.calculation(FixedRateCalculation.builder()
.dayCount(ACT_365F)
.rate(ValueSchedule.of(0.025d))
.build())
.build();
// expected
RatePaymentPeriod rpp1 = RatePaymentPeriod.builder()
.paymentDate(DATE_02_11)
.accrualPeriods(
RateAccrualPeriod.builder()
.startDate(DATE_01_06)
.endDate(DATE_01_13)
.unadjustedStartDate(DATE_01_06)
.unadjustedEndDate(DATE_01_13)
.yearFraction(ACT_365F.yearFraction(DATE_01_06, DATE_01_13))
.rateComputation(FixedRateComputation.of(0.025d))
.build(),
RateAccrualPeriod.builder()
.startDate(DATE_01_13)
.endDate(DATE_01_20)
.unadjustedStartDate(DATE_01_13)
.unadjustedEndDate(DATE_01_20)
.yearFraction(ACT_365F.yearFraction(DATE_01_13, DATE_01_20))
.rateComputation(FixedRateComputation.of(0.025d))
.build(),
RateAccrualPeriod.builder()
.startDate(DATE_01_20)
.endDate(DATE_01_27)
.unadjustedStartDate(DATE_01_20)
.unadjustedEndDate(DATE_01_27)
.yearFraction(ACT_365F.yearFraction(DATE_01_20, DATE_01_27))
.rateComputation(FixedRateComputation.of(0.025d))
.build(),
RateAccrualPeriod.builder()
.startDate(DATE_01_27)
.endDate(DATE_02_03)
.unadjustedStartDate(DATE_01_27)
.unadjustedEndDate(DATE_02_03)
.yearFraction(ACT_365F.yearFraction(DATE_01_27, DATE_02_03))
.rateComputation(FixedRateComputation.of(0.025d))
.build(),
RateAccrualPeriod.builder()
.startDate(DATE_02_03)
.endDate(DATE_02_07)
.unadjustedStartDate(DATE_02_03)
.unadjustedEndDate(DATE_02_07)
.yearFraction(ACT_365F.yearFraction(DATE_02_03, DATE_02_07))
.rateComputation(FixedRateComputation.of(0.025d))
.build())
.dayCount(ACT_365F)
.currency(GBP)
.notional(-1000d)
.build();
// assertion
assertThat(test.resolve(REF_DATA)).isEqualTo(ResolvedSwapLeg.builder()
.type(FIXED)
.payReceive(PAY)
.paymentPeriods(rpp1)
.build());
}

@Test
public void test_resolve_weeklyAccruals_monthlyPayments_fixedRate() {
// test case
Expand Down
2 changes: 1 addition & 1 deletion modules/report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-parent</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>strata-report</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.opengamma.strata</groupId>
<artifactId>strata-root</artifactId>
<version>2.12.22-xplain-4</version>
<version>2.12.22-xplain-5</version>
<packaging>pom</packaging>
<name>Strata-Root</name>
<description>OpenGamma Strata root</description>
Expand Down
Loading