Пример #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);
        }
        public virtual void test_createPosition()
        {
            FixedCouponBondSecurity test              = sut();
            PositionInfo            positionInfo      = PositionInfo.empty();
            FixedCouponBondPosition expectedPosition1 = FixedCouponBondPosition.builder().info(positionInfo).product(PRODUCT).longQuantity(100).build();

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

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
        public virtual void test_createPosition()
        {
            BillSecurity test              = BillSecurity.builder().dayCount(DAY_COUNT).info(INFO).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();
            Bill         product           = Bill.builder().dayCount(DAY_COUNT).securityId(SECURITY_ID).dayCount(DAY_COUNT).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();
            PositionInfo positionInfo      = PositionInfo.empty();
            BillPosition expectedPosition1 = BillPosition.builder().info(positionInfo).product(product).longQuantity(100).build();

            assertEquals(test.createPosition(positionInfo, 100, ReferenceData.empty()), expectedPosition1);
            BillPosition expectedPosition2 = BillPosition.builder().info(positionInfo).product(product).longQuantity(100).shortQuantity(50).build();

            assertEquals(test.createPosition(positionInfo, 100, 50, ReferenceData.empty()), expectedPosition2);
        }
Пример #4
0
        public virtual void test()
        {
            EtdOptionSecurity test = sut();

            assertEquals(test.Variant, EtdVariant.MONTHLY);
            assertEquals(test.Type, EtdType.OPTION);
            assertEquals(test.Currency, Currency.GBP);
            assertEquals(test.UnderlyingIds, ImmutableSet.of());
            assertEquals(test.createProduct(REF_DATA), test);
            assertEquals(test.createTrade(TradeInfo.empty(), 1, 2, ReferenceData.empty()), EtdOptionTrade.of(TradeInfo.empty(), test, 1, 2));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, ReferenceData.empty()), EtdOptionPosition.ofNet(PositionInfo.empty(), test, 1));
            assertEquals(test.createPosition(PositionInfo.empty(), 1, 2, ReferenceData.empty()), EtdOptionPosition.ofLongShort(PositionInfo.empty(), test, 1, 2));
        }
Пример #5
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);
        }
Пример #7
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);
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableDefaults private static void applyDefaults(Builder builder)
        private static void applyDefaults(Builder builder)
        {
            builder.info_Renamed = PositionInfo.empty();
        }
Пример #9
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from the security and net quantity.
 /// <para>
 /// The net quantity is the long quantity minus the short quantity, which may be negative.
 /// If the quantity is positive it is treated as a long quantity.
 /// Otherwise it is treated as a short quantity.
 ///
 /// </para>
 /// </summary>
 /// <param name="security">  the underlying security </param>
 /// <param name="netQuantity">  the net quantity of the underlying security </param>
 /// <returns> the position </returns>
 public static EtdFuturePosition ofNet(EtdFutureSecurity security, double netQuantity)
 {
     return(ofNet(PositionInfo.empty(), security, netQuantity));
 }
Пример #10
0
 /// <summary>
 /// Obtains an instance from the security, long quantity and short quantity.
 /// <para>
 /// The long quantity and short quantity must be zero or positive, not negative.
 /// In many cases, only a long quantity or short quantity will be present with the other set to zero.
 /// However it is also possible for both to be non-zero, allowing long and short positions to be treated separately.
 ///
 /// </para>
 /// </summary>
 /// <param name="security">  the underlying security </param>
 /// <param name="longQuantity">  the long quantity of the underlying security </param>
 /// <param name="shortQuantity">  the short quantity of the underlying security </param>
 /// <returns> the position </returns>
 public static EtdFuturePosition ofLongShort(EtdFutureSecurity security, double longQuantity, double shortQuantity)
 {
     return(ofLongShort(PositionInfo.empty(), security, longQuantity, shortQuantity));
 }