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);
        }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (TradeInfo)newValue;
                    break;

                case -309474065:         // product
                    this.product_Renamed = (BondFuture)newValue;
                    break;

                case -1285004149:         // quantity
                    this.quantity_Renamed = (double?)newValue.Value;
                    break;

                case 106934601:         // price
                    this.price_Renamed = (double?)newValue.Value;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Exemplo n.º 3
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (PositionInfo)newValue;
                    break;

                case -309474065:         // product
                    this.product_Renamed = (BondFuture)newValue;
                    break;

                case 611668775:         // longQuantity
                    this.longQuantity_Renamed = (double?)newValue.Value;
                    break;

                case -2094395097:         // shortQuantity
                    this.shortQuantity_Renamed = (double?)newValue.Value;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Exemplo n.º 4
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(BondFuturePosition beanToCopy)
 {
     this.info_Renamed          = beanToCopy.Info;
     this.product_Renamed       = beanToCopy.Product;
     this.longQuantity_Renamed  = beanToCopy.LongQuantity;
     this.shortQuantity_Renamed = beanToCopy.ShortQuantity;
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(BondFutureTrade beanToCopy)
 {
     this.info_Renamed     = beanToCopy.Info;
     this.product_Renamed  = beanToCopy.Product;
     this.quantity_Renamed = beanToCopy.Quantity;
     this.price_Renamed    = beanToCopy.Price;
 }
Exemplo n.º 6
0
        public virtual void test_createProduct_wrongType()
        {
            BondFutureOptionSecurity test = sut();
            BondFuture      future        = PRODUCT.UnderlyingFuture;
            SecurityId      secId         = future.SecurityId;
            GenericSecurity sec           = GenericSecurity.of(INFO);
            ReferenceData   refData       = ImmutableReferenceData.of(secId, sec);

            assertThrows(() => test.createProduct(refData), typeof(System.InvalidCastException));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(BondFutureOption beanToCopy)
 {
     this.securityId_Renamed       = beanToCopy.SecurityId;
     this.putCall_Renamed          = beanToCopy.PutCall;
     this.strikePrice_Renamed      = beanToCopy.StrikePrice;
     this.expiryDate_Renamed       = beanToCopy.ExpiryDate;
     this.expiryTime_Renamed       = beanToCopy.ExpiryTime;
     this.expiryZone_Renamed       = beanToCopy.ExpiryZone;
     this.premiumStyle_Renamed     = beanToCopy.PremiumStyle;
     this.rounding_Renamed         = beanToCopy.Rounding;
     this.underlyingFuture_Renamed = beanToCopy.UnderlyingFuture;
 }
Exemplo n.º 8
0
        //-------------------------------------------------------------------------
        public BondFutureOption createProduct(ReferenceData refData)
        {
            Security security = refData.getValue(underlyingFutureId);

            if (!(security is BondFutureSecurity))
            {
                throw new System.InvalidCastException(Messages.format("{} underlying future '{}' resolved to '{}' when '{}' was expected", typeof(BondFutureOptionSecurity).Name, underlyingFutureId, security.GetType().Name, typeof(BondFutureSecurity).Name));
            }
            BondFutureSecurity futureSec  = (BondFutureSecurity)security;
            BondFuture         underlying = futureSec.createProduct(refData);

            return(new BondFutureOption(SecurityId, putCall, strikePrice, expiryDate, expiryTime, expiryZone, premiumStyle, rounding, underlying));
        }
        //-------------------------------------------------------------------------
        public virtual void test_builder_full()
        {
            BondFuture test = BondFuture.builder().securityId(SECURITY_ID).deliveryBasket(BOND_PRODUCT).conversionFactors(CONVERSION_FACTOR).firstNoticeDate(FIRST_NOTICE_DATE).firstDeliveryDate(FIRST_DELIVERY_DATE).lastNoticeDate(LAST_NOTICE_DATE).lastDeliveryDate(LAST_DELIVERY_DATE).lastTradeDate(LAST_TRADING_DATE).rounding(ROUNDING).build();

            assertEquals(test.DeliveryBasket, ImmutableList.copyOf(BOND_PRODUCT));
            assertEquals(test.ConversionFactors, ImmutableList.copyOf(CONVERSION_FACTOR));
            assertEquals(test.Currency, USD);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.FirstNoticeDate, FIRST_NOTICE_DATE);
            assertEquals(test.LastNoticeDate, LAST_NOTICE_DATE);
            assertEquals(test.FirstDeliveryDate, FIRST_DELIVERY_DATE);
            assertEquals(test.LastDeliveryDate, LAST_DELIVERY_DATE);
            assertEquals(test.LastTradeDate, LAST_TRADING_DATE);
            assertEquals(test.Rounding, ROUNDING);
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            BondFuture product  = target.Product;
            QuoteId    quoteId  = QuoteId.of(product.SecurityId.StandardId, FieldName.SETTLEMENT_PRICE);
            Currency   currency = product.Currency;

            // use lookup to build requirements
            FunctionRequirements freqs = FunctionRequirements.builder().valueRequirements(quoteId).outputCurrencies(currency).build();
            LegalEntityDiscountingMarketDataLookup ledLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));

            foreach (FixedCouponBond bond in product.DeliveryBasket)
            {
                freqs = freqs.combinedWith(ledLookup.requirements(bond.SecurityId, bond.LegalEntityId, bond.Currency));
            }
            return(freqs);
        }
Exemplo n.º 11
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 1574023291:         // securityId
                    this.securityId_Renamed = (SecurityId)newValue;
                    break;

                case -219971059:         // putCall
                    this.putCall_Renamed = (PutCall)newValue;
                    break;

                case 50946231:         // strikePrice
                    this.strikePrice_Renamed = (double?)newValue.Value;
                    break;

                case -816738431:         // expiryDate
                    this.expiryDate_Renamed = (LocalDate)newValue;
                    break;

                case -816254304:         // expiryTime
                    this.expiryTime_Renamed = (LocalTime)newValue;
                    break;

                case -816069761:         // expiryZone
                    this.expiryZone_Renamed = (ZoneId)newValue;
                    break;

                case -1257652838:         // premiumStyle
                    this.premiumStyle_Renamed = (FutureOptionPremiumStyle)newValue;
                    break;

                case -142444:         // rounding
                    this.rounding_Renamed = (Rounding)newValue;
                    break;

                case -165476480:         // underlyingFuture
                    this.underlyingFuture_Renamed = (BondFuture)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        public virtual void test_builder_fail()
        {
            // wrong size
            assertThrowsIllegalArg(() => BondFuture.builder().securityId(SECURITY_ID).deliveryBasket(BOND_PRODUCT[0]).conversionFactors(CONVERSION_FACTOR).firstNoticeDate(FIRST_NOTICE_DATE).lastNoticeDate(LAST_NOTICE_DATE).lastTradeDate(LAST_TRADING_DATE).rounding(ROUNDING).build());
            // first notice date missing
            assertThrowsIllegalArg(() => BondFuture.builder().securityId(SECURITY_ID).deliveryBasket(BOND_PRODUCT).conversionFactors(CONVERSION_FACTOR).lastNoticeDate(LAST_NOTICE_DATE).lastTradeDate(LAST_TRADING_DATE).rounding(ROUNDING).build());
            // last notice date missing
            assertThrowsIllegalArg(() => BondFuture.builder().securityId(SECURITY_ID).deliveryBasket(BOND_PRODUCT).conversionFactors(CONVERSION_FACTOR).firstNoticeDate(FIRST_NOTICE_DATE).lastTradeDate(LAST_TRADING_DATE).rounding(ROUNDING).build());
            // basket list empty
            assertThrowsIllegalArg(() => BondFuture.builder().securityId(SECURITY_ID).conversionFactors(CONVERSION_FACTOR).firstNoticeDate(FIRST_NOTICE_DATE).lastNoticeDate(LAST_NOTICE_DATE).lastTradeDate(LAST_TRADING_DATE).rounding(ROUNDING).build());
            // notional mismatch
            FixedCouponBond bond0 = BOND_PRODUCT[0];
            FixedCouponBond bond1 = bond0.toBuilder().notional(100).build();
            FixedCouponBond bond2 = bond0.toBuilder().currency(Currency.CAD).build();

            assertThrowsIllegalArg(() => BondFuture.builder().securityId(SECURITY_ID).deliveryBasket(bond0, bond1).conversionFactors(CONVERSION_FACTOR[0], CONVERSION_FACTOR[1]).firstNoticeDate(FIRST_NOTICE_DATE).lastNoticeDate(LAST_NOTICE_DATE).firstDeliveryDate(FIRST_DELIVERY_DATE).lastDeliveryDate(LAST_DELIVERY_DATE).lastTradeDate(LAST_TRADING_DATE).rounding(ROUNDING).build());
            // currency mismatch
            assertThrowsIllegalArg(() => BondFuture.builder().securityId(SECURITY_ID).deliveryBasket(bond0, bond2).conversionFactors(CONVERSION_FACTOR[0], CONVERSION_FACTOR[1]).firstNoticeDate(FIRST_NOTICE_DATE).lastNoticeDate(LAST_NOTICE_DATE).firstDeliveryDate(FIRST_DELIVERY_DATE).lastDeliveryDate(LAST_DELIVERY_DATE).lastTradeDate(LAST_TRADING_DATE).rounding(ROUNDING).build());
        }
Exemplo n.º 13
0
 /// <summary>
 /// Creates an instance. </summary>
 /// <param name="securityId">  the value of the property, not null </param>
 /// <param name="putCall">  the value of the property </param>
 /// <param name="strikePrice">  the value of the property </param>
 /// <param name="expiryDate">  the value of the property, not null </param>
 /// <param name="expiryTime">  the value of the property, not null </param>
 /// <param name="expiryZone">  the value of the property, not null </param>
 /// <param name="premiumStyle">  the value of the property, not null </param>
 /// <param name="rounding">  the value of the property, not null </param>
 /// <param name="underlyingFuture">  the value of the property, not null </param>
 internal BondFutureOption(SecurityId securityId, PutCall putCall, double strikePrice, LocalDate expiryDate, LocalTime expiryTime, ZoneId expiryZone, FutureOptionPremiumStyle premiumStyle, Rounding rounding, BondFuture underlyingFuture)
 {
     JodaBeanUtils.notNull(securityId, "securityId");
     JodaBeanUtils.notNull(expiryDate, "expiryDate");
     JodaBeanUtils.notNull(expiryTime, "expiryTime");
     JodaBeanUtils.notNull(expiryZone, "expiryZone");
     JodaBeanUtils.notNull(premiumStyle, "premiumStyle");
     JodaBeanUtils.notNull(rounding, "rounding");
     JodaBeanUtils.notNull(underlyingFuture, "underlyingFuture");
     this.securityId       = securityId;
     this.putCall          = putCall;
     this.strikePrice      = strikePrice;
     this.expiryDate       = expiryDate;
     this.expiryTime       = expiryTime;
     this.expiryZone       = expiryZone;
     this.premiumStyle     = premiumStyle;
     this.rounding         = rounding;
     this.underlyingFuture = underlyingFuture;
     validate();
 }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            BondFutureOption option = target.Product;
            BondFuture       future = option.UnderlyingFuture;

            // use lookup to build requirements
            QuoteId optionQuoteId      = QuoteId.of(option.SecurityId.StandardId, FieldName.SETTLEMENT_PRICE);
            FunctionRequirements freqs = FunctionRequirements.builder().valueRequirements(optionQuoteId).outputCurrencies(future.Currency, option.Currency).build();
            LegalEntityDiscountingMarketDataLookup ledLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));

            foreach (FixedCouponBond bond in future.DeliveryBasket)
            {
                freqs = freqs.combinedWith(ledLookup.requirements(bond.SecurityId, bond.LegalEntityId, bond.Currency));
            }
            BondFutureOptionMarketDataLookup optionLookup = parameters.getParameter(typeof(BondFutureOptionMarketDataLookup));
            FunctionRequirements             optionReqs   = optionLookup.requirements(future.SecurityId);

            return(freqs.combinedWith(optionReqs));
        }
 //-------------------------------------------------------------------------
 internal static BondFuture sut()
 {
     return(BondFuture.builder().securityId(SECURITY_ID).deliveryBasket(BOND_PRODUCT).conversionFactors(ImmutableList.copyOf(CONVERSION_FACTOR)).firstNoticeDate(FIRST_NOTICE_DATE).firstDeliveryDate(FIRST_DELIVERY_DATE).lastNoticeDate(LAST_NOTICE_DATE).lastDeliveryDate(LAST_DELIVERY_DATE).lastTradeDate(LAST_TRADING_DATE).rounding(ROUNDING).build());
 }
Exemplo n.º 16
0
 /// <summary>
 /// Sets the future that was traded.
 /// <para>
 /// The product captures the contracted financial details.
 /// </para>
 /// </summary>
 /// <param name="product">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder product(BondFuture product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }
Exemplo n.º 17
0
 /// <summary>
 /// Sets the underlying future. </summary>
 /// <param name="underlyingFuture">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder underlyingFuture(BondFuture underlyingFuture)
 {
     JodaBeanUtils.notNull(underlyingFuture, "underlyingFuture");
     this.underlyingFuture_Renamed = underlyingFuture;
     return(this);
 }
 internal static BondFuture sut2()
 {
     return(BondFuture.builder().securityId(SECURITY_ID2).conversionFactors(0.9187).deliveryBasket(BOND_PRODUCT[3]).firstNoticeDate(FIRST_NOTICE_DATE.plusDays(7)).lastNoticeDate(LAST_NOTICE_DATE.plusDays(7)).lastTradeDate(LAST_TRADING_DATE.plusDays(7)).build());
 }