.ifPresent(v -> builder.initialExchange(v)); findValue(row, leg, NOTIONAL_INTERMEDIATE_EXCHANGE_FIELD) .map(s -> LoaderUtils.parseBoolean(s))
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(); }
.amount(ValueSchedule.of(1d)) .finalExchange(true) .initialExchange(true) .build()) .calculation(IborRateCalculation.builder()
.fixingDateOffset(MINUS_TWO_DAYS) .build()) .initialExchange(true) .intermediateExchange(true) .finalExchange(true)
.currency(GBP) .amount(ValueSchedule.of(1000d, ValueStep.of(1, ValueAdjustment.ofReplace(1500d)))) .initialExchange(true) .intermediateExchange(true) .finalExchange(true)
.amount(ValueSchedule.of(500d)) .finalExchange(true) .initialExchange(true) .build()) .calculation(IborRateCalculation.builder()
.amount(ValueSchedule.of(500d)) .finalExchange(true) .initialExchange(true) .build()) .calculation(IborRateCalculation.builder()
.notionalSchedule(NotionalSchedule.builder() .finalExchange(true) .initialExchange(true) .amount(ValueSchedule.of(NOTIONAL_EUR)) .currency(EUR) .notionalSchedule(NotionalSchedule.builder() .finalExchange(true) .initialExchange(true) .amount(ValueSchedule.of(NOTIONAL_USD)) .currency(USD)
.notionalSchedule(NotionalSchedule.builder() .finalExchange(finalExchange) .initialExchange(initialExchange) .amount(ValueSchedule.of(NOTIONAL_EUR)) .currency(EUR) .notionalSchedule(NotionalSchedule.builder() .finalExchange(finalExchange) .initialExchange(initialExchange) .intermediateExchange(intermediateExchange) .amount(ValueSchedule.of(NOTIONAL_USD))
.amount(ValueSchedule.of(500d)) .finalExchange(true) .initialExchange(true) .build()) .calculation(IborRateCalculation.builder()
.currency(getCurrency()) .finalExchange(notionalExchange) .initialExchange(notionalExchange) .amount(ValueSchedule.of(notional)).build()) .calculation(IborRateCalculation.builder()
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); }