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 = (FixedCouponBond)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);
            }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(FixedCouponBondTrade beanToCopy)
 {
     this.info_Renamed     = beanToCopy.Info;
     this.product_Renamed  = beanToCopy.Product;
     this.quantity_Renamed = beanToCopy.Quantity;
     this.price_Renamed    = beanToCopy.Price;
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(FixedCouponBondPosition beanToCopy)
 {
     this.info_Renamed          = beanToCopy.Info;
     this.product_Renamed       = beanToCopy.Product;
     this.longQuantity_Renamed  = beanToCopy.LongQuantity;
     this.shortQuantity_Renamed = beanToCopy.ShortQuantity;
 }
            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 = (FixedCouponBond)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);
            }
Пример #5
0
        public virtual void test_resolve()
        {
            FixedCouponBond         @base    = sut();
            ResolvedFixedCouponBond resolved = @base.resolve(REF_DATA);

            assertEquals(resolved.LegalEntityId, LEGAL_ENTITY);
            assertEquals(resolved.SettlementDateOffset, DATE_OFFSET);
            assertEquals(resolved.YieldConvention, YIELD_CONVENTION);
            ImmutableList <FixedCouponBondPaymentPeriod> periodicPayments = resolved.PeriodicPayments;
            int expNum = 20;

            assertEquals(periodicPayments.size(), expNum);
            LocalDate unadjustedEnd = END_DATE;
            Schedule  unadjusted    = PERIOD_SCHEDULE.createSchedule(REF_DATA).toUnadjusted();

            for (int i = 0; i < expNum; ++i)
            {
                FixedCouponBondPaymentPeriod payment = periodicPayments.get(expNum - 1 - i);
                assertEquals(payment.Currency, EUR);
                assertEquals(payment.Notional, NOTIONAL);
                assertEquals(payment.FixedRate, FIXED_RATE);
                assertEquals(payment.UnadjustedEndDate, unadjustedEnd);
                assertEquals(payment.EndDate, BUSINESS_ADJUST.adjust(unadjustedEnd, REF_DATA));
                assertEquals(payment.PaymentDate, payment.EndDate);
                LocalDate unadjustedStart = unadjustedEnd.minusMonths(6);
                assertEquals(payment.UnadjustedStartDate, unadjustedStart);
                assertEquals(payment.StartDate, BUSINESS_ADJUST.adjust(unadjustedStart, REF_DATA));
                assertEquals(payment.YearFraction, unadjusted.getPeriod(expNum - 1 - i).yearFraction(DAY_COUNT, unadjusted));
                assertEquals(payment.DetachmentDate, EX_COUPON.adjust(payment.PaymentDate, REF_DATA));
                unadjustedEnd = unadjustedStart;
            }
            Payment expectedPayment = Payment.of(CurrencyAmount.of(EUR, NOTIONAL), BUSINESS_ADJUST.adjust(END_DATE, REF_DATA));

            assertEquals(resolved.NominalPayment, expectedPayment);
        }
Пример #6
0
        internal static FixedCouponBond sut2()
        {
            BusinessDayAdjustment adj  = BusinessDayAdjustment.of(MODIFIED_FOLLOWING, SAT_SUN);
            PeriodicSchedule      sche = PeriodicSchedule.of(START_DATE, END_DATE, Frequency.P12M, adj, StubConvention.SHORT_INITIAL, true);

            return(FixedCouponBond.builder().securityId(SECURITY_ID2).dayCount(DayCounts.ACT_360).fixedRate(0.005).legalEntityId(LegalEntityId.of("OG-Ticker", "BUN EUR 2")).currency(GBP).notional(1.0e6).accrualSchedule(sche).settlementDateOffset(DaysAdjustment.ofBusinessDays(2, SAT_SUN)).yieldConvention(FixedCouponBondYieldConvention.GB_BUMP_DMO).build());
        }
Пример #7
0
        static BondFuturesJpyEnd2EndTest()
        {
            for (int i = 0; i < NB_UND_BONDS; ++i)
            {
                PeriodicSchedule periodSchedule = PeriodicSchedule.of(START_DATE[i], MATURITY_DATE[i], Frequency.P6M, BUSINESS_ADJUST, StubConvention.SHORT_INITIAL, false);
                FixedCouponBond  product        = FixedCouponBond.builder().securityId(SecurityId.of(BOND_SECURITY_ID[i])).dayCount(DAY_COUNT).fixedRate(UND_RATES[i] * ONE_PERCENT).legalEntityId(ISSUER_ID).currency(JPY).notional(NOTIONAL).accrualSchedule(periodSchedule).settlementDateOffset(SETTLEMENT_DAYS).yieldConvention(YIELD_CONVENTION).build();
                UND_BOND[i] = product;
            }
            UND_BOND_SEP = new FixedCouponBond[NB_UND_BONDS - 2];
            Array.Copy(UND_BOND, 2, UND_BOND_SEP, 0, NB_UND_BONDS - 2);
            UND_BOND_JUN = new FixedCouponBond[NB_UND_BONDS - 1];
            Array.Copy(UND_BOND, 1, UND_BOND_JUN, 0, NB_UND_BONDS - 1);
            double[]               timeIssuer  = new double[] { 0.25136612021857924, 0.4972677595628415, 1.0139980537465378, 2.013998053746538, 2.857833670184894, 3.857833670184894, 4.860655737704918, 5.857833670184894, 7.104409012650647, 7.857833670184894, 8.857923497267759, 9.863313122239688, 14.857833670184894, 19.857833670184895, 29.857833670184895, 39.11262819073284 };
            double[]               rateIssuer  = new double[] { -0.0013117084834668065, -0.0010851901424876163, -0.0020906775838723216, -0.0022137102045172784, -0.0022695678374162888, -0.0023424568490920798, -0.0021603059162879916, -0.0021667343131861225, -0.0018285921969274823, -0.001355094018965514, -6.763044056712535E-4, 1.9555294306801752E-4, 0.003944125562941363, 0.008054233458390252, 0.012276105941434846, 0.013537766297065804 };
            double[]               timeRepo    = new double[] { 0.00273224043715847, 0.01912568306010929, 0.040983606557377046, 0.05737704918032787, 0.07923497267759563, 0.2459016393442623, 0.4972677595628415, 1.0002994236095515 };
            double[]               rateRepo    = new double[] { 2.599662058772748E-4, -8.403529976927196E-4, -0.0010105103936934236, -0.0011506617573950931, -0.0012708071334455143, -0.00146106683851595, -0.0014710815100096722, -0.001481096281798276 };
            CurveMetadata          metaIssuer  = Curves.zeroRates(ISSUER_CURVE_NAME, ACT_ACT_ISDA);
            InterpolatedNodalCurve curveIssuer = InterpolatedNodalCurve.of(metaIssuer, DoubleArray.copyOf(timeIssuer), DoubleArray.copyOf(rateIssuer), INTERPOLATOR);
            DiscountFactors        dscIssuer   = ZeroRateDiscountFactors.of(JPY, VALUATION, curveIssuer);
            CurveMetadata          metaRepo    = Curves.zeroRates(REPO_CURVE_NAME, ACT_ACT_ISDA);
            InterpolatedNodalCurve curve       = InterpolatedNodalCurve.of(metaRepo, DoubleArray.copyOf(timeRepo), DoubleArray.copyOf(rateRepo), INTERPOLATOR);
            DiscountFactors        dscRepo     = ZeroRateDiscountFactors.of(JPY, VALUATION, curve);

            LED_PROVIDER = ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, JPY), dscIssuer)).issuerCurveGroups(ImmutableMap.of(ISSUER_ID, GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO, JPY), dscRepo)).repoCurveGroups(ImmutableMap.of(ISSUER_ID, GROUP_REPO)).build();
        }
Пример #8
0
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            FixedCouponBond product = target.Product;

            // use lookup to build requirements
            LegalEntityDiscountingMarketDataLookup bondLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));

            return(bondLookup.requirements(product.SecurityId, product.LegalEntityId, product.Currency));
        }
 static BondFutureTest()
 {
     for (int i = 0; i < NB_BOND; ++i)
     {
         LocalDate        endDate        = START_DATE[i].plus(BOND_TENOR[i]);
         PeriodicSchedule periodSchedule = PeriodicSchedule.of(START_DATE[i], endDate, Frequency.P6M, BUSINESS_ADJUST, StubConvention.SHORT_INITIAL, false);
         FixedCouponBond  product        = FixedCouponBond.builder().securityId(SecurityId.of("OG-Test", "Bond " + i)).dayCount(DAY_COUNT).fixedRate(RATE[i]).legalEntityId(ISSUER_ID).currency(USD).notional(NOTIONAL).accrualSchedule(periodSchedule).settlementDateOffset(SETTLEMENT_DAYS).yieldConvention(YIELD_CONVENTION).exCouponPeriod(EX_COUPON).build();
         BOND_PRODUCT[i]    = product;
         RESOLVED_BASKET[i] = product.resolve(REF_DATA);
     }
 }
Пример #10
0
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            FixedCouponBond test = sut();

            assertEquals(test.SecurityId, SECURITY_ID);
            assertEquals(test.DayCount, DAY_COUNT);
            assertEquals(test.FixedRate, FIXED_RATE);
            assertEquals(test.LegalEntityId, LEGAL_ENTITY);
            assertEquals(test.Currency, EUR);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.AccrualSchedule, PERIOD_SCHEDULE);
            assertEquals(test.SettlementDateOffset, DATE_OFFSET);
            assertEquals(test.YieldConvention, YIELD_CONVENTION);
            assertEquals(test.ExCouponPeriod, EX_COUPON);
        }
        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());
        }
 /// <summary>
 /// Sets the bond 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(FixedCouponBond product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }
 internal static FixedCouponBondSecurity createSecurity(FixedCouponBond product)
 {
     return(FixedCouponBondSecurity.builder().info(SecurityInfo.of(product.SecurityId, INFO.PriceInfo)).currency(product.Currency).notional(product.Notional).accrualSchedule(product.AccrualSchedule).fixedRate(product.FixedRate).dayCount(product.DayCount).yieldConvention(product.YieldConvention).legalEntityId(product.LegalEntityId).settlementDateOffset(product.SettlementDateOffset).exCouponPeriod(product.ExCouponPeriod).build());
 }
Пример #14
0
 public virtual void test_builder_fail()
 {
     assertThrowsIllegalArg(() => FixedCouponBond.builder().securityId(SECURITY_ID).dayCount(DAY_COUNT).fixedRate(FIXED_RATE).legalEntityId(LEGAL_ENTITY).currency(EUR).notional(NOTIONAL).accrualSchedule(PERIOD_SCHEDULE).settlementDateOffset(DATE_OFFSET).yieldConvention(YIELD_CONVENTION).exCouponPeriod(DaysAdjustment.ofBusinessDays(EX_COUPON_DAYS, EUTA, BUSINESS_ADJUST)).build());
     assertThrowsIllegalArg(() => FixedCouponBond.builder().securityId(SECURITY_ID).dayCount(DAY_COUNT).fixedRate(FIXED_RATE).legalEntityId(LEGAL_ENTITY).currency(EUR).notional(NOTIONAL).accrualSchedule(PERIOD_SCHEDULE).settlementDateOffset(DaysAdjustment.ofBusinessDays(-3, EUTA)).yieldConvention(YIELD_CONVENTION).build());
 }
Пример #15
0
 //-------------------------------------------------------------------------
 internal static FixedCouponBond sut()
 {
     return(FixedCouponBond.builder().securityId(SECURITY_ID).dayCount(DAY_COUNT).fixedRate(FIXED_RATE).legalEntityId(LEGAL_ENTITY).currency(EUR).notional(NOTIONAL).accrualSchedule(PERIOD_SCHEDULE).settlementDateOffset(DATE_OFFSET).yieldConvention(YIELD_CONVENTION).exCouponPeriod(EX_COUPON).build());
 }