Package com.opengamma.analytics.financial.provider.sensitivity.multicurve

Examples of com.opengamma.analytics.financial.provider.sensitivity.multicurve.MulticurveSensitivity


    // Backward sweep
    final double priceBar = 1.0;
    final double volatilityBar = priceAdjoint[2] * priceBar;
    final double forwardBar = priceAdjoint[1] * priceBar + volatilityAdjoint[1] * volatilityBar;
    final double priceFutureBar = -forwardBar;
    final MulticurveSensitivity priceFutureDerivative = METHOD_FUTURE.priceCurveSensitivity(security.getUnderlyingFuture(), sabrData.getMulticurveProvider());
    return priceFutureDerivative.multipliedBy(priceFutureBar);
  }
View Full Code Here


    final Currency ccy = coupon.getCurrency();
    final double swapRate = PRDC.visitFixedCouponSwap(coupon.getUnderlyingSwap(), multicurves);
    final double paymentTime = coupon.getPaymentTime();
    final double paymentDiscountFactor = multicurves.getDiscountFactor(coupon.getCurrency(), paymentTime);
    final double paymentDiscountFactorBar = swapRate * coupon.getPaymentYearFraction() * coupon.getNotional();
    final MulticurveSensitivity swapRateDp = coupon.getUnderlyingSwap().accept(PRCSDC, multicurves);
    final List<DoublesPair> list = new ArrayList<>();
    list.add(new DoublesPair(paymentTime, -paymentTime * paymentDiscountFactor * paymentDiscountFactorBar));
    final Map<String, List<DoublesPair>> resultMapDsc = new HashMap<>();
    resultMapDsc.put(multicurves.getName(coupon.getCurrency()), list);
    final MulticurveSensitivity dfDp = MulticurveSensitivity.ofYieldDiscounting(resultMapDsc);
    return MultipleCurrencyMulticurveSensitivity.of(
        ccy,
        swapRateDp.multipliedBy(coupon.getPaymentYearFraction() * coupon.getNotional() * paymentDiscountFactor).plus(
            dfDp.multipliedBy(swapRate * coupon.getPaymentYearFraction() * coupon.getNotional())));
  }
View Full Code Here

    final Currency ccy = swap.getSecondLeg().getCurrency();
    final double pvSecond = swap.getSecondLeg().accept(PVDC, multicurves).getAmount(ccy) * Math.signum(swap.getSecondLeg().getNthPayment(0).getNotional());
    final double pvbp = METHOD_SWAP.presentValueBasisPoint(swap, multicurves);
    final double pvbpBar = -pvSecond / (pvbp * pvbp);
    final double pvSecondBar = 1.0 / pvbp;
    final MulticurveSensitivity pvbpDr = METHOD_SWAP.presentValueBasisPointCurveSensitivity(swap, multicurves);
    final MulticurveSensitivity pvSecondDr = swap.getSecondLeg().accept(PVCSDC, multicurves).getSensitivity(ccy).multipliedBy(Math.signum(swap.getSecondLeg().getNthPayment(0).getNotional()));
    final MulticurveSensitivity result = pvSecondDr.multipliedBy(pvSecondBar).plus(pvbpDr.multipliedBy(pvbpBar));
    return result;
  }
View Full Code Here

    final Currency ccy = swap.getSecondLeg().getCurrency();
    final double pvSecond = swap.getSecondLeg().accept(PVDC, multicurves).getAmount(ccy) * Math.signum(swap.getSecondLeg().getNthPayment(0).getNotional());
    final double pvbp = METHOD_SWAP.presentValueBasisPoint(swap, dayCount, multicurves);
    final double pvbpBar = -pvSecond / (pvbp * pvbp);
    final double pvSecondBar = 1.0 / pvbp;
    final MulticurveSensitivity pvbpDr = METHOD_SWAP.presentValueBasisPointCurveSensitivity(swap, dayCount, multicurves);
    final MulticurveSensitivity pvSecondDr = swap.getSecondLeg().accept(PVCSDC, multicurves).getSensitivity(ccy).multipliedBy(Math.signum(swap.getSecondLeg().getNthPayment(0).getNotional()));
    final MulticurveSensitivity result = pvSecondDr.multipliedBy(pvSecondBar).plus(pvbpDr.multipliedBy(pvbpBar));
    return result;
  }
View Full Code Here

    final double pvSecond = swap.getSecondLeg().accept(PVDC, multicurves).getAmount(ccy) * Math.signum(swap.getSecondLeg().getNthPayment(0).getNotional());
    final double pvbp = METHOD_SWAP.presentValueBasisPoint(swap, dayCount, multicurves);
    final double pvCoeff = 1. / pvbp;
    final double crossCoeff = -1.0 / pvbp / pvbp;
    final double pvbpCoeff = 2.0 * pvSecond / pvbp / pvbp;
    final MulticurveSensitivity pvbpDr = METHOD_SWAP.presentValueBasisPointCurveSensitivity(swap, dayCount, multicurves);
    final MulticurveSensitivity pvSecondDr = swap.getSecondLeg().accept(PVCSDC, multicurves).getSensitivity(ccy)
        .multipliedBy(Math.signum(swap.getSecondLeg().getNthPayment(0).getNotional()));
    final MulticurveSensitivity pvbpDr2 = METHOD_SWAP.presentValueBasisPointSecondOrderCurveSensitivity(swap, dayCount, multicurves);

    final int len = swap.getSecondLeg().getNumberOfPayments();
    CouponIbor couponInitial = (CouponIbor) swap.getSecondLeg().getPayments()[0];
    MulticurveSensitivity pvSecondDr2 = CouponIborDiscountingMethod.getInstance().presentValueSecondOrderCurveSensitivity(couponInitial, multicurves).getSensitivity(ccy);
    for (int i = 1; i < len; ++i) {
      CouponIbor coupon = (CouponIbor) swap.getSecondLeg().getPayments()[i];
      pvSecondDr2.plus(CouponIborDiscountingMethod.getInstance().presentValueSecondOrderCurveSensitivity(coupon, multicurves).getSensitivity(ccy));
    }

    final MulticurveSensitivity result = pvSecondDr2.multipliedBy(pvCoeff).plus(pvbpDr2.multipliedBy(pvbpCoeff)).plus(pvSecondDr.productOf(pvbpDr.multipliedBy(crossCoeff)))
        .multipliedBy(Math.signum(swap.getSecondLeg().getNthPayment(0).getNotional()));
    return result;
  }
View Full Code Here

    final double sensiDF = -cmsCapFloor.getPaymentTime() * discountFactor * deltaPD;
    final List<DoublesPair> list = new ArrayList<>();
    list.add(new DoublesPair(cmsCapFloor.getPaymentTime(), sensiDF));
    final Map<String, List<DoublesPair>> resultMapDsc = new HashMap<>();
    resultMapDsc.put(sabrData.getMulticurveProvider().getName(ccy), list);
    final MulticurveSensitivity dscDp = MulticurveSensitivity.ofYieldDiscounting(resultMapDsc);
    final MulticurveSensitivity forwardDp = cmsCapFloor.getUnderlyingSwap().accept(PRCSDC, sabrData.getMulticurveProvider());
    return MultipleCurrencyMulticurveSensitivity.of(ccy, dscDp.plus(forwardDp.multipliedBy(deltaS0)));
  }
View Full Code Here

    final MultipleCurrencyMulticurveSensitivity pvss = annuity.accept(_pvSensitivityCalculator, curves);
    final Set<Currency> currencies = pvss.getCurrencies();
    if (currencies.size() != 1) {
      throw new IllegalStateException("Had more than one currency in result: " + pvss.getCurrencies());
    }
    final MulticurveSensitivity sensitivities = pvss.getSensitivity(Iterables.getOnlyElement(currencies));
    if (Double.doubleToLongBits(zSpread) == 0) {
      return sensitivities.getYieldDiscountingSensitivities();
    }
    final Map<String, List<DoublesPair>> result = new HashMap<>();
    for (final Map.Entry<String, List<DoublesPair>> entry : sensitivities.getYieldDiscountingSensitivities().entrySet()) {
      final List<DoublesPair> unadjusted = entry.getValue();
      final ArrayList<DoublesPair> adjusted = new ArrayList<>(unadjusted.size());
      for (final DoublesPair pair : unadjusted) {
        final DoublesPair newPair = new DoublesPair(pair.first, pair.second * Math.exp(-zSpread * pair.first));
        adjusted.add(newPair);
View Full Code Here

    final MultipleCurrencyMulticurveSensitivity pvss = annuity.accept(_pvSensitivityCalculator, curves);
    final Set<Currency> currencies = pvss.getCurrencies();
    if (currencies.size() != 1) {
      throw new IllegalStateException("Had more than one currency in result: " + pvss.getCurrencies());
    }
    final MulticurveSensitivity sensitivities = pvss.getSensitivity(Iterables.getOnlyElement(currencies));
    if (Double.doubleToLongBits(zSpread) == 0) {
      return sensitivities.getYieldDiscountingSensitivities();
    }
    final Map<String, List<DoublesPair>> result = new HashMap<>();
    for (final Map.Entry<String, List<DoublesPair>> entry : sensitivities.getYieldDiscountingSensitivities().entrySet()) {
      final List<DoublesPair> unadjusted = entry.getValue();
      final ArrayList<DoublesPair> adjusted = new ArrayList<>(unadjusted.size());
      for (final DoublesPair pair : unadjusted) {
        final DoublesPair newPair = new DoublesPair(pair.first, -pair.second * Math.exp(-zSpread * pair.first) / dPricedZ);
        adjusted.add(newPair);
View Full Code Here

   */
  public SimpleParameterSensitivity calculateSensitivity(final InstrumentDerivative instrument, final DATA_TYPE parameterMulticurves, final Set<String> curvesSet) {
    ArgumentChecker.notNull(instrument, "derivative");
    ArgumentChecker.notNull(parameterMulticurves, "Black data");
    ArgumentChecker.notNull(curvesSet, "curves");
    MulticurveSensitivity sensitivity = instrument.accept(_curveSensitivityCalculator, parameterMulticurves);
    sensitivity = sensitivity.cleaned(); // TODO: for testing purposes mainly. Could be removed after the tests.
    return pointToParameterSensitivity(sensitivity, parameterMulticurves, curvesSet);
  }
View Full Code Here

    ArgumentChecker.notNull(cap, "The cap/floor shoud not be null");
    ArgumentChecker.notNull(black, "Black provider");
    final MulticurveProviderInterface multicurve = black.getMulticurveProvider();
    final double forward = multicurve.getForwardRate(cap.getIndex(), cap.getFixingPeriodStartTime(), cap.getFixingPeriodEndTime(), cap.getFixingAccrualFactor());
    final double df = multicurve.getDiscountFactor(cap.getCurrency(), cap.getPaymentTime());
    final MulticurveSensitivity forwardDr = MulticurveSensitivity.ofForward(multicurve.getName(cap.getIndex()),
        new ForwardSensitivity(cap.getFixingPeriodStartTime(), cap.getFixingPeriodEndTime(), cap.getFixingAccrualFactor(), 1.0));
    final double dfDr = -cap.getPaymentTime() * df;
    final double volatility = black.getBlackShiftParameters().getVolatility(cap.getFixingTime(), cap.getStrike());
    final double shift = black.getBlackShiftParameters().getShift(cap.getFixingTime());
    final EuropeanVanillaOption option = new EuropeanVanillaOption(cap.getStrike() + shift, cap.getFixingTime(), cap.isCap());
    final BlackFunctionData dataBlack = new BlackFunctionData(forward + shift, 1.0, volatility);
    final double[] bsAdjoint = BLACK_FUNCTION.getPriceAdjoint(option, dataBlack);
    final List<DoublesPair> list = new ArrayList<>();
    list.add(new DoublesPair(cap.getPaymentTime(), dfDr));
    final Map<String, List<DoublesPair>> resultMap = new HashMap<>();
    resultMap.put(multicurve.getName(cap.getCurrency()), list);
    MulticurveSensitivity result = MulticurveSensitivity.ofYieldDiscounting(resultMap);
    result = result.multipliedBy(bsAdjoint[0]);
    result = result.plus(forwardDr.multipliedBy(df * bsAdjoint[1]));
    result = result.multipliedBy(cap.getNotional() * cap.getPaymentYearFraction());
    return MultipleCurrencyMulticurveSensitivity.of(cap.getCurrency(), result);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.provider.sensitivity.multicurve.MulticurveSensitivity

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.