Package com.opengamma.analytics.financial.interestrate

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


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

    final ParRateCalculator parRateCalculator = ParRateCalculator.getInstance();
    final double parRate = loan.accept(parRateCalculator, bundle);
    out.println(parRate);
  }
View Full Code Here


   */
  //REVIEW emcleod This method does not belong in this class
  @Deprecated
  public InstrumentDerivative[] calibrationBasket(final RatchetIborCalibrationType type, final YieldCurveBundle curves) {
    final ArrayList<InstrumentDerivative> calibration = new ArrayList<>();
    final ParRateCalculator prc = ParRateCalculator.getInstance();
    switch (type) {
      case FORWARD_COUPON:
        final int nbCpn = getNumberOfPayments();
        final double[] cpnRate = new double[nbCpn];
        for (int loopcpn = 0; loopcpn < nbCpn; loopcpn++) {
          if (getNthPayment(loopcpn) instanceof CouponIborRatchet) {
            final CouponIborRatchet cpn = (CouponIborRatchet) getNthPayment(loopcpn);
            final double ibor = prc.visitCouponIborSpread(cpn, curves);
            final double cpnMain = cpn.getMainCoefficients()[0] * cpnRate[loopcpn - 1] + cpn.getMainCoefficients()[1] * ibor + cpn.getMainCoefficients()[2];
            final double cpnFloor = cpn.getFloorCoefficients()[0] * cpnRate[loopcpn - 1] + cpn.getFloorCoefficients()[1] * ibor + cpn.getFloorCoefficients()[2];
            final double cpnCap = cpn.getCapCoefficients()[0] * cpnRate[loopcpn - 1] + cpn.getCapCoefficients()[1] * ibor + cpn.getCapCoefficients()[2];
            cpnRate[loopcpn] = Math.min(Math.max(cpnFloor, cpnMain), cpnCap);
            calibration.add(new CapFloorIbor(cpn.getCurrency(), cpn.getPaymentTime(), cpn.getFundingCurveName(), cpn.getPaymentYearFraction(), cpn.getNotional(), cpn.getFixingTime(), cpn.getIndex(),
                cpn.getFixingPeriodStartTime(), cpn.getFixingPeriodEndTime(), cpn.getFixingAccrualFactor(), cpn.getForwardCurveName(), cpnRate[loopcpn], true));
          } else {
            if (getNthPayment(loopcpn) instanceof CouponFixed) {
              final CouponFixed cpn = (CouponFixed) getNthPayment(loopcpn);
              cpnRate[loopcpn] = cpn.getFixedRate();
            } else {
              final CouponIborGearing cpn = (CouponIborGearing) getNthPayment(loopcpn);
              final double ibor = prc.visitCouponIborGearing(cpn, curves);
              cpnRate[loopcpn] = cpn.getFactor() * ibor + cpn.getSpread();
            }
          }
        }
        break;
View Full Code Here

   * @return The coupon price.
   */
  public CurrencyAmount presentValue(final CouponCMS cmsCoupon, final YieldCurveBundle curves) {
    Validate.notNull(cmsCoupon);
    Validate.notNull(curves);
    final ParRateCalculator parRate = ParRateCalculator.getInstance();
    final double swapRate = parRate.visitFixedCouponSwap(cmsCoupon.getUnderlyingSwap(), curves);
    final YieldAndDiscountCurve fundingCurve = curves.getCurve(cmsCoupon.getFundingCurveName());
    final double paymentDiscountFactor = fundingCurve.getDiscountFactor(cmsCoupon.getPaymentTime());
    final double pv = swapRate * cmsCoupon.getPaymentYearFraction() * cmsCoupon.getNotional() * paymentDiscountFactor;
    return CurrencyAmount.of(cmsCoupon.getCurrency(), pv);
  }
View Full Code Here

   * @return The present value curve sensitivity.
   */
  public InterestRateCurveSensitivity presentValueSensitivity(final CouponCMS cmsCoupon, final YieldCurveBundle curves) {
    Validate.notNull(cmsCoupon);
    Validate.notNull(curves);
    final ParRateCalculator parRateCal = ParRateCalculator.getInstance();
    final double swapRate = parRateCal.visitFixedCouponSwap(cmsCoupon.getUnderlyingSwap(), curves);
    final String fundingCurveName = cmsCoupon.getFundingCurveName();
    final YieldAndDiscountCurve fundingCurve = curves.getCurve(fundingCurveName);
    final double paymentTime = cmsCoupon.getPaymentTime();
    final double paymentDiscountFactor = fundingCurve.getDiscountFactor(paymentTime);
    final ParRateCurveSensitivityCalculator parRateSensCal = ParRateCurveSensitivityCalculator.getInstance();
View Full Code Here

    final double discountFactorPayment = CURVES.getCurve(FUNDING_CURVE_NAME).getDiscountFactor(PAYMENT_TIME);
    final CouponCMSSABRReplicationMethod methodCms = CouponCMSSABRReplicationMethod.getInstance();
    final CapFloorCMSSABRReplicationMethod methodCmsCap = CapFloorCMSSABRReplicationMethod.getDefaultInstance();
    final NormalImpliedVolatilityFormula impliedVolatility = new NormalImpliedVolatilityFormula();
    final NormalPriceFunction normalPrice = new NormalPriceFunction();
    final ParRateCalculator parRate = ParRateCalculator.getInstance();
    final CouponCMS cmsCoupon1 = CouponCMS.from(CMS_CAP_SPREAD, SWAP_1, SETTLEMENT_TIME);
    final CouponCMS cmsCoupon2 = CouponCMS.from(CMS_CAP_SPREAD, SWAP_2, SETTLEMENT_TIME);
    final double cmsCoupon1Price = methodCms.presentValue(cmsCoupon1, SABR_BUNDLE).getAmount();
    final double cmsCoupon2Price = methodCms.presentValue(cmsCoupon2, SABR_BUNDLE).getAmount();
    final double expectedRate1 = cmsCoupon1Price / discountFactorPayment / cmsCoupon1.getNotional() / cmsCoupon1.getPaymentYearFraction();
View Full Code Here

   * Tests approximation error. "enabled = false" for the standard testing.
   */
  public void errorAnalysis() {
    final double bp1 = 10000;
    final double errorLimit = 5.0E-1; // 0.5 bp
    final ParRateCalculator prc = ParRateCalculator.getInstance();
    final double forward = SWAP_PAYER.accept(prc, CURVES);
    final double[] strikeRel = new double[] {-0.0250, -0.0150, -0.0050, 0.0, 0.0050, 0.0150, 0.0250 };
    final double[] pvPayerApproximation = new double[strikeRel.length];
    final double[] pvPayerIntegration = new double[strikeRel.length];
    final double[] pvReceiverApproximation = new double[strikeRel.length];
View Full Code Here

  /**
   * Test the rate computed from the method and from the calculator.
   */
  public void parRateMethodVsCalculator() {
    final double rateMethod = METHOD_FUT_SEC.parRate(ERU2_SEC, CURVES);
    final ParRateCalculator calculator = ParRateCalculator.getInstance();
    final double rateCalculator = ERU2_SEC.accept(calculator, CURVES);
    assertEquals("Future price from curves", rateMethod, rateCalculator, TOLERANCE_PRICE);
  }
View Full Code Here

TOP

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

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.