builder.currency(currency); builder.amount(ValueSchedule.of(LoaderUtils.parseDouble(getValueWithFallback(row, leg, NOTIONAL_FIELD))));
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); }
.build()) .notionalSchedule(NotionalSchedule.builder() .currency(GBP) .amount(ValueSchedule.of(1000d, ValueStep.of(1, ValueAdjustment.ofReplace(1500d)))) .initialExchange(true)
.build()) .notionalSchedule(NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(500d)) .finalExchange(true)
public void stubAmortizedSwap_cashflows() { .currency(EUR) .amount(ValueSchedule.builder() .initialValue(50000000d)
.build()) .notionalSchedule(NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(500d)) .finalExchange(true)
.currency(EUR) .amount(ValueSchedule.builder() .initialValue(50000000d)
.initialExchange(initialExchange) .amount(ValueSchedule.of(NOTIONAL_EUR)) .currency(EUR) .build()) .calculation(IborRateCalculation.builder() .intermediateExchange(intermediateExchange) .amount(ValueSchedule.of(NOTIONAL_USD)) .currency(USD) .fxReset(FxResetCalculation.builder() .fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, CalendarUSD.NYC, BDA_P))
.currency(EUR) .amount(ValueSchedule.builder() .initialValue(50000000d)
.build()) .notionalSchedule(NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(500d)) .finalExchange(true)
.build()) .notionalSchedule(NotionalSchedule.builder() .currency(getCurrency()) .finalExchange(notionalExchange) .initialExchange(notionalExchange)
.build()) .notionalSchedule(NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(1d)) .finalExchange(true)
.build()) .notionalSchedule(NotionalSchedule.builder() .currency(GBP) .amount(ValueSchedule.of(1000d)) .finalExchange(true)
public void test_builder_invalidCurrencyFxReset() { assertThrowsIllegalArg(() -> NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(2000d)) .fxReset(FxResetCalculation.builder() .referenceCurrency(USD) .index(GBP_USD_WM) .fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)) .build()) .build()); assertThrowsIllegalArg(() -> NotionalSchedule.builder() .currency(EUR) .amount(ValueSchedule.of(2000d)) .fxReset(FxResetCalculation.builder() .referenceCurrency(USD) .index(GBP_USD_WM) .fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)) .build()) .build()); }
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); }
/** * Obtains an instance with a notional amount that can change over time. * * @param currency the currency of the notional and swap payments * @param amountSchedule the schedule describing how the notional changes over time * @return the notional amount */ public static NotionalSchedule of(Currency currency, ValueSchedule amountSchedule) { ArgChecker.notNull(currency, "currency"); ArgChecker.notNull(amountSchedule, "amountSchedule"); return NotionalSchedule.builder() .currency(currency) .amount(amountSchedule) .build(); }
/** * Obtains an instance with a single amount that does not change over time. * * @param currency the currency of the notional and swap payments * @param amount the single notional amount that does not change over time * @return the notional amount */ public static NotionalSchedule of(Currency currency, double amount) { ArgChecker.notNull(currency, "currency"); return NotionalSchedule.builder() .currency(currency) .amount(ValueSchedule.of(amount)) .build(); }
/** * Obtains an instance with a single amount that does not change over time. * * @param notional the single notional that does not change over time * @return the notional amount */ public static NotionalSchedule of(CurrencyAmount notional) { ArgChecker.notNull(notional, "notional"); return NotionalSchedule.builder() .currency(notional.getCurrency()) .amount(ValueSchedule.of(notional.getAmount())) .build(); }