@Override public IborFutureOptionPosition createPosition( PositionInfo positionInfo, double longQuantity, double shortQuantity, ReferenceData refData) { return IborFutureOptionPosition.ofLongShort(positionInfo, createProduct(refData), longQuantity, shortQuantity); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(IborFutureOptionSecurity beanToCopy) { this.info = beanToCopy.getInfo(); this.currency = beanToCopy.getCurrency(); this.putCall = beanToCopy.getPutCall(); this.strikePrice = beanToCopy.getStrikePrice(); this.expiryDate = beanToCopy.getExpiryDate(); this.expiryTime = beanToCopy.getExpiryTime(); this.expiryZone = beanToCopy.getExpiryZone(); this.premiumStyle = beanToCopy.getPremiumStyle(); this.rounding = beanToCopy.getRounding(); this.underlyingFutureId = beanToCopy.getUnderlyingFutureId(); }
@Override public IborFutureOptionSecurity build() { return new IborFutureOptionSecurity( info, currency, putCall, strikePrice, expiryDate, expiryTime, expiryZone, premiumStyle, rounding, underlyingFutureId); }
public void test_builder() { IborFutureOptionSecurity test = sut(); assertEquals(test.getInfo(), INFO); assertEquals(test.getSecurityId(), OPTION.getSecurityId()); assertEquals(test.getCurrency(), OPTION.getCurrency()); assertEquals(test.getPutCall(), OPTION.getPutCall()); assertEquals(test.getPremiumStyle(), OPTION.getPremiumStyle()); assertEquals(test.getUnderlyingFutureId(), FUTURE_ID); assertEquals(test.getUnderlyingIds(), ImmutableSet.of(FUTURE_ID)); }
public void test_createProduct() { IborFutureOptionSecurity test = sut(); ReferenceData refData = ImmutableReferenceData.of(FUTURE_ID, FUTURE_SECURITY); assertEquals(test.createProduct(refData), OPTION); TradeInfo tradeInfo = TradeInfo.of(date(2016, 6, 30)); IborFutureOptionTrade expectedTrade = IborFutureOptionTrade.builder() .info(tradeInfo) .product(OPTION) .quantity(100) .price(123.50) .build(); assertEquals(test.createTrade(tradeInfo, 100, 123.50, refData), expectedTrade); PositionInfo positionInfo = PositionInfo.empty(); IborFutureOptionPosition expectedPosition1 = IborFutureOptionPosition.builder() .info(positionInfo) .product(OPTION) .longQuantity(100) .build(); TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, refData), expectedPosition1); IborFutureOptionPosition expectedPosition2 = IborFutureOptionPosition.builder() .info(positionInfo) .product(OPTION) .longQuantity(100) .shortQuantity(50) .build(); assertEquals(test.createPosition(positionInfo, 100, 50, refData), expectedPosition2); }
@Override public IborFutureOptionSecurity withInfo(SecurityInfo info) { return toBuilder().info(info).build(); }
@Override public IborFutureOption createProduct(ReferenceData refData) { Security security = refData.getValue(underlyingFutureId); if (!(security instanceof IborFutureSecurity)) { throw new ClassCastException(Messages.format( "{} underlying future '{}' resolved to '{}' when '{}' was expected", IborFutureOptionSecurity.class.getSimpleName(), underlyingFutureId, security.getClass().getSimpleName(), IborFutureSecurity.class.getSimpleName())); } IborFutureSecurity futureSec = (IborFutureSecurity) security; IborFuture underlying = futureSec.createProduct(refData); return new IborFutureOption( getSecurityId(), putCall, strikePrice, expiryDate, expiryTime, expiryZone, premiumStyle, rounding, underlying); }
static IborFutureOptionSecurity sut2() { return IborFutureOptionSecurity.builder() .info(INFO2) .currency(OPTION2.getCurrency()) .putCall(OPTION2.getPutCall()) .strikePrice(OPTION2.getStrikePrice()) .expiryDate(OPTION2.getExpiryDate()) .expiryTime(OPTION2.getExpiryTime()) .expiryZone(OPTION2.getExpiryZone()) .premiumStyle(OPTION2.getPremiumStyle()) .rounding(OPTION2.getRounding()) .underlyingFutureId(FUTURE_ID2) .build(); }
public void test_builder_badPrice() { assertThrowsIllegalArg(() -> sut().toBuilder().strikePrice(2.1).build()); }
static IborFutureOptionSecurity sut() { return IborFutureOptionSecurity.builder() .info(INFO) .currency(OPTION.getCurrency()) .putCall(OPTION.getPutCall()) .strikePrice(OPTION.getStrikePrice()) .expiryDate(OPTION.getExpiryDate()) .expiryTime(OPTION.getExpiryTime()) .expiryZone(OPTION.getExpiryZone()) .premiumStyle(OPTION.getPremiumStyle()) .rounding(OPTION.getRounding()) .underlyingFutureId(FUTURE_ID) .build(); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3237038: // info return ((IborFutureOptionSecurity) bean).getInfo(); case 575402001: // currency return ((IborFutureOptionSecurity) bean).getCurrency(); case -219971059: // putCall return ((IborFutureOptionSecurity) bean).getPutCall(); case 50946231: // strikePrice return ((IborFutureOptionSecurity) bean).getStrikePrice(); case -816738431: // expiryDate return ((IborFutureOptionSecurity) bean).getExpiryDate(); case -816254304: // expiryTime return ((IborFutureOptionSecurity) bean).getExpiryTime(); case -816069761: // expiryZone return ((IborFutureOptionSecurity) bean).getExpiryZone(); case -1257652838: // premiumStyle return ((IborFutureOptionSecurity) bean).getPremiumStyle(); case -142444: // rounding return ((IborFutureOptionSecurity) bean).getRounding(); case -109104965: // underlyingFutureId return ((IborFutureOptionSecurity) bean).getUnderlyingFutureId(); } return super.propertyGet(bean, propertyName, quiet); }
@Override public IborFutureOptionTrade createTrade( TradeInfo info, double quantity, double tradePrice, ReferenceData refData) { return new IborFutureOptionTrade(info, createProduct(refData), quantity, tradePrice); }
public void test_createProduct_wrongType() { IborFutureOptionSecurity test = sut(); IborFuture future = OPTION.getUnderlyingFuture(); SecurityId secId = future.getSecurityId(); GenericSecurity sec = GenericSecurity.of(INFO); ReferenceData refData = ImmutableReferenceData.of(secId, sec); assertThrows(() -> test.createProduct(refData), ClassCastException.class); }