Esempio n. 1
0
        public virtual void test_withPrice()
        {
            BondFutureTrade @base    = sut();
            double          price    = 1.5d;
            BondFutureTrade computed = @base.withPrice(price);
            BondFutureTrade expected = BondFutureTrade.builder().info(TRADE_INFO).product(FUTURE).quantity(QUANTITY).price(price).build();

            assertEquals(computed, expected);
        }
Esempio n. 2
0
        //-------------------------------------------------------------------------
        public virtual void test_withQuantity()
        {
            BondFutureTrade @base    = sut();
            double          quantity = 366d;
            BondFutureTrade computed = @base.withQuantity(quantity);
            BondFutureTrade expected = BondFutureTrade.builder().info(TRADE_INFO).product(FUTURE).quantity(quantity).price(PRICE).build();

            assertEquals(computed, expected);
        }
Esempio n. 3
0
        //-------------------------------------------------------------------------
        public virtual void test_createProduct()
        {
            BondFutureSecurity test = sut();
            ImmutableList <FixedCouponBond> basket   = PRODUCT.DeliveryBasket;
            FixedCouponBondSecurity         bondSec0 = FixedCouponBondSecurityTest.createSecurity(PRODUCT.DeliveryBasket.get(0));
            FixedCouponBondSecurity         bondSec1 = FixedCouponBondSecurityTest.createSecurity(PRODUCT.DeliveryBasket.get(1));
            ReferenceData refData = ImmutableReferenceData.of(ImmutableMap.of(basket.get(0).SecurityId, bondSec0, basket.get(1).SecurityId, bondSec1));
            BondFuture    product = test.createProduct(refData);

            assertEquals(product.DeliveryBasket.get(0), PRODUCT.DeliveryBasket.get(0));
            assertEquals(product.DeliveryBasket.get(1), PRODUCT.DeliveryBasket.get(1));
            TradeInfo       tradeInfo     = TradeInfo.of(date(2016, 6, 30));
            BondFutureTrade expectedTrade = BondFutureTrade.builder().info(tradeInfo).product(product).quantity(100).price(123.50).build();

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

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

            TestHelper.assertEqualsBean(test.createPosition(positionInfo, 100, refData), expectedPosition1);
            BondFuturePosition expectedPosition2 = BondFuturePosition.builder().info(positionInfo).product(product).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, refData), expectedPosition2);
        }
Esempio n. 4
0
 internal static BondFutureTrade sut2()
 {
     return(BondFutureTrade.builder().info(TRADE_INFO2).product(FUTURE2).quantity(QUANTITY2).price(PRICE2).build());
 }