//------------------------------------------------------------------------- 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 virtual void test_withQuantity() { BondFutureOptionTrade @base = sut(); double quantity = 5432d; BondFutureOptionTrade computed = @base.withQuantity(quantity); BondFutureOptionTrade expected = BondFutureOptionTrade.builder().info(TRADE_INFO).product(OPTION_PRODUCT).quantity(quantity).price(PRICE.Value).build(); assertEquals(computed, expected); }
public virtual void test_withPrice() { BondFutureOptionTrade @base = sut(); double price = 0.05d; BondFutureOptionTrade computed = @base.withPrice(price); BondFutureOptionTrade expected = BondFutureOptionTrade.builder().info(TRADE_INFO).product(OPTION_PRODUCT).quantity(QUANTITY).price(price).build(); assertEquals(computed, expected); }
internal static BondFutureOptionTrade sut2() { return(BondFutureOptionTrade.builder().info(TRADE_INFO2).product(OPTION_PRODUCT2).quantity(QUANTITY2).price(PRICE2.Value).build()); }