Package com.opengamma.analytics.financial.interestrate

Examples of com.opengamma.analytics.financial.interestrate.PresentValueCalculator


    out.println(Arrays.deepToString(annuity.getPayments()));

    final YieldCurveBundle bundle = getBundle();

    final PresentValueCalculator presentValueCalculator = PresentValueCalculator.getInstance();
    final double presentValue = annuity.accept(presentValueCalculator, bundle);
    out.format("Present Value %f%n", presentValue);
  }
View Full Code Here


  public static void presentValueDemo(final PrintStream out) {
    final Cash loan = new Cash(ccy, 0.0, t, notional, r, t, yieldCurveName);
    final YieldCurveBundle bundle = getBundle();

    final PresentValueCalculator presentValueCalculator = PresentValueCalculator.getInstance();
    final double presentValue = loan.accept(presentValueCalculator, bundle);
    out.println(presentValue);
  }
View Full Code Here

   * @param curves The yield curves. Should contain the discounting and forward curves associated to the instrument.
   * @param price The quoted price.
   * @return The present value.
   */
  public double presentValueFromPrice(final InterestRateFutureOptionPremiumTransaction option, final YieldCurveBundle curves, final double price) {
    final PresentValueCalculator pvc = PresentValueCalculator.getInstance();
    final double premiumPV = option.getPremium().accept(pvc, curves);
    final double optionPV = price * option.getQuantity() * option.getUnderlyingOption().getUnderlyingFuture().getNotional()
        * option.getUnderlyingOption().getUnderlyingFuture().getPaymentAccrualFactor();
    return optionPV + premiumPV;
  }
View Full Code Here

    if (paymentToday.size() != 1) {
      throw new IllegalStateException("Expecting a single payment in the currency of the swap");
    }
    final YieldCurveBundle tomorrowData = CURVE_ROLLDOWN.rollDown(data, shiftTime);
    final Currency currency = paymentToday.getCurrencyAmounts()[0].getCurrency(); //TODO assuming that currencies are all the same
    final PresentValueCalculator pvCalculator = PresentValueCalculator.getInstance();
    final double result = instrumentTomorrow.accept(pvCalculator, tomorrowData) - instrumentToday.accept(pvCalculator, data) + paymentToday.getAmount(currency);
    return MultipleCurrencyAmount.of(CurrencyAmount.of(currency, result));
  }
View Full Code Here

    if (paymentToday.size() != 1) {
      throw new IllegalStateException("Expecting a single payment in the currency of the interest rate future");
    }
    final YieldCurveBundle tomorrowData = CURVE_ROLLDOWN.rollDown(data, shiftTime);
    final Currency currency = paymentToday.getCurrencyAmounts()[0].getCurrency(); //TODO assuming that currencies are all the same
    final PresentValueCalculator pvCalculator = PresentValueCalculator.getInstance();
    final double result = instrumentTomorrow.accept(pvCalculator, tomorrowData) - instrumentToday.accept(pvCalculator, data) + paymentToday.getAmount(currency);
    return MultipleCurrencyAmount.of(CurrencyAmount.of(currency, result));
  }
View Full Code Here

    final CouponCMSSABRReplicationMethod replication = CouponCMSSABRReplicationMethod.getInstance();
    final double priceCMS_method = replication.presentValue(CMS_COUPON_RECEIVER, sabrBundle).getAmount();
    assertEquals(priceCMS, priceCMS_method, 1.5); // Different precision in integration.
    final double priceCMS_calculator = CMS_COUPON_RECEIVER.accept(PVC, sabrBundle);
    assertEquals(priceCMS_method, priceCMS_calculator, 2E-1);// Different precision in integration.
    final PresentValueCalculator pvcNoConvexity = PresentValueCalculator.getInstance();
    final double priceCMS_noConvexity = CMS_COUPON_RECEIVER.accept(pvcNoConvexity, curves);// Price without convexity adjustment.
    assertEquals(priceCMS_calculator, priceCMS_noConvexity, 400.0);
    assertEquals(priceCMS_calculator > priceCMS_noConvexity, true);
  }
View Full Code Here

    final SABRInterestRateDataBundle sabrHaganBundle = new SABRInterestRateDataBundle(sabrParameterHagan, curves);
    final double priceHagan = CMS_COUPON_RECEIVER.accept(PVC, sabrHaganBundle);
    // From previous run
    assertEquals(8853.300, priceHagan, 1E-2);
    // No convexity adjustment
    final PresentValueCalculator pvcNoConvexity = PresentValueCalculator.getInstance();
    final double priceNoConvexity = CMS_COUPON_RECEIVER.accept(pvcNoConvexity, curves);
    assertEquals(priceHagan, priceNoConvexity, 400.0);
    // SABR Hagan alternative volatility function
    final SABRInterestRateParameters sabrParameterHaganAlt = TestsDataSetsSABR.createSABR1(new SABRHaganAlternativeVolatilityFunction());
    final SABRInterestRateDataBundle sabrHaganAltBundle = new SABRInterestRateDataBundle(sabrParameterHaganAlt, curves);
View Full Code Here

    final CurrencyAmount pv = METHOD.presentValue(COUPON, CURVES_BUNDLE);
    final CouponIborDefinition couponIborDefinition = new CouponIborDefinition(CUR, ACCRUAL_END_DATE, ACCRUAL_START_DATE, ACCRUAL_END_DATE, ACCRUAL_FACTOR, NOTIONAL, FIXING_DATE, INDEX, CALENDAR);
    final Payment couponIbor = couponIborDefinition.toDerivative(REFERENCE_DATE, CURVES_NAMES);
    final CouponFixedDefinition couponFixedDefinition = new CouponFixedDefinition(couponIborDefinition, SPREAD);
    final Payment couponFixed = couponFixedDefinition.toDerivative(REFERENCE_DATE, CURVES_NAMES);
    final PresentValueCalculator pvc = PresentValueCalculator.getInstance();
    final double pvIbor = couponIbor.accept(pvc, CURVES_BUNDLE);
    final double pvFixed = couponFixed.accept(pvc, CURVES_BUNDLE);
    assertEquals("Present value by discounting", pvIbor * FACTOR + pvFixed, pv.getAmount());
  }
View Full Code Here

    assertEquals("Bond future Discounting Method: present value currency", CUR, pvComputed.getCurrency());
    assertEquals("Bond future Discounting Method: present value amount", pvExpected, pvComputed.getAmount(), TOLERANCE_PV);
    final InstrumentDerivative derivative = BOND_FUTURE_DERIV;
    final CurrencyAmount pvComputed2 = METHOD.presentValue(derivative, CURVES);
    assertEquals("Bond future Discounting Method: present value", pvComputed, pvComputed2);
    final PresentValueCalculator calculator = PresentValueCalculator.getInstance();
    final double presentValueCalculator = BOND_FUTURE_DERIV.accept(calculator, CURVES);
    assertEquals("Bond future Discounting Method: present value from price", pvComputed.getAmount(), presentValueCalculator);
  }
View Full Code Here

  @Override
  protected Object getResult(final InstrumentDerivative derivative, final SABRInterestRateDataBundle data, final ValueRequirement desiredValue) {
    final Double cutoff = Double.parseDouble(desiredValue.getConstraint(SABRRightExtrapolationFunction.PROPERTY_CUTOFF_STRIKE));
    final Double mu = Double.parseDouble(desiredValue.getConstraint(SABRRightExtrapolationFunction.PROPERTY_TAIL_THICKNESS_PARAMETER));
    final PresentValueCalculator calculator = new PresentValueSABRExtrapolationCalculator(cutoff, mu);
    return derivative.accept(calculator, data);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.interestrate.PresentValueCalculator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.