Package com.opengamma.analytics.financial.provider.description.interestrate

Examples of com.opengamma.analytics.financial.provider.description.interestrate.MulticurveProviderDiscount


  @BeforeSuite
  static void initClass() {
    CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.add(makeCurvesFromDefinitions(DEFINITIONS_UNITS[0], GENERATORS_UNITS[0], NAMES_UNITS[0], MULTICURVE_KNOWN_DATA, PSMQDC,
        PSMQCSDC, DSC_MAP, FWD_IBOR_MAP, FWD_ON_MAP, false)); // USD and EUR curves
    final MulticurveProviderDiscount knownCurves = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(0).getFirst().copy();
    knownCurves.removeCurve(EUR);
    CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.add(makeCurvesFromDefinitions(DEFINITIONS_UNITS[1], GENERATORS_UNITS[1], NAMES_UNITS[1], knownCurves, PSMQDC,
        PSMQCSDC, DSC_MAP_2, FWD_IBOR_MAP_2, FWD_ON_MAP_2, false)); // EUR with USD FF collateral dsc curve
  }
View Full Code Here


   * Create a yield curve bundle with three curves. One called "Discounting EUR" with a constant rate of 2.50%, one called "Discounting USD" with a constant rate of 1.00%
   * and one called "Discounting GBP" with a constant rate of 2.00%; "Discounting KRW" with a constant rate of 3.21%;
   * @return The yield curve bundle.
   */
  public static MulticurveProviderDiscount createMulticurvesForex() {
    final MulticurveProviderDiscount multicurves = new MulticurveProviderDiscount(FX_MATRIX);
    multicurves.setCurve(EUR, EUR_DSC);
    multicurves.setCurve(USD, USD_DSC);
    multicurves.setCurve(GBP, GBP_DSC);
    multicurves.setCurve(KRW, KRW_DSC);
    return multicurves;
  }
View Full Code Here

    return multicurves;
  }

  public static MulticurveProviderDiscount createMulticurvesEURUSD() {
    FXMatrix fxMatrix = new FXMatrix(USD, EUR, 1.0d / EUR_USD);
    final MulticurveProviderDiscount multicurves = new MulticurveProviderDiscount(fxMatrix);
    multicurves.setCurve(EUR, EUR_DSC);
    multicurves.setCurve(USD, USD_DSC);
    return multicurves;
  }
View Full Code Here

  public void currencyExposure() {
    final MultipleCurrencyAmount ce = METHOD_BARRIER.currencyExposure(OPTION_BARRIER, SMILE_FLAT_MULTICURVES);
    final double shiftSpotEURUSD = 1E-6;
    final MultipleCurrencyAmount pv = METHOD_BARRIER.presentValue(OPTION_BARRIER, SMILE_FLAT_MULTICURVES);
    final FXMatrix fxMatrixShift = new FXMatrix(EUR, USD, SPOT + shiftSpotEURUSD);
    final MulticurveProviderDiscount multicurvesShiftedFX = MULTICURVES.copy();
    multicurvesShiftedFX.setForexMatrix(fxMatrixShift);
    final BlackForexSmileProviderDiscount smileBumpedSpot = new BlackForexSmileProviderDiscount(multicurvesShiftedFX, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final MultipleCurrencyAmount pvBumpedSpot = METHOD_BARRIER.presentValue(OPTION_BARRIER, smileBumpedSpot);
    final double ceDomesticFD = (pvBumpedSpot.getAmount(USD) - pv.getAmount(USD));
    assertEquals("Barrier currency exposure: domestic currency", ceDomesticFD, ce.getAmount(EUR) * shiftSpotEURUSD, 2.0E-4);
    final double spotGBPUSD = 1.60;
View Full Code Here

  /**
   * Reports the error of the arithmetic average approximation by the log of the compounded rate.
   */
  public void averageApproximation() {

    final MulticurveProviderDiscount multicurvesCst = new MulticurveProviderDiscount();
    YieldAndDiscountCurve curveCst = YieldCurve.from(ConstantDoublesCurve.from(0.0, "CST"));
    multicurvesCst.setCurve(FEDFUND, curveCst);

    final double[] rateLevel = {0.01, 0.05, 0.10 };
    final int nbLevel = rateLevel.length;
    final int nbStart = 36;
    final Period step = Period.ofMonths(1);
    final ZonedDateTime[] effectiveDate = new ZonedDateTime[nbStart];
    effectiveDate[0] = ScheduleCalculator.getAdjustedDate(REFERENCE_DATE, GENERATOR_SWAP_EONIA.getSpotLag(), NYC);

    final double[][] payComp = new double[nbLevel][nbStart];
    final double[][] payAA = new double[nbLevel][nbStart];
    final double[][] payAAApprox = new double[nbLevel][nbStart];
    final double[][] rateComp = new double[nbLevel][nbStart];
    final double[][] rateAA = new double[nbLevel][nbStart];
    final double[][] rateAAApprox = new double[nbLevel][nbStart];

    for (int looplevel = 0; looplevel < nbLevel; looplevel++) {
      curveCst = YieldCurve.from(ConstantDoublesCurve.from(rateLevel[looplevel], "CST"));
      multicurvesCst.replaceCurve(FEDFUND, curveCst);

      for (int loopstart = 0; loopstart < nbStart; loopstart++) {
        effectiveDate[loopstart] = ScheduleCalculator.getAdjustedDate(effectiveDate[0], step.multipliedBy(loopstart), USDLIBOR3M, NYC);
        final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(effectiveDate[loopstart], TENOR_3M, USDLIBOR3M, NYC);
        final CouponArithmeticAverageONDefinition cpnONDefinition = CouponArithmeticAverageONDefinition.from(FEDFUND, effectiveDate[loopstart], endDate, NOTIONAL, 0, NYC);
        final CouponArithmeticAverageON cpnON = cpnONDefinition.toDerivative(REFERENCE_DATE);
        // Compute daily forwards
        final int nbON = cpnON.getFixingPeriodAccrualFactors().length;
        final double fwdON[] = new double[nbON];
        for (int loopon = 0; loopon < nbON; loopon++) {
          fwdON[loopon] = multicurvesCst.getForwardRate(FEDFUND, cpnON.getFixingPeriodTimes()[loopon], cpnON.getFixingPeriodTimes()[loopon + 1], cpnON.getFixingPeriodAccrualFactors()[loopon]);
        }
        // Compounded period forward
        payComp[looplevel][loopstart] = multicurvesCst.getForwardRate(FEDFUND, cpnON.getFixingPeriodTimes()[0], cpnON.getFixingPeriodTimes()[nbON], cpnON.getFixingPeriodRemainingAccrualFactor())
            * cpnON.getFixingPeriodRemainingAccrualFactor();
        payAA[looplevel][loopstart] = 0;
        for (int loopon = 0; loopon < nbON; loopon++) {
          payAA[looplevel][loopstart] += fwdON[loopon] * cpnON.getFixingPeriodAccrualFactors()[loopon];
        }
View Full Code Here

  /**
   * Tests the currency exposure with a FD rate shift.
   */
  public void currencyExposureForeign2() {
    final double shift = 0.000005;
    final MulticurveProviderDiscount multicurveP = MULTICURVES.copy();
    final FXMatrix fxMatrixP = new FXMatrix(EUR, USD, SPOT + shift);
    multicurveP.setForexMatrix(fxMatrixP);
    final BlackForexSmileProviderDiscount smileP = new BlackForexSmileProviderDiscount(multicurveP, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final MultipleCurrencyAmount ce = METHOD_BLACK_DIGITAL.currencyExposure(FOREX_DIGITAL_CALL_FOR, SMILE_FLAT_MULTICURVES);
    final MultipleCurrencyAmount pv = METHOD_BLACK_DIGITAL.presentValue(FOREX_DIGITAL_CALL_FOR, SMILE_FLAT_MULTICURVES);
    final MultipleCurrencyAmount pvP = METHOD_BLACK_DIGITAL.presentValue(FOREX_DIGITAL_CALL_FOR, smileP);
    assertEquals("Forex Digital option: call spread method - currency exposure - PL EUR", pvP.getAmount(EUR) - pv.getAmount(EUR), ce.getAmount(USD)
View Full Code Here

    final CouponFixed cpnExpected = new CouponFixed(EUR_CUR, paymentTime, EUR_PAYMENT_YEAR_FRACTION, NOTIONAL, (notionalIncreased / NOTIONAL - 1.0) / EUR_PAYMENT_YEAR_FRACTION);
    assertEquals("CouponOISSimplified definition: toDerivative", cpnExpected, cpnConverted);

    // Test pricing, too. Notice that the value of a coupon on its payment date is non-zero
    final MulticurveProviderDiscount curves = MulticurveProviderDiscountDataSets.createMulticurveEurUsd();
    final MultipleCurrencyAmount pvConverted = com.opengamma.analytics.financial.interestrate.payments.provider.CouponFixedDiscountingMethod.getInstance().presentValue((CouponFixed) cpnConverted,
        curves);
    final MultipleCurrencyAmount pvExpected = com.opengamma.analytics.financial.interestrate.payments.provider.CouponFixedDiscountingMethod.getInstance().presentValue(cpnExpected, curves);
    assertEquals("CouponOIS definition: toDerivative", pvConverted, pvExpected);
    assertEquals("CouponOIS definition: toDerivative", pvConverted, MultipleCurrencyAmount.of(EUR_CUR, 19445.833380471457));
View Full Code Here

        final String valueName = input.getSpecification().getValueName();
        if (CURVE_BUNDLE.equals(valueName)) {
          providers.add((MulticurveProviderDiscount) input.getValue());
        }
      }
      final MulticurveProviderDiscount result = ProviderUtils.mergeDiscountingProviders(providers);
      return ProviderUtils.mergeDiscountingProviders(result, matrix);
    }
View Full Code Here

      final InterpolatedDoublesSurface betaSurface = surfaces.getBetaSurface();
      final InterpolatedDoublesSurface nuSurface = surfaces.getNuSurface();
      final InterpolatedDoublesSurface rhoSurface = surfaces.getRhoSurface();
      final SABRInterestRateParameters modelParameters = new SABRInterestRateParameters(alphaSurface, betaSurface, rhoSurface, nuSurface, dayCount,
          VolatilityFunctionFactory.HAGAN_FORMULA);
      final MulticurveProviderDiscount curves = getMergedProviders(inputs, fxMatrix);
      final GeneratorInstrument<GeneratorAttributeIR> generatorSwap = SwaptionUtils.getSwapGenerator(security, definition, securitySource);
      if (!(generatorSwap instanceof GeneratorSwapFixedIbor)) {
        throw new OpenGammaRuntimeException("Cannot handle swap generators of type " + generatorSwap.getClass());
      }
      return new SABRSwaptionProviderDiscount(curves, modelParameters, (GeneratorSwapFixedIbor) generatorSwap);
View Full Code Here

        throw new OpenGammaRuntimeException("Could not get the currency for this set of Hull-White one factor parameters");
      }
      final FXMatrix fxMatrix = (FXMatrix) inputs.getValue(ValueRequirementNames.FX_MATRIX);
      HullWhiteOneFactorProviderDiscount knownData;
      if (getExogenousRequirements().isEmpty()) {
        knownData = new HullWhiteOneFactorProviderDiscount(new MulticurveProviderDiscount(fxMatrix), modelParameters, currency);
      } else {
        final Object curveBundle = inputs.getValue(ValueRequirementNames.CURVE_BUNDLE);
        if (curveBundle instanceof MulticurveProviderDiscount) {
          knownData = new HullWhiteOneFactorProviderDiscount((MulticurveProviderDiscount) curveBundle, modelParameters, currency);
        }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.provider.description.interestrate.MulticurveProviderDiscount

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.