Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public FxResetNotionalExchange adjustPaymentDate(TemporalAdjuster adjuster) {
return adjusted.equals(paymentDate) ? this : new FxResetNotionalExchange(notionalAmount, adjusted, observation);
}

@Override
public boolean isKnownAmountAt(LocalDate date) {
return !observation.getFixingDate().isAfter(date);
}

//------------------------- AUTOGENERATED START -------------------------
/**
* The meta-bean for {@code FxResetNotionalExchange}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ public NotionalExchange adjustPaymentDate(TemporalAdjuster adjuster) {
return of(payment.getValue(), adjusted);
}

@Override
public boolean isKnownAmountAt(LocalDate date) {
return true;
}

//------------------------- AUTOGENERATED START -------------------------
/**
* The meta-bean for {@code NotionalExchange}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,15 @@ public interface SwapPaymentEvent {
*/
public abstract SwapPaymentEvent adjustPaymentDate(TemporalAdjuster adjuster);

//-------------------------------------------------------------------------
/**
* Checks whether the payment amount of an event is known at a given date.
* <p>
* Each payment event may be a known amount at a given date, else it could be fixed at a later date
*
* @param date the date to check whether payment amount is known or not
* @return true if payment is fixed at given date
*/
public abstract boolean isKnownAmountAt(LocalDate date);

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class FxResetNotionalExchangeTest {
private static final ReferenceData REF_DATA = ReferenceData.standard();
private static final LocalDate DATE_2014_03_28 = date(2014, 3, 28);
private static final LocalDate DATE_2014_06_30 = date(2014, 6, 30);
private static final LocalDate DATE_2013_12_30 = date(2013, 12, 30);

@Test
public void test_of() {
Expand Down Expand Up @@ -67,6 +68,15 @@ public void test_adjustPaymentDate() {
assertThat(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d -> d.plusDays(2)))).isEqualTo(expected);
}

@Test
public void test_isPaymentFixedAt() {
FxResetNotionalExchange test = FxResetNotionalExchange.of(
CurrencyAmount.of(USD, 1000d), DATE_2014_06_30, FxIndexObservation.of(GBP_USD_WM, DATE_2014_03_28, REF_DATA));
assertThat(test.isKnownAmountAt(DATE_2014_06_30)).isTrue();
assertThat(test.isKnownAmountAt(DATE_2014_03_28)).isTrue();
assertThat(test.isKnownAmountAt(DATE_2013_12_30)).isFalse();
}

//-------------------------------------------------------------------------
@Test
public void coverage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
*/
public class NotionalExchangeTest {

private static final LocalDate DATE_2013_06_30 = date(2013, 6, 30);
private static final LocalDate DATE_2014_06_30 = date(2014, 6, 30);
private static final LocalDate DATE_2015_06_30 = date(2015, 6, 30);
private static final CurrencyAmount GBP_1000 = CurrencyAmount.of(GBP, 1000d);

@Test
Expand Down Expand Up @@ -66,6 +68,14 @@ public void test_adjustPaymentDate() {
assertThat(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d -> d.plusDays(2)))).isEqualTo(expected);
}

@Test
public void test_isPaymentFixedAt() {
NotionalExchange test = NotionalExchange.of(GBP_1000, DATE_2014_06_30);
assertThat(test.isKnownAmountAt(DATE_2013_06_30)).isTrue();
assertThat(test.isKnownAmountAt(DATE_2014_06_30)).isTrue();
assertThat(test.isKnownAmountAt(DATE_2015_06_30)).isTrue();
}

//-------------------------------------------------------------------------
@Test
public void coverage() {
Expand Down