Ejemplo n.º 1
0
        //-------------------------------------------------------------------------
        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);
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual void test_summarize()
        {
            BondFutureOptionTrade trade    = sut();
            PortfolioItemSummary  expected = PortfolioItemSummary.builder().id(TRADE_INFO.Id.orElse(null)).portfolioItemType(PortfolioItemType.TRADE).productType(ProductType.BOND_FUTURE_OPTION).currencies(Currency.USD).description("BondFutureOption x 1234").build();

            assertEquals(trade.summarize(), expected);
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------------
        public virtual void test_getters()
        {
            ResolvedBondFutureOptionTrade test  = sut();
            BondFutureOptionTrade         @base = BondFutureOptionTradeTest.sut();

            assertEquals(test.TradedPrice.get(), TradedPrice.of(@base.Info.TradeDate.get(), @base.Price));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------------
        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);
        }
Ejemplo n.º 6
0
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            BondFutureOptionTrade test = sut();

            assertEquals(test.Info, TRADE_INFO);
            assertEquals(test.Product, OPTION_PRODUCT);
            assertEquals(test.Quantity, QUANTITY);
            assertEquals(test.Price, PRICE);
            assertEquals(test.withInfo(TRADE_INFO).Info, TRADE_INFO);
            assertEquals(test.withQuantity(129).Quantity, 129d, 0d);
            assertEquals(test.withPrice(129).Price, 129d, 0d);
        }
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         BondFutureOptionTrade other = (BondFutureOptionTrade)obj;
         return(JodaBeanUtils.equal(info, other.info) && JodaBeanUtils.equal(product, other.product) && JodaBeanUtils.equal(quantity, other.quantity) && JodaBeanUtils.equal(price, other.price));
     }
     return(false);
 }
Ejemplo n.º 8
0
 internal static BondFutureOptionTrade sut2()
 {
     return(BondFutureOptionTrade.builder().info(TRADE_INFO2).product(OPTION_PRODUCT2).quantity(QUANTITY2).price(PRICE2.Value).build());
 }