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());
        }
        public virtual void test_resolve1()
        {
            ResolvedCapitalIndexedBondTrade test     = sut1().resolve(REF_DATA);
            ResolvedCapitalIndexedBondTrade expected = ResolvedCapitalIndexedBondTrade.builder().info(TRADE_INFO).product(PRODUCT1.resolve(REF_DATA)).quantity(QUANTITY).settlement(ResolvedCapitalIndexedBondSettlement.of(SETTLEMENT_DATE, PRICE, SETTLEMENT1)).build();

            assertEquals(test, expected);
        }
Example #3
0
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            ResolvedCapitalIndexedBondTrade expected = ResolvedCapitalIndexedBondTrade.builder().info(POSITION_INFO).product(PRODUCT.resolve(REF_DATA)).quantity(QUANTITY).build();

            assertEquals(sut().resolve(REF_DATA), expected);
        }