/** * 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 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 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(); }
private static NotionalSchedule parseNotionalSchedule(CsvRow row, String leg) { NotionalSchedule.Builder builder = NotionalSchedule.builder();
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); }
.paymentDateOffset(PLUS_TWO_DAYS) .build()) .notionalSchedule(NotionalSchedule.builder() .currency(GBP) .amount(ValueSchedule.of(1000d))
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()); }
.paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(1d))
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); }
.paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.builder() .finalExchange(finalExchange) .initialExchange(initialExchange) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.builder() .finalExchange(finalExchange) .initialExchange(initialExchange)
Swap swap = swapTrade.getProduct(); NotionalSchedule notionalFloat = NotionalSchedule.builder() .currency(EUR) .amount(ValueSchedule.builder()
Swap swap = swapTrade.getProduct(); NotionalSchedule notional = NotionalSchedule.builder() .currency(EUR) .amount(ValueSchedule.builder()
.paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(500d))
.paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(500d))
.paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(500d))
.compoundingMethod(getCompoundingMethod()) .build()) .notionalSchedule(NotionalSchedule.builder() .currency(getCurrency()) .finalExchange(notionalExchange)
public void stubAmortizedSwap_cashflows() { NotionalSchedule notional = NotionalSchedule.builder() .currency(EUR) .amount(ValueSchedule.builder()
.compoundingMethod(STRAIGHT) .build()) .notionalSchedule(NotionalSchedule.builder() .currency(GBP) .amount(ValueSchedule.of(1000d, ValueStep.of(1, ValueAdjustment.ofReplace(1500d))))