public virtual void test_of_constant_interface() { IsdaCreditDiscountFactors test = (IsdaCreditDiscountFactors)CreditDiscountFactors.of(USD, VALUATION, CONST_CURVE); assertEquals(test.Currency, USD); assertEquals(test.Curve, CONST_CURVE); assertEquals(test.DayCount, ACT_365L); assertEquals(test.ParameterCount, 1); assertEquals(test.getParameter(0), RATE_SINGLE); assertEquals(test.ParameterKeys, DoubleArray.of(TIME_SINGLE)); assertEquals(test.getParameterMetadata(0), SimpleCurveParameterMetadata.of(METADATA.XValueType, TIME_SINGLE)); assertEquals(test.ValuationDate, VALUATION); assertEquals(test.findData(CONST_CURVE.Name), CONST_CURVE); assertEquals(test.findData(CurveName.of("Rubbish")), null); assertEquals(test.toDiscountFactors(), ZeroRateDiscountFactors.of(USD, VALUATION, CONST_CURVE)); assertEquals(test.IsdaCompliant, true); }
public virtual void test_of() { IsdaCreditDiscountFactors test = IsdaCreditDiscountFactors.of(USD, VALUATION, CURVE); assertEquals(test.Currency, USD); assertEquals(test.Curve, CURVE); assertEquals(test.DayCount, ACT_365F); assertEquals(test.ParameterCount, RATE.size()); assertEquals(test.getParameter(3), RATE.get(3)); assertEquals(test.getParameter(1), RATE.get(1)); assertEquals(test.ParameterKeys, TIME); assertEquals(test.getParameterMetadata(4), SimpleCurveParameterMetadata.of(METADATA.XValueType, TIME.get(4))); assertEquals(test.getParameterMetadata(6), SimpleCurveParameterMetadata.of(METADATA.XValueType, TIME.get(6))); assertEquals(test.ValuationDate, VALUATION); assertEquals(test.findData(CURVE.Name), CURVE); assertEquals(test.findData(CurveName.of("Rubbish")), null); assertEquals(test.toDiscountFactors(), ZeroRateDiscountFactors.of(USD, VALUATION, CURVE)); assertEquals(test.IsdaCompliant, true); }
//------------------------------------------------------------------------- public virtual void test_presentValue() { CurrencyAmount computed = PRICER.presentValue(TRADE, RATES_PROVIDER, PriceType.CLEAN, REF_DATA); CurrencyAmount expected = PRICER_PRODUCT.presentValue(PRODUCT, RATES_PROVIDER, VALUATION_DATE, PriceType.CLEAN, REF_DATA).plus(PRICER_PAYMENT.presentValue(UPFRONT, YIELD_CRVE.toDiscountFactors())); CurrencyAmount computedMf = PRICER_MF.presentValue(TRADE_NO_SETTLE_DATE, RATES_PROVIDER, PriceType.CLEAN, REF_DATA); CurrencyAmount expectedMf = PRICER_PRODUCT_MF.presentValue(PRODUCT, RATES_PROVIDER, VALUATION_DATE, PriceType.CLEAN, REF_DATA); assertEquals(computed.Amount, expected.Amount, TOL); assertEquals(computedMf.Amount, expectedMf.Amount, TOL); }