findValue(row, leg, NOTIONAL_FINAL_EXCHANGE_FIELD) .map(s -> LoaderUtils.parseBoolean(s)) .ifPresent(v -> builder.finalExchange(v)); return builder.build();
private NotionalSchedule parseSwapNotionalSchedule(XmlElement legEl, XmlElement calcEl, FpmlDocument document) { // supported elements: // 'principalExchanges/initialExchange' // 'principalExchanges/finalExchange' // 'principalExchanges/intermediateExchange' // 'calculationPeriodAmount/calculation/notionalSchedule/notionalStepSchedule' // 'calculationPeriodAmount/calculation/notionalSchedule/notionalStepParameters' NotionalSchedule.Builder notionalScheduleBuilder = NotionalSchedule.builder(); // exchanges legEl.findChild("principalExchanges").ifPresent(el -> { notionalScheduleBuilder.initialExchange(Boolean.parseBoolean(el.getChild("initialExchange").getContent())); notionalScheduleBuilder.intermediateExchange( Boolean.parseBoolean(el.getChild("intermediateExchange").getContent())); notionalScheduleBuilder.finalExchange(Boolean.parseBoolean(el.getChild("finalExchange").getContent())); }); // notional schedule XmlElement notionalEl = calcEl.getChild("notionalSchedule"); XmlElement stepScheduleEl = notionalEl.getChild("notionalStepSchedule"); Optional<XmlElement> paramScheduleElOpt = notionalEl.findChild("notionalStepParameters"); double initialValue = document.parseDecimal(stepScheduleEl.getChild("initialValue")); ValueStepSequence seq = paramScheduleElOpt.map(el -> parseAmountSchedule(el, initialValue, document)).orElse(null); notionalScheduleBuilder.amount(parseSchedule(stepScheduleEl, initialValue, seq, document)); notionalScheduleBuilder.currency(document.parseCurrency(stepScheduleEl.getChild("currency"))); return notionalScheduleBuilder.build(); }
public void test_builder_FxResetSetsFlags() { FxResetCalculation fxReset = FxResetCalculation.builder() .referenceCurrency(GBP) .index(GBP_USD_WM) .fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)) .build(); NotionalSchedule test = NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(2000d)) .intermediateExchange(true) .finalExchange(true) .fxReset(fxReset) .build(); assertEquals(test.getCurrency(), USD); assertEquals(test.getAmount(), ValueSchedule.of(2000d)); assertEquals(test.getFxReset(), Optional.of(fxReset)); assertEquals(test.isInitialExchange(), false); assertEquals(test.isIntermediateExchange(), true); assertEquals(test.isFinalExchange(), true); }
.initialExchange(true) .intermediateExchange(true) .finalExchange(true) .build()) .calculation(FixedRateCalculation.builder()
.initialExchange(true) .intermediateExchange(true) .finalExchange(true) .build()) .calculation(IborRateCalculation.builder()
.currency(USD) .amount(ValueSchedule.of(500d)) .finalExchange(true) .initialExchange(true) .build())
.currency(USD) .amount(ValueSchedule.of(500d)) .finalExchange(true) .initialExchange(true) .build())
.build()) .notionalSchedule(NotionalSchedule.builder() .finalExchange(finalExchange) .initialExchange(initialExchange) .amount(ValueSchedule.of(NOTIONAL_EUR)) .build()) .notionalSchedule(NotionalSchedule.builder() .finalExchange(finalExchange) .initialExchange(initialExchange) .intermediateExchange(intermediateExchange)
.build()) .notionalSchedule(NotionalSchedule.builder() .finalExchange(true) .initialExchange(true) .amount(ValueSchedule.of(NOTIONAL_EUR)) .build()) .notionalSchedule(NotionalSchedule.builder() .finalExchange(true) .initialExchange(true) .amount(ValueSchedule.of(NOTIONAL_USD))
.currency(USD) .amount(ValueSchedule.of(500d)) .finalExchange(true) .initialExchange(true) .build())
.notionalSchedule(NotionalSchedule.builder() .currency(getCurrency()) .finalExchange(notionalExchange) .initialExchange(notionalExchange) .amount(ValueSchedule.of(notional)).build())
.currency(USD) .amount(ValueSchedule.of(1d)) .finalExchange(true) .initialExchange(true) .build())
.currency(GBP) .amount(ValueSchedule.of(1000d)) .finalExchange(true) .fxReset(FxResetCalculation.builder() .referenceCurrency(EUR)
public void coverage() { NotionalSchedule test = NotionalSchedule.of(GBP, 1000d); coverImmutableBean(test); NotionalSchedule test2 = NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(2000d)) .fxReset(FxResetCalculation.builder() .referenceCurrency(GBP) .index(GBP_USD_WM) .fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)) .build()) .initialExchange(true) .intermediateExchange(true) .finalExchange(true) .build(); coverBeanEquals(test, test2); }