Package com.opengamma.analytics.financial.forex.derivative

Examples of com.opengamma.analytics.financial.forex.derivative.ForexOptionVanilla


  }

  @Override
  public ForexOptionSingleBarrier toDerivative(final ZonedDateTime date) {
    ArgumentChecker.notNull(date, "date");
    final ForexOptionVanilla underlying = _underlyingOption.toDerivative(date);
    return new ForexOptionSingleBarrier(underlying, _barrier);
  }
View Full Code Here


  public ForexOptionVanilla toDerivative(final ZonedDateTime date, final String... yieldCurveNames) {
    ArgumentChecker.notNull(date, "date");
    ArgumentChecker.notNull(yieldCurveNames, "yieldCurveNames");
    final Forex fx = _underlyingForex.toDerivative(date, yieldCurveNames);
    final double expirationTime = TimeCalculator.getTimeBetween(date, _expirationDate);
    return new ForexOptionVanilla(fx, expirationTime, _isCall, _isLong);
  }
View Full Code Here

  @Override
  public ForexOptionVanilla toDerivative(final ZonedDateTime date) {
    ArgumentChecker.notNull(date, "date");
    final Forex fx = _underlyingForex.toDerivative(date);
    final double expirationTime = TimeCalculator.getTimeBetween(date, _expirationDate);
    return new ForexOptionVanilla(fx, expirationTime, _isCall, _isLong);
  }
View Full Code Here

      final CurrencyAmount result = forex.accept(CALCULATOR, data);
      final double gammaValue = result.getAmount() / 100.0; // FIXME: the 100 should be removed when the scaling is available
      // for PLAT-4626
      double spot = 1;
      if (forex instanceof ForexOptionVanilla) {
        final ForexOptionVanilla fxDerivative = (ForexOptionVanilla) forex;
        spot = data.getFxRates().getFxRate(fxDerivative.getCurrency1(), fxDerivative.getCurrency2());
      } else if (forex instanceof ForexOptionDigital) {
        final ForexOptionDigital fxDerivative = (ForexOptionDigital) forex;
        if (fxDerivative.payDomestic()) {
          spot = data.getFxRates().getFxRate(fxDerivative.getCurrency1(), fxDerivative.getCurrency2());    
        } else {
          spot = data.getFxRates().getFxRate(fxDerivative.getCurrency2(), fxDerivative.getCurrency1());      
        }
      } else if (forex instanceof ForexOptionSingleBarrier) {
        final ForexOptionSingleBarrier fxDerivative = (ForexOptionSingleBarrier) forex;
        spot = data.getFxRates().getFxRate(fxDerivative.getCurrency1(), fxDerivative.getCurrency2());
        return Collections.singleton(new ComputedValue(spec, gammaValue * spot * spot));
      }
      return Collections.singleton(new ComputedValue(spec, gammaValue * spot));
    }
    throw new OpenGammaRuntimeException("Can only calculate gamma spot for surfaces with smiles");
View Full Code Here

    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20);
    final InstrumentDerivative optionConverted = FX_OPTION_DEFINITION.toDerivative(referenceDate, curves_name);
    final Forex fx = FX_DEFINITION.toDerivative(referenceDate, curves_name);
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double expirationTime = actAct.getDayCountFraction(referenceDate, EXPIRATION_DATE);
    final ForexOptionVanilla optionConstructed = new ForexOptionVanilla(fx, expirationTime, IS_CALL, IS_LONG);
    assertEquals("Convertion to derivative", optionConstructed, optionConverted);
  }
View Full Code Here

    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2011, 5, 20);
    final InstrumentDerivative optionConverted = FX_OPTION_DEFINITION.toDerivative(referenceDate);
    final Forex fx = FX_DEFINITION.toDerivative(referenceDate);
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double expirationTime = actAct.getDayCountFraction(referenceDate, EXPIRATION_DATE);
    final ForexOptionVanilla optionConstructed = new ForexOptionVanilla(fx, expirationTime, IS_CALL, IS_LONG);
    assertEquals("Convertion to derivative", optionConstructed, optionConverted);
  }
View Full Code Here

   * the treatment of the barrier is: Price(t,T_exp) (roughly :))
   */
  public void testKnockInOutParity() {
    // Local version where expiry is OPTION_PAY_DATE
    final ForexOptionVanillaDefinition vanillaDefn = new ForexOptionVanillaDefinition(FOREX_DEFINITION, OPTION_PAY_DATE, IS_CALL, IS_LONG);
    final ForexOptionVanilla vanillaExpiryEqualsPay = vanillaDefn.toDerivative(REFERENCE_DATE, CURVES_NAME);

    final ForexOptionSingleBarrier knockOut = new ForexOptionSingleBarrier(vanillaExpiryEqualsPay, BARRIER_KO, 0.0);
    final ForexOptionSingleBarrier knockIn = new ForexOptionSingleBarrier(vanillaExpiryEqualsPay, BARRIER_KI, 0.0);
    final ForexOptionSingleBarrier impossibleKnockOut = new ForexOptionSingleBarrier(vanillaExpiryEqualsPay, BARRIER_IMPOSSIBLE_DOWN, 0.0);

View Full Code Here

  public void scaleLongShortParity() {
    final MultipleCurrencyAmount priceBarrier = METHOD_BARRIER.presentValue(OPTION_BARRIER, SMILE_BUNDLE);
    final double scale = 10;
    final ForexDefinition fxDefinitionScale = new ForexDefinition(EUR, USD, OPTION_PAY_DATE, NOTIONAL * scale, STRIKE);
    final ForexOptionVanillaDefinition optionDefinitionScale = new ForexOptionVanillaDefinition(fxDefinitionScale, OPTION_EXPIRY_DATE, IS_CALL, IS_LONG);
    final ForexOptionVanilla optionScale = optionDefinitionScale.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final ForexOptionSingleBarrier optionBarrierScale = new ForexOptionSingleBarrier(optionScale, BARRIER_KI, scale * REBATE);
    final MultipleCurrencyAmount priceBarrierScale = METHOD_BARRIER.presentValue(optionBarrierScale, SMILE_BUNDLE);
    assertEquals("Barriers are cheaper than vanilla", priceBarrier.getAmount(USD) * scale, priceBarrierScale.getAmount(USD), 1.0E-2);
    final MultipleCurrencyAmount priceBarrierShort = METHOD_BARRIER.presentValue(BARRIER_SHORT, SMILE_BUNDLE);
    assertEquals("Barriers are cheaper than vanilla", -priceBarrier.getAmount(USD), priceBarrierShort.getAmount(USD), 1.0E-2);
View Full Code Here

    final String putCurveName = desiredValue.getConstraint(PUT_CURVE);
    final String callCurveName = desiredValue.getConstraint(CALL_CURVE);
    final String deltaName = desiredValue.getConstraint(PROPERTY_OTM_DELTA);
    final String[] allCurveNames = getCurveNames(putCurrency, putCurveName, callCurrency, callCurveName, baseQuotePairs);
    final SmileDeltaTermStructureVannaVolgaDataBundle smiles = getSmiles(putCurrency, callCurrency, allCurveNames, baseQuotePairs, deltaName, inputs);
    final ForexOptionVanilla fxOption = (ForexOptionVanilla) getDerivative(security, allCurveNames, baseQuotePairs, now);
    final MultipleCurrencyAmount pv = CALCULATOR.presentValue(fxOption, smiles);
    ArgumentChecker.isTrue(pv.size() == 1, "result size must be one; have {}", pv.size());
    final CurrencyAmount ca = pv.getCurrencyAmounts()[0];
    final double amount = ca.getAmount();
    final CurrencyPair baseQuotePair = baseQuotePairs.getCurrencyPair(putCurrency, callCurrency);
View Full Code Here

    final boolean isLong = true;
    final double notional = 100000000;
    final int indexPay = 2; // 1Y
    final ForexDefinition forexUnderlyingDefinition = new ForexDefinition(EUR, USD, PAY_DATE[indexPay], notional, strike);
    final ForexOptionVanillaDefinition forexOptionDefinition = new ForexOptionVanillaDefinition(forexUnderlyingDefinition, EXPIRY_DATE[indexPay], isCall, isLong);
    final ForexOptionVanilla forexOption = forexOptionDefinition.toDerivative(REFERENCE_DATE);
    final double df = MULTICURVES.getDiscountFactor(USD, TimeCalculator.getTimeBetween(REFERENCE_DATE, PAY_DATE[indexPay]));
    final double forward = SPOT * MULTICURVES.getDiscountFactor(EUR, TimeCalculator.getTimeBetween(REFERENCE_DATE, PAY_DATE[indexPay])) / df;
    final double volatility = SMILE_TERM.getVolatility(new Triple<>(TIME_TO_EXPIRY[indexPay + 1], strike, forward));
    final BlackFunctionData dataBlack = new BlackFunctionData(forward, df, volatility);
    final Function1D<BlackFunctionData, Double> func = BLACK_FUNCTION.getPriceFunction(forexOption);
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.forex.derivative.ForexOptionVanilla

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.