Package com.opengamma.analytics.financial.model.option.definition

Examples of com.opengamma.analytics.financial.model.option.definition.SmileDeltaTermStructureDataBundle


  /**
   * Tests the present value versus an hard-coded value.
   */
  public void persentValueHardCoded() {
    final YieldCurveBundle curves = TestsDataSetsForex.createCurvesForexXXXYYY(USD, KRW, SPOT_USD_KRW);
    final SmileDeltaTermStructureDataBundle curvesVol = new SmileDeltaTermStructureDataBundle(curves, SMILE_TERM_FLAT_USD_KRW, Pair.of(USD, KRW));
    final MultipleCurrencyAmount pvComputed = METHOD_BLACK_DIGITAL.presentValue(FOREX_DIGITAL_USD_KRW_PUT_FOR, curvesVol);
    final double pvHardCoded = 43312.895;
    assertEquals("Forex Digital option: present value", pvHardCoded, pvComputed.getAmount(USD), TOLERANCE_PV);
  }
View Full Code Here


    final double[] pv = new double[nbSpot + 1];
    for (int loopspot = 0; loopspot <= nbSpot; loopspot++) {
      spot[loopspot] = strike - range + 2.0d * range * loopspot / nbSpot;
      final FXMatrix fxMatrix = new FXMatrix(EUR, USD, spot[loopspot]);
      final YieldCurveBundle curves = new YieldCurveBundle(fxMatrix, CURVE_CURRENCY, CURVES.getCurvesMap());
      final SmileDeltaTermStructureDataBundle smileBundle = new SmileDeltaTermStructureDataBundle(curves, SMILE_TERM, Pair.of(EUR, USD));
      pv[loopspot] = METHOD_BLACK_DIGITAL.presentValue(forexOption, smileBundle).getAmount(USD);
    }
  }
View Full Code Here

    final double[] pv = new double[nbSpot + 1];
    for (int loopspot = 0; loopspot <= nbSpot; loopspot++) {
      spot[loopspot] = strike - range + 2.0d * range * loopspot / nbSpot;
      final FXMatrix fxMatrix = new FXMatrix(EUR, USD, spot[loopspot]);
      final YieldCurveBundle curves = new YieldCurveBundle(fxMatrix, CURVE_CURRENCY, CURVES.getCurvesMap());
      final SmileDeltaTermStructureDataBundle smileBundle = new SmileDeltaTermStructureDataBundle(curves, SMILE_TERM, Pair.of(EUR, USD));
      pv[loopspot] = METHOD_BLACK_DIGITAL.presentValue(forexOption, smileBundle).getAmount(EUR);
    }
  }
View Full Code Here

    final double shift = 0.000005;
    final FXMatrix fxMatrix = new FXMatrix(EUR, USD, SPOT);
    final FXMatrix fxMatrixP = new FXMatrix(EUR, USD, SPOT + shift);
    final YieldCurveBundle curves = new YieldCurveBundle(fxMatrix, CURVE_CURRENCY, CURVES.getCurvesMap());
    final YieldCurveBundle curvesP = new YieldCurveBundle(fxMatrixP, CURVE_CURRENCY, CURVES.getCurvesMap());
    final SmileDeltaTermStructureDataBundle smileBundle = new SmileDeltaTermStructureDataBundle(curves, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final SmileDeltaTermStructureDataBundle smileBundleP = new SmileDeltaTermStructureDataBundle(curvesP, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final MultipleCurrencyAmount ce = METHOD_BLACK_DIGITAL.currencyExposure(FOREX_DIGITAL_CALL_FOR, smileBundle);
    final MultipleCurrencyAmount pv = METHOD_BLACK_DIGITAL.presentValue(FOREX_DIGITAL_CALL_FOR, smileBundle);
    final MultipleCurrencyAmount pvP = METHOD_BLACK_DIGITAL.presentValue(FOREX_DIGITAL_CALL_FOR, smileBundleP);
    assertEquals("Forex Digital option: call spread method - currency exposure - PL EUR", pvP.getAmount(EUR) - pv.getAmount(EUR), ce.getAmount(USD) * (1.0 / (SPOT + shift) - 1 / SPOT),
        TOLERANCE_PV);
View Full Code Here

  /**
   * Tests the present value versus an hard-coded value.
   */
  public void persentValueHardCoded() {
    final YieldCurveBundle curves = TestsDataSetsForex.createCurvesForexXXXYYY(USD, JPY, SPOT_USD_JPY);
    final SmileDeltaTermStructureDataBundle curvesVol = new SmileDeltaTermStructureDataBundle(curves, SMILE_TERM_FLAT_USD_JPY, Pair.of(USD, JPY));
    final MultipleCurrencyAmount pvComputed = METHOD_BARRIER.presentValue(CALL_USD_JPY_BARRIER, curvesVol);
    final CurrencyAmount pvComputedUSD = curves.getFxRates().convert(pvComputed, USD);
    final double pvHardCodedUSD = 12958.820;
    assertEquals("Forex Barrier option: present value", pvHardCodedUSD, pvComputedUSD.getAmount(), TOLERANCE_PV);
    final MultipleCurrencyAmount pvVanilla = METHOD_VANILLA.presentValue(CALL_USD_JPY_BARRIER.getUnderlyingOption(), curvesVol);
View Full Code Here

    final double[][] rrFlat = new double[][] { {0.0, 0.0 }, {0.0, 0.0 }, {0.0, 0.0 }, {0.0, 0.0 }, {0.0, 0.0 } };
    final double[][] sFlat = new double[][] { {0.0, 0.0 }, {0.0, 0.0 }, {0.0, 0.0 }, {0.0, 0.0 }, {0.0, 0.0 } };
    final SmileDeltaTermStructureParametersStrikeInterpolation smileTermFlat = new SmileDeltaTermStructureParametersStrikeInterpolation(TIME_TO_EXPIRY, DELTA, atmFlat, rrFlat, sFlat);
    final FXMatrix fxMatrixShift = new FXMatrix(EUR, USD, SPOT + shiftSpotEURUSD);
    final YieldCurveBundle curvesShiftedFX = new YieldCurveBundle(fxMatrixShift, CURVES.getCurrencyMap(), CURVES.getCurvesMap());
    final SmileDeltaTermStructureDataBundle smileBumpedSpot = new SmileDeltaTermStructureDataBundle(curvesShiftedFX, smileTermFlat, 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;
    final double spotGBPEUR = spotGBPUSD / SPOT;
View Full Code Here

   * This works well for the one-dimensional sensitivities above, but not well at all for the cross-derivative, Vanna. Comparison below, and in test above.
   *
   */
  public void testOfFiniteDifferenceMethods() {
    final ForexOptionSingleBarrier optionForex = OPTION_BARRIER;
    final SmileDeltaTermStructureDataBundle smile = SMILE_BUNDLE;
    final double bp10 = 0.001;
    final double relShift = 0.001;
    // repackage for calls to BARRIER_FUNCTION
    final String domesticCurveName = optionForex.getUnderlyingOption().getUnderlyingForex().getPaymentCurrency2().getFundingCurveName();
    final String foreignCurveName = optionForex.getUnderlyingOption().getUnderlyingForex().getPaymentCurrency1().getFundingCurveName();
    final double payTime = optionForex.getUnderlyingOption().getUnderlyingForex().getPaymentTime();
    final double rateDomestic = smile.getCurve(domesticCurveName).getInterestRate(payTime);
    final double rateForeign = smile.getCurve(foreignCurveName).getInterestRate(payTime);
    final double costOfCarry = rateDomestic - rateForeign;
    final double spot = smile.getFxRates().getFxRate(optionForex.getCurrency1(), optionForex.getCurrency2());
    final double forward = spot * Math.exp(-rateForeign * payTime) / Math.exp(-rateDomestic * payTime);
    final double foreignAmount = optionForex.getUnderlyingOption().getUnderlyingForex().getPaymentCurrency1().getAmount();
    final double rebateByForeignUnit = optionForex.getRebate() / Math.abs(foreignAmount);
    final double sign = (optionForex.getUnderlyingOption().isLong() ? 1.0 : -1.0);
    final double vol = FXVolatilityUtils.getVolatility(smile, optionForex.getCurrency1(), optionForex.getCurrency2(), optionForex.getUnderlyingOption().getTimeToExpiry(), optionForex
View Full Code Here

    assertEquals("Forex: relative delta", ce.getAmount(EUR), delta, TOLERANCE_RELATIVE);
    final FXMatrix fxMatrixM = new FXMatrix(EUR, USD, SPOT - shift);
    final FXMatrix fxMatrixP = new FXMatrix(EUR, USD, SPOT + shift);
    final YieldCurveBundle fxDown = new YieldCurveBundle(fxMatrixM, CURVES.getCurrencyMap(), CURVES.getCurvesMap());
    final YieldCurveBundle fxUp = new YieldCurveBundle(fxMatrixP, CURVES.getCurrencyMap(), CURVES.getCurvesMap());
    final SmileDeltaTermStructureDataBundle smileBundleM = new SmileDeltaTermStructureDataBundle(fxDown, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final SmileDeltaTermStructureDataBundle smileBundleP = new SmileDeltaTermStructureDataBundle(fxUp, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final MultipleCurrencyAmount pvM = METHOD_OPTION.presentValue(forexOption, smileBundleM);
    final MultipleCurrencyAmount pvP = METHOD_OPTION.presentValue(forexOption, smileBundleP);
    final double deltaFlat = METHOD_OPTION.deltaRelative(forexOption, SMILE_BUNDLE_FLAT, true);
    assertEquals("Forex: relative delta", (pvP.getAmount(USD) - pvM.getAmount(USD)) / (2 * shift), deltaFlat, TOLERANCE_RELATIVE);
  }
View Full Code Here

    final double shift = 1.0E-6;
    final FXMatrix fxMatrixM = new FXMatrix(EUR, USD, SPOT - shift);
    final FXMatrix fxMatrixP = new FXMatrix(EUR, USD, SPOT + shift);
    final YieldCurveBundle fxDown = new YieldCurveBundle(fxMatrixM, CURVES.getCurrencyMap(), CURVES.getCurvesMap());
    final YieldCurveBundle fxUp = new YieldCurveBundle(fxMatrixP, CURVES.getCurrencyMap(), CURVES.getCurvesMap());
    final SmileDeltaTermStructureDataBundle smileBundleM = new SmileDeltaTermStructureDataBundle(fxDown, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final SmileDeltaTermStructureDataBundle smileBundleP = new SmileDeltaTermStructureDataBundle(fxUp, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final double strike = 1.45;
    final boolean isCall = true;
    final boolean isLong = true;
    final double notional = 1;
    final ZonedDateTime payDate = ScheduleCalculator.getAdjustedDate(REFERENCE_DATE, Period.ofMonths(9), BUSINESS_DAY, CALENDAR);
View Full Code Here

    assertEquals("Forex: relative delta", ce.getAmount(EUR), delta, TOLERANCE_RELATIVE);
    final FXMatrix fxMatrixM = new FXMatrix(EUR, USD, SPOT * (1 - shift));
    final FXMatrix fxMatrixP = new FXMatrix(EUR, USD, SPOT * (1 + shift));
    final YieldCurveBundle fxDown = new YieldCurveBundle(fxMatrixM, CURVES.getCurrencyMap(), CURVES.getCurvesMap());
    final YieldCurveBundle fxUp = new YieldCurveBundle(fxMatrixP, CURVES.getCurrencyMap(), CURVES.getCurvesMap());
    final SmileDeltaTermStructureDataBundle smileBundleM = new SmileDeltaTermStructureDataBundle(fxDown, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final SmileDeltaTermStructureDataBundle smileBundleP = new SmileDeltaTermStructureDataBundle(fxUp, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final MultipleCurrencyAmount pvM = METHOD_OPTION.presentValue(forexOption, smileBundleM);
    final MultipleCurrencyAmount pvP = METHOD_OPTION.presentValue(forexOption, smileBundleP);
    final double deltaFlat = METHOD_OPTION.deltaRelativeSpot(forexOption, SMILE_BUNDLE_FLAT, true);
    assertEquals("Forex: relative delta", (pvP.getAmount(USD) - pvM.getAmount(USD)) / (2 * shift), deltaFlat, TOLERANCE_RELATIVE);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.option.definition.SmileDeltaTermStructureDataBundle

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.