/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(BondFutureOptionPosition beanToCopy) { this.info_Renamed = beanToCopy.Info; this.product_Renamed = beanToCopy.Product; this.longQuantity_Renamed = beanToCopy.LongQuantity; this.shortQuantity_Renamed = beanToCopy.ShortQuantity; }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 3237038: // info this.info_Renamed = (PositionInfo)newValue; break; case -309474065: // product this.product_Renamed = (BondFutureOption)newValue; break; case 611668775: // longQuantity this.longQuantity_Renamed = (double?)newValue.Value; break; case -2094395097: // shortQuantity this.shortQuantity_Renamed = (double?)newValue.Value; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
//------------------------------------------------------------------------- public virtual void test_resolve() { BondFutureOption test = sut(); ResolvedBondFutureOption expected = ResolvedBondFutureOption.builder().securityId(SECURITY_ID).putCall(CALL).strikePrice(STRIKE_PRICE).expiry(EXPIRY_DATE.atTime(EXPIRY_TIME).atZone(EXPIRY_ZONE)).premiumStyle(FutureOptionPremiumStyle.DAILY_MARGIN).underlyingFuture(FUTURE.resolve(REF_DATA)).build(); assertEquals(test.resolve(REF_DATA), expected); }
//------------------------------------------------------------------------- public virtual void test_createProduct() { BondFutureOptionSecurity test = sut(); BondFuture future = PRODUCT.UnderlyingFuture; BondFutureSecurity futureSec = BondFutureSecurityTest.sut(); ImmutableList <FixedCouponBond> basket = future.DeliveryBasket; FixedCouponBondSecurity bondSec0 = FixedCouponBondSecurityTest.createSecurity(future.DeliveryBasket.get(0)); FixedCouponBondSecurity bondSec1 = FixedCouponBondSecurityTest.createSecurity(future.DeliveryBasket.get(1)); ReferenceData refData = ImmutableReferenceData.of(ImmutableMap.of(test.UnderlyingFutureId, futureSec, basket.get(0).SecurityId, bondSec0, basket.get(1).SecurityId, bondSec1)); BondFutureOption product = test.createProduct(refData); assertEquals(product.UnderlyingFuture.DeliveryBasket.get(0), future.DeliveryBasket.get(0)); assertEquals(product.UnderlyingFuture.DeliveryBasket.get(1), future.DeliveryBasket.get(1)); TradeInfo tradeInfo = TradeInfo.of(date(2016, 6, 30)); BondFutureOptionTrade expectedTrade = BondFutureOptionTrade.builder().info(tradeInfo).product(product).quantity(100).price(123.50).build(); assertEquals(test.createTrade(tradeInfo, 100, 123.50, refData), expectedTrade); PositionInfo positionInfo = PositionInfo.empty(); BondFutureOptionPosition expectedPosition1 = BondFutureOptionPosition.builder().info(positionInfo).product(product).longQuantity(100).build(); TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, refData), expectedPosition1); BondFutureOptionPosition expectedPosition2 = BondFutureOptionPosition.builder().info(positionInfo).product(product).longQuantity(100).shortQuantity(50).build(); assertEquals(test.createPosition(positionInfo, 100, 50, refData), expectedPosition2); }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 3237038: // info this.info_Renamed = (TradeInfo)newValue; break; case -309474065: // product this.product_Renamed = (BondFutureOption)newValue; break; case -1285004149: // quantity this.quantity_Renamed = (double?)newValue.Value; break; case 106934601: // price this.price_Renamed = (double?)newValue.Value; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(BondFutureOptionTrade beanToCopy) { this.info_Renamed = beanToCopy.Info; this.product_Renamed = beanToCopy.Product; this.quantity_Renamed = beanToCopy.Quantity; this.price_Renamed = beanToCopy.Price; }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { BondFutureOption other = (BondFutureOption)obj; return(JodaBeanUtils.equal(securityId, other.securityId) && JodaBeanUtils.equal(putCall, other.putCall) && JodaBeanUtils.equal(strikePrice, other.strikePrice) && JodaBeanUtils.equal(expiryDate, other.expiryDate) && JodaBeanUtils.equal(expiryTime, other.expiryTime) && JodaBeanUtils.equal(expiryZone, other.expiryZone) && JodaBeanUtils.equal(premiumStyle, other.premiumStyle) && JodaBeanUtils.equal(rounding, other.rounding) && JodaBeanUtils.equal(underlyingFuture, other.underlyingFuture)); } return(false); }
//------------------------------------------------------------------------- public virtual void test_builder() { BondFutureOption test = sut(); assertEquals(test.PutCall, CALL); assertEquals(test.StrikePrice, STRIKE_PRICE); assertEquals(test.ExpiryDate, EXPIRY_DATE); assertEquals(test.ExpiryTime, EXPIRY_TIME); assertEquals(test.ExpiryZone, EXPIRY_ZONE); assertEquals(test.Expiry, ZonedDateTime.of(EXPIRY_DATE, EXPIRY_TIME, EXPIRY_ZONE)); assertEquals(test.Rounding, Rounding.none()); assertEquals(test.UnderlyingFuture, FUTURE); assertEquals(test.Currency, FUTURE.Currency); }
/// <summary> /// Sets the option that was traded. /// <para> /// The product captures the contracted financial details. /// </para> /// </summary> /// <param name="product"> the new value, not null </param> /// <returns> this, for chaining, not null </returns> public Builder product(BondFutureOption product) { JodaBeanUtils.notNull(product, "product"); this.product_Renamed = product; return(this); }
public BondFutureOptionTrade createTrade(TradeInfo info, double quantity, double tradePrice, ReferenceData refData) { BondFutureOption product = createProduct(refData); return(new BondFutureOptionTrade(info, product, quantity, tradePrice)); }
//------------------------------------------------------------------------- internal static BondFutureOption sut() { return(BondFutureOption.builder().securityId(SECURITY_ID).putCall(CALL).strikePrice(STRIKE_PRICE).expiryDate(EXPIRY_DATE).expiryTime(EXPIRY_TIME).expiryZone(EXPIRY_ZONE).premiumStyle(FutureOptionPremiumStyle.DAILY_MARGIN).underlyingFuture(FUTURE).build()); }
public virtual void test_builder_expiryNotAfterTradeDate() { assertThrowsIllegalArg(() => BondFutureOption.builder().putCall(CALL).expiryDate(FUTURE.LastTradeDate).expiryTime(EXPIRY_TIME).expiryZone(EXPIRY_ZONE).strikePrice(STRIKE_PRICE).underlyingFuture(FUTURE).build()); }
internal static BondFutureOption sut2() { return(BondFutureOption.builder().securityId(SECURITY_ID2).putCall(PUT).strikePrice(1.075).expiryDate(date(2011, 9, 21)).expiryTime(LocalTime.of(12, 0)).expiryZone(ZoneId.of("Europe/Paris")).premiumStyle(FutureOptionPremiumStyle.UPFRONT_PREMIUM).rounding(ROUNDING).underlyingFuture(FUTURE2).build()); }