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

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


    final double zSpread = CALCULATOR.calculateZSpread(PAYMENTS, MULTI_CURVES, price);
    final double[] rSpread = new double[R1.length];
    for (int i = 0; i < rSpread.length; i++) {
      rSpread[i] = R1[i] + zSpread;
    }
    final MulticurveProviderDiscount multicurves = new MulticurveProviderDiscount(MULTI_CURVES.copy());
    multicurves.replaceCurve(Currency.EUR, YieldCurve.from(InterpolatedDoublesCurve.from(T, rSpread, INTERPOLATOR)));
    assertEquals(price, PAYMENTS.accept(PV_CALCULATOR, multicurves).getAmount(Currency.EUR), 1e-15);
    assertEquals(price, CALCULATOR.calculatePriceForZSpread(PAYMENTS, MULTI_CURVES, zSpread), 1e-15);
  }
View Full Code Here


    final double eps = 1e-3;
    final double[] rSpread = new double[R1.length];
    for (int i = 0; i < rSpread.length; i++) {
      rSpread[i] = R1[i] + zSpread + eps;
    }
    final MulticurveProviderDiscount multicurves = new MulticurveProviderDiscount(MULTI_CURVES.copy());
    multicurves.replaceCurve(Currency.EUR, YieldCurve.from(InterpolatedDoublesCurve.from(T, rSpread, INTERPOLATOR)));
    final double newPrice = PAYMENTS.accept(PV_CALCULATOR, multicurves).getAmount(Currency.EUR);
    assertEquals((newPrice - price) / eps, CALCULATOR.calculatePriceSensitivityToZSpread(PAYMENTS, MULTI_CURVES, zSpread), eps);
  }
View Full Code Here

   * @param dsc The discounting curve level.
   * @param fwd The forward curve level.
   * @return
   */
  public static MulticurveProviderDiscount curves1(final double dsc, final double fwd, final Currency ccy, final IborIndex index) {
    final MulticurveProviderDiscount curves = new MulticurveProviderDiscount();
    curves.setCurve(ccy, YieldCurve.from(ConstantDoublesCurve.from(dsc)));
    curves.setCurve(index, YieldCurve.from(ConstantDoublesCurve.from(fwd)));
    return curves;
  }
View Full Code Here

    curves.setCurve(index, YieldCurve.from(ConstantDoublesCurve.from(fwd)));
    return curves;
  }

  public static MulticurveProviderDiscount curves2(final double dsc, final double fwd, final Currency ccy, final IborIndex index) {
    final MulticurveProviderDiscount curves = new MulticurveProviderDiscount();
    final double[] dscArray = new double[RATES_TIME.length];
    final double[] fwdArray = new double[RATES_TIME.length];
    for (int loopt = 0; loopt < RATES_TIME.length; loopt++) {
      dscArray[loopt] = dsc;
      fwdArray[loopt] = fwd;
    }
    curves.setCurve(ccy, YieldCurve.from(new InterpolatedDoublesCurve(RATES_TIME, dscArray, LINEAR_FLAT, true)));
    curves.setCurve(index, YieldCurve.from(new InterpolatedDoublesCurve(RATES_TIME, fwdArray, LINEAR_FLAT, true)));
    return curves;
  }
View Full Code Here

  public static MulticurveProviderDiscount createCurvesForex() {
    final YieldAndDiscountCurve CURVE_EUR = EUR_DSC; // YieldCurve.from(ConstantDoublesCurve.from(0.0250));
    final YieldAndDiscountCurve CURVE_USD = USD_DSC; // YieldCurve.from(ConstantDoublesCurve.from(0.0100));
    final YieldAndDiscountCurve CURVE_GBP = GBP_DSC; // YieldCurve.from(ConstantDoublesCurve.from(0.0200));
    final YieldAndDiscountCurve CURVE_KRW = KRW_DSC; // YieldCurve.from(ConstantDoublesCurve.from(0.0321));
    final MulticurveProviderDiscount curves = new MulticurveProviderDiscount(FX_MATRIX);
    curves.setCurve(Currency.EUR, CURVE_EUR);
    curves.setCurve(Currency.USD, CURVE_USD);
    curves.setCurve(Currency.GBP, CURVE_GBP);
    curves.setCurve(Currency.of("KRW"), CURVE_KRW);
    return curves;
  }
View Full Code Here

  public static MulticurveProviderDiscount createCurvesForex(final Currency ccy1, final Currency ccy2, final double exchangeRate) {
    final YieldAndDiscountCurve curve1 = YieldCurve.from(ConstantDoublesCurve.from(0.0100));
    final YieldAndDiscountCurve curve2 = YieldCurve.from(ConstantDoublesCurve.from(0.0200));
    final FXMatrix fxMatrix = new FXMatrix(ccy1, ccy2, exchangeRate);
    final MulticurveProviderDiscount curves = new MulticurveProviderDiscount(fxMatrix);
    curves.setCurve(ccy1, curve1);
    curves.setCurve(ccy2, curve2);
    return curves;
  }
View Full Code Here

  public static MulticurveProviderDiscount createCurvesForex2() {
    final YieldAndDiscountCurve CURVE_EUR = YieldCurve.from(ConstantDoublesCurve.from(0.0250));
    final YieldAndDiscountCurve CURVE_USD = YieldCurve.from(ConstantDoublesCurve.from(0.0100));
    final YieldAndDiscountCurve CURVE_GBP = YieldCurve.from(ConstantDoublesCurve.from(0.0200));
    final YieldAndDiscountCurve CURVE_KRW = YieldCurve.from(ConstantDoublesCurve.from(0.0321));
    final MulticurveProviderDiscount curves = new MulticurveProviderDiscount(FX_MATRIX);
    curves.setCurve(Currency.EUR, CURVE_EUR);
    curves.setCurve(Currency.USD, CURVE_USD);
    curves.setCurve(Currency.GBP, CURVE_GBP);
    curves.setCurve(Currency.of("KRW"), CURVE_KRW);
    return curves;
  }
View Full Code Here

  @Test(enabled = true)
  /**
   * Analyzes incoherence between curve inerpolation and forward points interpolation.
   */
  public void forwardPointsInterpolation() {
    final MulticurveProviderDiscount multicurves = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(0).getFirst();
    // FX swap description
    final double notionalEUR = 1E8; //100m
    final double fxEURUSDFwdInit = FX_EURUSD + 0.0010; // Should have no impact
    final Period startTenor = Period.ofMonths(0);
    final Period endTenor = Period.ofMonths(12);
    final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(NOW, USDLIBOR3M.getSpotLag(), TARGET);
    final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spot, startTenor, USDLIBOR3M, NYC);
    final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(spot, endTenor, USDLIBOR3M, NYC);
    final double[] points = DSC_EUR_MARKET_QUOTES;
    final double[] time = ((InterpolatedDoublesCurve) ((YieldCurve) multicurves.getCurve(EUR)).getCurve()).getXDataAsPrimitive();
    final InterpolatedDoublesCurve pointsCurve = new InterpolatedDoublesCurve(time, points, INTERPOLATOR_LINEAR, true, "Points curve");
    ZonedDateTime loopdate = startDate;
    final List<Double> pvUSDCurve = new ArrayList<>();
    final List<Double> pvUSDPts = new ArrayList<>();
    final List<Double> pvUSDDiff = new ArrayList<>();
    final List<Double> ptsCurve = new ArrayList<>();
    final List<Double> ptsInt = new ArrayList<>();
    final List<Double> ptsDiff = new ArrayList<>();
    final List<Double> payTime = new ArrayList<>();
    while (!loopdate.isAfter(endDate)) {
      final ForexDefinition fxSwapDefinition = new ForexDefinition(EUR, USD, loopdate, notionalEUR, fxEURUSDFwdInit);
      final Forex fxSwap = fxSwapDefinition.toDerivative(NOW);
      final MultipleCurrencyAmount pvFxSwap = fxSwap.accept(PVDC, multicurves);
      final double pvUSDCurved = FX_MATRIX.convert(pvFxSwap, USD).getAmount();
      pvUSDCurve.add(pvUSDCurved);
      final double pvUSDPtsd = -(fxEURUSDFwdInit - FX_EURUSD - pointsCurve.getYValue(fxSwap.getPaymentTime()))
          * multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
      pvUSDPts.add(pvUSDPtsd);
      pvUSDDiff.add(pvUSDCurved - pvUSDPtsd);
      //      double testUSDI = (fxEURUSDFwdInit)
      //          * multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
      //      double testUSDC = (FX_EURUSD + pointsCurve.getYValue(fxSwap.getPaymentTime()))
      //          * multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) * notionalEUR;
      //      double testEURUSD = pvFxSwap.getAmount(EUR) * FX_EURUSD;
      final double ptC = (multicurves.getDiscountFactor(EUR, fxSwap.getPaymentTime()) / multicurves.getDiscountFactor(USD, fxSwap.getPaymentTime()) - 1) * FX_EURUSD;
      ptsCurve.add(ptC);
      ptsInt.add(pointsCurve.getYValue(fxSwap.getPaymentTime()));
      ptsDiff.add((ptC - pointsCurve.getYValue(fxSwap.getPaymentTime())) * 10000);
      payTime.add(fxSwap.getPaymentTime());
      loopdate = ScheduleCalculator.getAdjustedDate(loopdate, 1, TARGET);
View Full Code Here

   * Analyzes the shape of the forward curve.
   */
  public void marketQuoteSensitivityAnalysis() {
    // Create a 3 currencies provider
    final int indexEur = 4;
    final MulticurveProviderDiscount multicurves7 = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(indexEur).getFirst();
    multicurves7.setAll(CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(1).getFirst());
    final CurveBuildingBlockBundle blocks7 = CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(indexEur).getSecond();
    blocks7.addAll(CURVES_PAR_SPREAD_MQ_WITHOUT_TODAY_BLOCK.get(1).getSecond());
    final double spreadJPYEUR = 0.0010; // 10bps
    final GeneratorAttributeFX attr6Mx5Y = new GeneratorAttributeFX(Period.ofMonths(6), Period.ofYears(5), FX_MATRIX); //TODO Check dates swap
    final double notional = 100000;
View Full Code Here

    final CouponFixed cpnExpected = new CouponFixed(Currency.USD, paymentTime, ACCURAL_FACTOR_7D, NOTIONAL, rateAccrued / ACCURAL_FACTOR_7D);
    assertEquals("CouponArithmeticAverageON 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("CouponArithmeticAverageON definition: toDerivative", pvConverted, pvExpected);
    assertEquals("CouponArithmeticAverageON definition: toDerivative", pvConverted, MultipleCurrencyAmount.of(Currency.USD, 19444.44444444444));
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.