public virtual void test_builder()
        {
            ResolvedCapitalIndexedBond test = sut();

            assertEquals(test.Currency, USD);
            assertEquals(test.DayCount, ACT_ACT_ISDA);
            assertEquals(test.StartDate, PERIODIC[0].StartDate);
            assertEquals(test.EndDate, PERIODIC[3].EndDate);
            assertEquals(test.UnadjustedStartDate, PERIODIC[0].UnadjustedStartDate);
            assertEquals(test.UnadjustedEndDate, PERIODIC[3].UnadjustedEndDate);
            assertEquals(test.LegalEntityId, LEGAL_ENTITY);
            assertEquals(test.NominalPayment, NOMINAL);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.PeriodicPayments.toArray(), PERIODIC);
            assertEquals(test.SettlementDateOffset, SETTLE_OFFSET);
            assertEquals(test.YieldConvention, US_IL_REAL);
            assertEquals(test.hasExCouponPeriod(), false);
            assertEquals(test.FirstIndexValue, RATE_CALC.FirstIndexValue.Value);
            assertEquals(test.findPeriod(PERIODIC[0].UnadjustedStartDate), (test.PeriodicPayments.get(0)));
            assertEquals(test.findPeriod(LocalDate.MIN), null);
            assertEquals(test.findPeriodIndex(PERIODIC[0].UnadjustedStartDate), int?.of(0));
            assertEquals(test.findPeriodIndex(PERIODIC[1].UnadjustedStartDate), int?.of(1));
            assertEquals(test.findPeriodIndex(LocalDate.MIN), int?.empty());
            assertEquals(test.calculateSettlementDateFromValuation(date(2015, 6, 30), REF_DATA), SETTLE_OFFSET.adjust(date(2015, 6, 30), REF_DATA));
        }
コード例 #2
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (PortfolioItemInfo)newValue;
                    break;

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

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

                case 73828649:         // settlement
                    this.settlement_Renamed = (ResolvedCapitalIndexedBondSettlement)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
コード例 #3
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(ResolvedCapitalIndexedBondTrade beanToCopy)
 {
     this.info_Renamed       = beanToCopy.Info;
     this.product_Renamed    = beanToCopy.Product;
     this.quantity_Renamed   = beanToCopy.Quantity;
     this.settlement_Renamed = beanToCopy.settlement;
 }
コード例 #4
0
        public ResolvedCapitalIndexedBondTrade resolve(ReferenceData refData)
        {
            ResolvedCapitalIndexedBond resolvedProduct = product.resolve(refData);
            LocalDate settlementDate = calculateSettlementDate(refData);

            double accruedInterest = resolvedProduct.accruedInterest(settlementDate) / product.Notional;

            if (settlementDate.isBefore(resolvedProduct.StartDate))
            {
                throw new System.ArgumentException("Settlement date must not be before bond starts");
            }
            BondPaymentPeriod settlePeriod;

            if (product.YieldConvention.Equals(CapitalIndexedBondYieldConvention.GB_IL_FLOAT))
            {
                settlePeriod = KnownAmountBondPaymentPeriod.of(Payment.of(product.Currency, -product.Notional * quantity * (price + accruedInterest), settlementDate), SchedulePeriod.of(resolvedProduct.StartDate, settlementDate, product.AccrualSchedule.StartDate, settlementDate));
            }
            else
            {
                RateComputation rateComputation = product.RateCalculation.createRateComputation(settlementDate);
                settlePeriod = CapitalIndexedBondPaymentPeriod.builder().startDate(resolvedProduct.StartDate).unadjustedStartDate(product.AccrualSchedule.StartDate).endDate(settlementDate).rateComputation(rateComputation).currency(product.Currency).notional(-product.Notional * quantity * (price + accruedInterest)).realCoupon(1d).build();
            }

            return(ResolvedCapitalIndexedBondTrade.builder().info(info).product(resolvedProduct).quantity(quantity).settlement(ResolvedCapitalIndexedBondSettlement.of(settlementDate, price, settlePeriod)).build());
        }
コード例 #5
0
 /// <summary>
 /// Creates an instance. </summary>
 /// <param name="info">  the value of the property, not null </param>
 /// <param name="product">  the value of the property, not null </param>
 /// <param name="quantity">  the value of the property </param>
 /// <param name="settlement">  the value of the property </param>
 internal ResolvedCapitalIndexedBondTrade(PortfolioItemInfo info, ResolvedCapitalIndexedBond product, double quantity, ResolvedCapitalIndexedBondSettlement settlement)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(product, "product");
     this.info       = info;
     this.product    = product;
     this.quantity   = quantity;
     this.settlement = settlement;
 }
        //-------------------------------------------------------------------------
        public virtual void test_yearFraction_scheduleInfo()
        {
            ResolvedCapitalIndexedBond      @base  = sut();
            CapitalIndexedBondPaymentPeriod period = @base.PeriodicPayments.get(0);
            AtomicBoolean eom = new AtomicBoolean(false);
            DayCount      dc  = new DayCountAnonymousInnerClass(this, @base, period, eom);
            ResolvedCapitalIndexedBond test = @base.toBuilder().dayCount(dc).build();

            assertEquals(test.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), 0.5);
            // test with EOM=true
            ResolvedCapitalIndexedBond test2 = test.toBuilder().rollConvention(RollConventions.EOM).build();

            eom.set(true);
            assertEquals(test2.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), 0.5);
        }
コード例 #7
0
        public virtual void test_resolve()
        {
            CapitalIndexedBond @base = sut();

            LocalDate[] unAdjDates = new LocalDate[] { LocalDate.of(2008, 1, 13), LocalDate.of(2008, 7, 13), LocalDate.of(2009, 1, 13), LocalDate.of(2009, 7, 13), LocalDate.of(2010, 1, 13) };
            CapitalIndexedBondPaymentPeriod[] periodic = new CapitalIndexedBondPaymentPeriod[4];
            for (int i = 0; i < 4; ++i)
            {
                LocalDate       start      = SCHEDULE_ADJ.adjust(unAdjDates[i], REF_DATA);
                LocalDate       end        = SCHEDULE_ADJ.adjust(unAdjDates[i + 1], REF_DATA);
                LocalDate       detachment = EX_COUPON.adjust(end, REF_DATA);
                RateComputation comp       = RATE_CALC.createRateComputation(end);
                periodic[i] = CapitalIndexedBondPaymentPeriod.builder().currency(USD).startDate(start).endDate(end).unadjustedStartDate(unAdjDates[i]).unadjustedEndDate(unAdjDates[i + 1]).detachmentDate(detachment).realCoupon(COUPONS[i]).rateComputation(comp).notional(NOTIONAL).build();
            }
            CapitalIndexedBondPaymentPeriod nominalExp = periodic[3].withUnitCoupon(periodic[0].StartDate, periodic[0].UnadjustedStartDate);
            ResolvedCapitalIndexedBond      expected   = ResolvedCapitalIndexedBond.builder().securityId(SECURITY_ID).dayCount(ACT_ACT_ISDA).legalEntityId(LEGAL_ENTITY).nominalPayment(nominalExp).periodicPayments(periodic).frequency(SCHEDULE.Frequency).rollConvention(SCHEDULE.calculatedRollConvention()).settlementDateOffset(SETTLE_OFFSET).yieldConvention(US_IL_REAL).rateCalculation(@base.RateCalculation).build();

            assertEquals(@base.resolve(REF_DATA), expected);
        }
 internal static ResolvedCapitalIndexedBond sut2()
 {
     return(ResolvedCapitalIndexedBond.builder().securityId(CapitalIndexedBondTest.sut2().SecurityId).dayCount(NL_365).legalEntityId(LegalEntityId.of("OG-Ticker", "US-Govt1")).nominalPayment(PERIODIC[1].withUnitCoupon(PERIODIC[0].StartDate, PERIODIC[0].UnadjustedStartDate)).periodicPayments(PERIODIC[0], PERIODIC[1]).frequency(CapitalIndexedBondTest.sut2().AccrualSchedule.Frequency).rollConvention(CapitalIndexedBondTest.sut2().AccrualSchedule.calculatedRollConvention()).settlementDateOffset(DaysAdjustment.ofBusinessDays(3, GBLO)).yieldConvention(GB_IL_FLOAT).rateCalculation(CapitalIndexedBondTest.sut2().RateCalculation).build());
 }
 //-------------------------------------------------------------------------
 internal static ResolvedCapitalIndexedBond sut()
 {
     return(ResolvedCapitalIndexedBond.builder().securityId(CapitalIndexedBondTest.sut().SecurityId).dayCount(ACT_ACT_ISDA).legalEntityId(LEGAL_ENTITY).nominalPayment(NOMINAL).periodicPayments(PERIODIC).frequency(CapitalIndexedBondTest.sut().AccrualSchedule.Frequency).rollConvention(CapitalIndexedBondTest.sut().AccrualSchedule.calculatedRollConvention()).settlementDateOffset(SETTLE_OFFSET).yieldConvention(US_IL_REAL).rateCalculation(RATE_CALC).build());
 }
コード例 #10
0
        public virtual void test_builder_fail()
        {
            CapitalIndexedBondPaymentPeriod period = CapitalIndexedBondPaymentPeriod.builder().startDate(PERIODIC[2].StartDate).endDate(PERIODIC[2].EndDate).currency(GBP).notional(NOTIONAL).rateComputation(PERIODIC[2].RateComputation).realCoupon(COUPON).build();

            assertThrowsIllegalArg(() => ResolvedCapitalIndexedBond.builder().dayCount(ACT_ACT_ISDA).legalEntityId(LEGAL_ENTITY).nominalPayment(NOMINAL).periodicPayments(PERIODIC[0], PERIODIC[1], period, PERIODIC[3]).settlementDateOffset(SETTLE_OFFSET).yieldConvention(US_IL_REAL).build());
        }
コード例 #11
0
 /// <summary>
 /// Sets the resolved capital indexed bond product.
 /// <para>
 /// The product captures the contracted financial details of the trade.
 /// </para>
 /// </summary>
 /// <param name="product">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder product(ResolvedCapitalIndexedBond product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }
コード例 #12
0
        public ResolvedCapitalIndexedBondTrade resolve(ReferenceData refData)
        {
            ResolvedCapitalIndexedBond resolved = product.resolve(refData);

            return(new ResolvedCapitalIndexedBondTrade(info, resolved, Quantity, null));
        }