public void test_builder() { Swaption test = sut(); assertEquals(test.getExpiryDate(), ADJUSTABLE_EXPIRY_DATE); assertEquals(test.getExpiryTime(), EXPIRY_TIME); assertEquals(test.getExpiryZone(), ZONE); assertEquals(test.getExpiry(), EXPIRY_DATE.atTime(EXPIRY_TIME).atZone(ZONE)); assertEquals(test.getLongShort(), LONG); assertEquals(test.getSwaptionSettlement(), PHYSICAL_SETTLE); assertEquals(test.getUnderlying(), SWAP); assertEquals(test.getCurrency(), USD); assertEquals(test.getIndex(), IborIndices.USD_LIBOR_3M); assertEquals(test.isCrossCurrency(), false); assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(USD)); assertEquals(test.allCurrencies(), ImmutableSet.of(USD)); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(Swaption beanToCopy) { this.longShort = beanToCopy.getLongShort(); this.swaptionSettlement = beanToCopy.getSwaptionSettlement(); this.expiryDate = beanToCopy.getExpiryDate(); this.expiryTime = beanToCopy.getExpiryTime(); this.expiryZone = beanToCopy.getExpiryZone(); this.underlying = beanToCopy.getUnderlying(); }
@Override public PortfolioItemSummary summarize() { // Long 5Y USD 2mm Rec USD-LIBOR-6M / Pay 1% : 21Jan18 String swapDesc = product.getUnderlying().summaryDescription(); swapDesc = swapDesc.contains(":") ? swapDesc.substring(0, swapDesc.lastIndexOf(':')).trim() : swapDesc; StringBuilder buf = new StringBuilder(96); buf.append(product.getLongShort()); buf.append(' '); buf.append(swapDesc); buf.append(" : "); buf.append(SummarizerUtils.date(product.getExpiryDate().getUnadjusted())); return SummarizerUtils.summary(this, ProductType.SWAPTION, buf.toString(), product.getCurrency()); }
static Swaption sut2() { return Swaption.builder() .expiryDate(AdjustableDate.of(LocalDate.of(2014, 6, 10), ADJUSTMENT)) .expiryTime(LocalTime.of(14, 0)) .expiryZone(ZoneId.of("GMT")) .longShort(SHORT) .swaptionSettlement(CASH_SETTLE) .underlying(FixedIborSwapConventions.USD_FIXED_6M_LIBOR_3M .createTrade(LocalDate.of(2014, 6, 10), Tenor.TENOR_10Y, BuySell.BUY, 1d, FIXED_RATE, REF_DATA).getProduct()) .build(); }
public void test_physicalSettlement() { Swaption swaption = Swaption .builder() .expiryDate(AdjustableDate.of(MATURITY, BDA_MF)) .expiryTime(LocalTime.NOON) .expiryZone(ZoneOffset.UTC) .swaptionSettlement(PhysicalSwaptionSettlement.DEFAULT) .longShort(LONG) .underlying(SWAP_PAY) .build(); assertThrowsIllegalArg(() -> PRICER.impliedVolatility(swaption.resolve(REF_DATA), RATE_PROVIDER, VOLS)); }
Swap swap = swaption.getUnderlying(); NotionalSchedule notional = NotionalSchedule.of(EUR, 50000000d); RateCalculationSwapLeg payLeg = RateCalculationSwapLeg.builder() LocalTime expiryTime = LocalTime.of(11, 0, 0); ZoneId expiryZone = ZoneId.of("Europe/Brussels"); Swaption swaptionExpected = Swaption.builder() .expiryDate(expiryDate) .expiryZone(expiryZone)
@Override public ResolvedSwaptionTrade resolve(ReferenceData refData) { return ResolvedSwaptionTrade.builder() .info(info) .product(product.resolve(refData)) .premium(premium.resolve(refData)) .build(); }
@Override public ImmutableSet<Currency> allCurrencies() { return ImmutableSet.of(getCurrency()); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 116685664: // longShort return ((Swaption) bean).getLongShort(); case -1937554512: // swaptionSettlement return ((Swaption) bean).getSwaptionSettlement(); case -816738431: // expiryDate return ((Swaption) bean).getExpiryDate(); case -816254304: // expiryTime return ((Swaption) bean).getExpiryTime(); case -816069761: // expiryZone return ((Swaption) bean).getExpiryZone(); case -1770633379: // underlying return ((Swaption) bean).getUnderlying(); } return super.propertyGet(bean, propertyName, quiet); }
public void test_builder_expiryAfterStart() { assertThrowsIllegalArg(() -> Swaption.builder() .expiryDate(AdjustableDate.of(LocalDate.of(2014, 6, 17), ADJUSTMENT)) .expiryTime(EXPIRY_TIME) .expiryZone(ZONE) .longShort(LONG) .swaptionSettlement(PHYSICAL_SETTLE) .underlying(SWAP) .build()); }
public void test_physicalSettlement() { Swaption swaption = Swaption.builder() .swaptionSettlement(PhysicalSwaptionSettlement.DEFAULT) .expiryDate(AdjustableDate.of(SWAPTION_EXERCISE_DATE)) .expiryTime(SWAPTION_EXPIRY_TIME) .expiryZone(SWAPTION_EXPIRY_ZONE) .longShort(LongShort.LONG) .underlying(SWAP_REC) .build(); assertThrowsIllegalArg(() -> PRICER_SWAPTION.presentValue(swaption.resolve(REF_DATA), RATE_PROVIDER, VOLS)); }
public void test_resolve() { Swaption base = sut(); ResolvedSwaption test = base.resolve(REF_DATA); assertEquals(test.getExpiry(), ADJUSTMENT.adjust(EXPIRY_DATE, REF_DATA).atTime(EXPIRY_TIME).atZone(ZONE)); assertEquals(test.getLongShort(), LONG); assertEquals(test.getSwaptionSettlement(), PHYSICAL_SETTLE); assertEquals(test.getUnderlying(), SWAP.resolve(REF_DATA)); }
static Swaption sut() { return Swaption.builder() .expiryDate(ADJUSTABLE_EXPIRY_DATE) .expiryTime(EXPIRY_TIME) .expiryZone(ZONE) .longShort(LONG) .swaptionSettlement(PHYSICAL_SETTLE) .underlying(SWAP) .build(); }
public void test_resolve() { SwaptionTrade test = SwaptionTrade.of(TRADE_INFO, SWAPTION, PREMIUM); assertEquals(test.resolve(REF_DATA).getPremium(), PREMIUM.resolve(REF_DATA)); assertEquals(test.resolve(REF_DATA).getProduct(), SWAPTION.resolve(REF_DATA)); assertEquals(test.resolve(REF_DATA).getInfo(), TRADE_INFO); }
public void test_builder_invalidSwapBasis() { assertThrowsIllegalArg(() -> Swaption.builder() .expiryDate(ADJUSTABLE_EXPIRY_DATE) .expiryTime(EXPIRY_TIME) .expiryZone(ZONE) .longShort(LONG) .swaptionSettlement(PHYSICAL_SETTLE) .underlying(SWAP_BASIS) .build()); }
public void test_builder_invalidSwapXCcy() { assertThrowsIllegalArg(() -> Swaption.builder() .expiryDate(ADJUSTABLE_EXPIRY_DATE) .expiryTime(EXPIRY_TIME) .expiryZone(ZONE) .longShort(LONG) .swaptionSettlement(PHYSICAL_SETTLE) .underlying(SWAP_XCCY) .build()); }
public void test_builder_invalidSwapOis() { assertThrowsIllegalArg(() -> Swaption.builder() .expiryDate(ADJUSTABLE_EXPIRY_DATE) .expiryTime(EXPIRY_TIME) .expiryZone(ZONE) .longShort(LONG) .swaptionSettlement(PHYSICAL_SETTLE) .underlying(SWAP_OIS) .build()); }
Swap swap = swapParser.parseSwap(document, swaptionEl, tradeInfoBuilder); Swaption swaption = Swaption.builder() .expiryDate(expiryDate) .expiryZone(expiryZone)