Exemplo 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);
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            IborFutureSecurity test = sut();

            assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT);
            TradeInfo       tradeInfo     = TradeInfo.of(date(2016, 6, 30));
            IborFutureTrade expectedTrade = IborFutureTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(0.995).build();

            assertEquals(test.createTrade(tradeInfo, 100, 0.995, ReferenceData.empty()), expectedTrade);

            PositionInfo       positionInfo      = PositionInfo.empty();
            IborFuturePosition expectedPosition1 = IborFuturePosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build();

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            IborFuturePosition expectedPosition2 = IborFuturePosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            DsfSecurity test = sut();

            assertEquals(test.createProduct(ReferenceData.empty()), PRODUCT);
            TradeInfo tradeInfo     = TradeInfo.of(PRODUCT.LastTradeDate.minusDays(1));
            DsfTrade  expectedTrade = DsfTrade.builder().info(tradeInfo).product(PRODUCT).quantity(100).price(123.50).build();

            assertEquals(test.createTrade(tradeInfo, 100, 123.50, ReferenceData.empty()), expectedTrade);

            PositionInfo positionInfo      = PositionInfo.empty();
            DsfPosition  expectedPosition1 = DsfPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build();

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            DsfPosition expectedPosition2 = DsfPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
Exemplo n.º 4
0
        //-------------------------------------------------------------------------
        public virtual 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);
        }