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());
        }
示例#2
0
        //-------------------------------------------------------------------------
        public virtual void test_adjustPaymentDate()
        {
            KnownAmountBondPaymentPeriod test     = KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_01).startDate(DATE_2014_03_30).unadjustedStartDate(DATE_2014_03_30).endDate(DATE_2014_10_01).unadjustedEndDate(DATE_2014_09_30).build();
            KnownAmountBondPaymentPeriod expected = KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).unadjustedStartDate(DATE_2014_03_30).endDate(DATE_2014_10_01).unadjustedEndDate(DATE_2014_09_30).build();

            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(0))), test);
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), expected);
        }
示例#3
0
        //-------------------------------------------------------------------------
        public virtual void test_collectIndices_simple()
        {
            KnownAmountBondPaymentPeriod test = KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).unadjustedStartDate(DATE_2014_03_30).endDate(DATE_2014_10_01).unadjustedEndDate(DATE_2014_09_30).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of());
        }
示例#4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            KnownAmountBondPaymentPeriod test = KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).unadjustedStartDate(DATE_2014_03_30).endDate(DATE_2014_10_01).unadjustedEndDate(DATE_2014_09_30).build();

            coverImmutableBean(test);
            KnownAmountBondPaymentPeriod test2 = KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03.negated()).startDate(DATE_2014_06_30).endDate(DATE_2014_09_30).build();

            coverBeanEquals(test, test2);
        }
示例#5
0
        public virtual void test_builder_defaultDates()
        {
            KnownAmountBondPaymentPeriod test = KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).endDate(DATE_2014_10_01).build();

            assertEquals(test.Payment, PAYMENT_2014_10_03);
            assertEquals(test.StartDate, DATE_2014_03_30);
            assertEquals(test.UnadjustedStartDate, DATE_2014_03_30);
            assertEquals(test.EndDate, DATE_2014_10_01);
            assertEquals(test.UnadjustedEndDate, DATE_2014_10_01);
            assertEquals(test.PaymentDate, DATE_2014_10_03);
            assertEquals(test.Currency, GBP);
        }
示例#6
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         KnownAmountBondPaymentPeriod other = (KnownAmountBondPaymentPeriod)obj;
         return(JodaBeanUtils.equal(payment, other.payment) && JodaBeanUtils.equal(startDate, other.startDate) && JodaBeanUtils.equal(endDate, other.endDate) && JodaBeanUtils.equal(unadjustedStartDate, other.unadjustedStartDate) && JodaBeanUtils.equal(unadjustedEndDate, other.unadjustedEndDate));
     }
     return(false);
 }
示例#7
0
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            SchedulePeriod sched = SchedulePeriod.of(DATE_2014_03_30, DATE_2014_09_30);
            KnownAmountBondPaymentPeriod test = KnownAmountBondPaymentPeriod.of(PAYMENT_2014_10_03, sched);

            assertEquals(test.Payment, PAYMENT_2014_10_03);
            assertEquals(test.StartDate, DATE_2014_03_30);
            assertEquals(test.UnadjustedStartDate, DATE_2014_03_30);
            assertEquals(test.EndDate, DATE_2014_09_30);
            assertEquals(test.UnadjustedEndDate, DATE_2014_09_30);
            assertEquals(test.PaymentDate, DATE_2014_10_03);
            assertEquals(test.Currency, GBP);
        }
示例#8
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance based on a payment and schedule period.
 /// </summary>
 /// <param name="payment">  the payment </param>
 /// <param name="period">  the schedule period </param>
 /// <returns> the period </returns>
 public static KnownAmountBondPaymentPeriod of(Payment payment, SchedulePeriod period)
 {
     return(KnownAmountBondPaymentPeriod.builder().payment(payment).startDate(period.StartDate).endDate(period.EndDate).unadjustedStartDate(period.UnadjustedStartDate).unadjustedEndDate(period.UnadjustedEndDate).build());
 }
示例#9
0
 public virtual void test_builder_invalid()
 {
     assertThrowsIllegalArg(() => KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03).endDate(DATE_2014_10_01).build());
     assertThrowsIllegalArg(() => KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_10_01).build());
     assertThrowsIllegalArg(() => KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_10_01).endDate(DATE_2014_10_01).build());
 }
示例#10
0
        public virtual void test_serialization()
        {
            KnownAmountBondPaymentPeriod test = KnownAmountBondPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).unadjustedStartDate(DATE_2014_03_30).endDate(DATE_2014_10_01).unadjustedEndDate(DATE_2014_09_30).build();

            assertSerialization(test);
        }