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

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


    listForeign.add(new DoublesPair(payTime, rForeignBar));
    resultMap.put(multicurves.getName(optionForex.getCurrency1()), listForeign);
    final List<DoublesPair> listDomestic = new ArrayList<>();
    listDomestic.add(new DoublesPair(payTime, rDomesticBar));
    resultMap.put(multicurves.getName(optionForex.getCurrency2()), listDomestic);
    final MulticurveSensitivity result = MulticurveSensitivity.ofYieldDiscounting(resultMap);
    return MultipleCurrencyMulticurveSensitivity.of(optionForex.getUnderlyingOption().getUnderlyingForex().getCurrency2(), result);
  }
View Full Code Here


    final Map<String, List<DoublesPair>> pvsDF = new HashMap<>();
    pvsDF.put(multicurvesHW.getMulticurveProvider().getName(ccy), listDfSensi);
    final double dfPaymentBar = (a0 + a2 / 2) * cms.getNotional() * cms.getPaymentYearFraction() * pvBar;
    final DoublesPair dfPaymentSensi = new DoublesPair(payTimeCMS, -payTimeCMS * dfPayment * dfPaymentBar); // Sensi to dfPayment
    listDfSensi.add(dfPaymentSensi);
    MulticurveSensitivity sensitivity = MulticurveSensitivity.ofYieldDiscounting(pvsDF);
    sensitivity = sensitivity.cleaned();
    // Sensitivity from the CFE
    final Map<Double, MulticurveSensitivity> cfeCurveSensi = swap.accept(CFECSC, multicurvesHW.getMulticurveProvider());
    for (int loopcf = 0; loopcf < nbIbor; loopcf++) {
      final MulticurveSensitivity sensiCfe = cfeCurveSensi.get(cfeIbor.getNthPayment(loopcf).getPaymentTime());
      if (!(sensiCfe == null)) { // There is some sensitivity to that cfe. No sensi of the last cf.
        sensitivity = sensitivity.plus(sensiCfe.multipliedBy(cfeIborAmountBar[loopcf]));
      }
    }
    sensitivity = sensitivity.cleaned();
    return MultipleCurrencyMulticurveSensitivity.of(ccy, sensitivity);
  }
View Full Code Here

    // Backward sweep
    final double spreadBar = 1.0;
    final double dfEndBar = -pv2 / (notional1 * dfEnd * dfEnd) * spreadBar;
    final double pv2Bar = spreadBar / (notional1 * dfEnd);
    final MultipleCurrencyMulticurveSensitivity pv2DrMC = presentValueCurveSensitivity(fx, multicurves);
    final MulticurveSensitivity pv2Dr = pv2DrMC.converted(ccy2, multicurves.getFxRates()).getSensitivity(ccy2);
    final List<DoublesPair> list = new ArrayList<>();
    list.add(new DoublesPair(payTime, -payTime * dfEnd * dfEndBar));
    final Map<String, List<DoublesPair>> result = new HashMap<>();
    result.put(multicurves.getName(ccy2), list);
    final MulticurveSensitivity dfEndDr = MulticurveSensitivity.ofYieldDiscounting(result);
    return pv2Dr.multipliedBy(pv2Bar).plus(dfEndDr);
  }
View Full Code Here

      for (int loopimp = 0; loopimp < impactTime[loopjump].length; loopimp++) {
        listDiscounting.add(new DoublesPair(impactTime[loopjump][loopimp], -impactTime[loopjump][loopimp] * pDI[loopjump][loopimp] * pDIBar[loopjump][loopimp]));
      }
    }
    resultMap.put(multicurves.getName(ccy), listDiscounting);
    MulticurveSensitivity result = MulticurveSensitivity.ofYieldDiscounting(resultMap);
    // Adding sensitivity due to cash flow equivalent sensitivity to curves.
    for (int loopjump = 0; loopjump < nbJump; loopjump++) {
      final Map<Double, MulticurveSensitivity> impactAmountDerivative = decision.getImpactAmountDerivative().get(loopjump);
      for (int loopimp = 0; loopimp < impactTime[loopjump].length; loopimp++) {
        final MulticurveSensitivity sensiCfe = impactAmountDerivative.get(impactTime[loopjump][loopimp]);
        if (!(sensiCfe == null)) { // There is some sensitivity to that cfe.
          result = result.plus(sensiCfe.multipliedBy(impactAmountBar[loopjump][loopimp]));
        }
      }
    }
    result = result.cleaned();
    return MultipleCurrencyMulticurveSensitivity.of(ccy, result);
View Full Code Here

    listForeign.add(new DoublesPair(payTime, rForeignBar));
    resultMap.put(multicurves.getName(foreignCcy), listForeign);
    final List<DoublesPair> listDomestic = new ArrayList<>();
    listDomestic.add(new DoublesPair(payTime, rDomesticBar));
    resultMap.put(multicurves.getName(domesticCcy), listDomestic);
    final MulticurveSensitivity result = MulticurveSensitivity.ofYieldDiscounting(resultMap);
    return MultipleCurrencyMulticurveSensitivity.of(domesticCcy, result);
  }
View Full Code Here

    ArgumentChecker.notNull(sabr, "SABR cap provider");
    final MulticurveProviderInterface multicurve = sabr.getMulticurveProvider();
    final EuropeanVanillaOption option = new EuropeanVanillaOption(cap.getStrike(), cap.getFixingTime(), cap.isCap());
    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(sabr.getMulticurveProvider().getName(cap.getIndex()),
        new ForwardSensitivity(cap.getFixingPeriodStartTime(), cap.getFixingPeriodEndTime(), cap.getFixingAccrualFactor(), 1.0));
    final double dfDr = -cap.getPaymentTime() * df;
    final double maturity = cap.getFixingPeriodEndTime() - cap.getFixingPeriodStartTime();
    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);
    double bsPrice;
    double bsDforward;
    if (cap.getStrike() <= _cutOffStrike) { // No extrapolation
      final double[] volatilityAdjoint = sabr.getSABRParameter().getVolatilityAdjoint(cap.getFixingTime(), maturity, cap.getStrike(), forward);
      final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volatilityAdjoint[0]);
      final double[] bsAdjoint = BLACK_FUNCTION.getPriceAdjoint(option, dataBlack);
      bsPrice = bsAdjoint[0];
      bsDforward = df * (bsAdjoint[1] + bsAdjoint[2] * volatilityAdjoint[1]);
    } else { // With extrapolation
      final DoublesPair expiryMaturity = new DoublesPair(cap.getFixingTime(), maturity);
      final double alpha = sabr.getSABRParameter().getAlpha(expiryMaturity);
      final double beta = sabr.getSABRParameter().getBeta(expiryMaturity);
      final double rho = sabr.getSABRParameter().getRho(expiryMaturity);
      final double nu = sabr.getSABRParameter().getNu(expiryMaturity);
      final SABRFormulaData sabrParam = new SABRFormulaData(alpha, beta, rho, nu);
      final SABRExtrapolationRightFunction sabrExtrapolation = new SABRExtrapolationRightFunction(forward, sabrParam, _cutOffStrike, cap.getFixingTime(), _mu);
      bsPrice = sabrExtrapolation.price(option);
      bsDforward = sabrExtrapolation.priceDerivativeForward(option);
    }
    result = result.multipliedBy(bsPrice);
    result = result.plus(forwardDr.multipliedBy(bsDforward));
    result = result.multipliedBy(cap.getNotional() * cap.getPaymentYearFraction());
    return MultipleCurrencyMulticurveSensitivity.of(cap.getCurrency(), result);
  }
View Full Code Here

    // Backward sweep
    final double spreadBar = 1.0;
    final double dfEndBar = pv2 / (notional1 * dfEnd * dfEnd) * spreadBar;
    final double pv2Bar = -spreadBar / (notional1 * dfEnd);
    final MultipleCurrencyMulticurveSensitivity pv2DrMC = presentValueCurveSensitivity(fx, multicurves);
    final MulticurveSensitivity pv2Dr = pv2DrMC.converted(ccy2, multicurves.getFxRates()).getSensitivity(ccy2);
    final List<DoublesPair> list = new ArrayList<>();
    list.add(new DoublesPair(payTime, -payTime * dfEnd * dfEndBar));
    final Map<String, List<DoublesPair>> result = new HashMap<>();
    result.put(multicurves.getName(ccy2), list);
    final MulticurveSensitivity dfEndDr = MulticurveSensitivity.ofYieldDiscounting(result);
    return pv2Dr.multipliedBy(pv2Bar).plus(dfEndDr);
  }
View Full Code Here

    listNonDelivery.add(new DoublesPair(paymentTime, rNonDeliveryBar * Math.abs(optionForex.getUnderlyingNDF().getNotionalCurrency1())));
    resultMap.put(multicurves.getName(optionForex.getCurrency1()), listNonDelivery);
    final List<DoublesPair> listDelivery = new ArrayList<>();
    listDelivery.add(new DoublesPair(paymentTime, rDeliveryBar * Math.abs(optionForex.getUnderlyingNDF().getNotionalCurrency1())));
    resultMap.put(multicurves.getName(optionForex.getCurrency2()), listDelivery);
    final MulticurveSensitivity result = MulticurveSensitivity.ofYieldDiscounting(resultMap);
    return MultipleCurrencyMulticurveSensitivity.of(optionForex.getCurrency2(), 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

    listForeign.add(new DoublesPair(payTime, rForeignBar * factor));
    resultMap.put(multicurves.getName(optionForex.getCurrency1()), listForeign);
    final List<DoublesPair> listDomestic = new ArrayList<>();
    listDomestic.add(new DoublesPair(payTime, rDomesticBar * factor));
    resultMap.put(multicurves.getName(optionForex.getCurrency2()), listDomestic);
    final MulticurveSensitivity result = MulticurveSensitivity.ofYieldDiscounting(resultMap);
    return MultipleCurrencyMulticurveSensitivity.of(optionForex.getUnderlyingForex().getCurrency2(), 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.