示例#1
0
        public virtual void test_presentValueFromCleanPrice_early()
        {
            CurrencyAmount computed  = PRICER.presentValueFromCleanPrice(TRADE_EARLY, RATES_PROVIDER, ISSUER_RATES_PROVIDER, REF_DATA, TRADE_PRICE);
            CurrencyAmount netAmount = PRICER.netAmount(TRADE_EARLY, RATES_PROVIDER);
            CapitalIndexedBondPaymentPeriod period = PRODUCT.resolve(REF_DATA).PeriodicPayments.get(16);
            double pvDiff    = PERIOD_PRICER.presentValue(period, RATES_PROVIDER, ISSUER_DISCOUNT_FACTORS) * QUANTITY;
            double df1       = ISSUER_RATES_PROVIDER.repoCurveDiscountFactors(SECURITY_ID, LEGAL_ENTITY, USD).discountFactor(SETTLEMENT_EARLY);
            double df2       = ISSUER_RATES_PROVIDER.repoCurveDiscountFactors(SECURITY_ID, LEGAL_ENTITY, USD).discountFactor(SETTLEMENT_STANDARD);
            double expected1 = netAmount.Amount * df1;
            double expected2 = -pvDiff + QUANTITY * df2 * PRICER.forecastValueStandardFromCleanPrice(RPRODUCT, RATES_PROVIDER, SETTLEMENT_STANDARD, TRADE_PRICE).Amount;

            assertEquals(computed.Amount, expected1 + expected2, NOTIONAL * QUANTITY * TOL);
        }
示例#2
0
        public virtual void test_presentValue_settle_after_val()
        {
            CurrencyAmount pvComputed = PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_AFTER_VAL, PROVIDER);
            CurrencyAmount pvExpected = PRICER_PRODUCT.presentValue(BILL_PRODUCT.resolve(REF_DATA), PROVIDER).multipliedBy(QUANTITY).plus(PRICER_PAYMENT.presentValue(BILL_TRADE_SETTLE_AFTER_VAL.Settlement.get(), PROVIDER.repoCurveDiscountFactors(BILL_PRODUCT.SecurityId, BILL_PRODUCT.LegalEntityId, BILL_PRODUCT.Currency).DiscountFactors));

            assertEquals(pvComputed.Currency, EUR);
            assertEquals(pvComputed.Amount, pvExpected.Amount, TOLERANCE_PV);
            MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(BILL_TRADE_SETTLE_AFTER_VAL, PROVIDER);

            assertEquals(ceComputed.Currencies.size(), 1);
            assertTrue(ceComputed.contains(EUR));
            assertEquals(ceComputed.getAmount(EUR).Amount, pvExpected.Amount, TOLERANCE_PV);
            CurrencyAmount cashComputed = PRICER_TRADE.currentCash(BILL_TRADE_SETTLE_AFTER_VAL, VAL_DATE);

            assertEquals(cashComputed.Currency, EUR);
            assertEquals(cashComputed.Amount, 0, TOLERANCE_PV);
        }
 //-------------------------------------------------------------------------
 // extracts the repo curve discount factors for the bond
 internal static RepoCurveDiscountFactors repoCurveDf(ResolvedBill bill, LegalEntityDiscountingProvider provider)
 {
     return(provider.repoCurveDiscountFactors(bill.SecurityId, bill.LegalEntityId, bill.Currency));
 }