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

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


      final double[][] delta = deserializer.fieldValueToObject(double[][].class, message.getByName(DELTA_DATA_FIELD_NAME));
      final double[][] volatility = deserializer.fieldValueToObject(double[][].class, message.getByName(VOLATILITY_DATA_FIELD_NAME));
      final int n = t.length;
      final SmileDeltaParameters[] smiles = new SmileDeltaParameters[n];
      for (int i = 0; i < n; i++) {
        smiles[i] = new SmileDeltaParameters(t[i], delta[i], volatility[i]);
      }
      final Interpolator1D strikeInterpolator = deserializer.fieldValueToObject(Interpolator1D.class, message.getByName(STRIKE_INTERPOLATOR_NAME));
      final Interpolator1D timeInterpolator = deserializer.fieldValueToObject(Interpolator1D.class, message.getByName(TIME_INTERPOLATOR_NAME));
      return new SmileDeltaTermStructureParametersStrikeInterpolation(smiles, strikeInterpolator, timeInterpolator);
    }
View Full Code Here


      final double[][] delta = deserializer.fieldValueToObject(double[][].class, message.getByName(DELTA_DATA_FIELD_NAME));
      final double[][] volatility = deserializer.fieldValueToObject(double[][].class, message.getByName(VOLATILITY_DATA_FIELD_NAME));
      final int n = t.length;
      final SmileDeltaParameters[] smiles = new SmileDeltaParameters[n];
      for (int i = 0; i < n; i++) {
        smiles[i] = new SmileDeltaParameters(t[i], delta[i], volatility[i]);
      }
      final Interpolator1D interpolator = deserializer.fieldValueToObject(Interpolator1D.class, message.getByName(TIME_INTERPOLATOR_NAME));
      return new SmileDeltaTermStructureParameters(smiles, interpolator);
    }
View Full Code Here

   */
  public void volatilityBelowFirstExpiry() {
    final double forward = 1.40;
    final double timeToExpiration = 0.05;
    final double strike = 1.45;
    final SmileDeltaParameters smile = new SmileDeltaParameters(timeToExpiration, ATM[0], DELTA, RISK_REVERSAL[0], STRANGLE[0]);
    final double[] strikes = smile.getStrike(forward);
    final double[] vol = smile.getVolatility();
    final ArrayInterpolator1DDataBundle volatilityInterpolation = new ArrayInterpolator1DDataBundle(strikes, vol);
    final double volExpected = INTERPOLATOR_STRIKE.interpolate(volatilityInterpolation, strike);
    final double volComputed = SMILE_TERM.getVolatility(timeToExpiration, strike, forward);
    assertEquals("Smile by delta term structure: volatility interpolation on strike", volExpected, volComputed, TOLERANCE_VOL);
  }
View Full Code Here

   */
  public void volatilityAboveLastExpiry() {
    final double forward = 1.40;
    final double timeToExpiration = 5.00;
    final double strike = 1.45;
    final SmileDeltaParameters smile = new SmileDeltaParameters(timeToExpiration, ATM[NB_EXP - 1], DELTA, RISK_REVERSAL[NB_EXP - 1], STRANGLE[NB_EXP - 1]);
    final double[] strikes = smile.getStrike(forward);
    final double[] vol = smile.getVolatility();
    final ArrayInterpolator1DDataBundle volatilityInterpolation = new ArrayInterpolator1DDataBundle(strikes, vol);
    final double volExpected = INTERPOLATOR_STRIKE.interpolate(volatilityInterpolation, strike);
    final double volComputed = SMILE_TERM.getVolatility(timeToExpiration, strike, forward);
    assertEquals("Smile by delta term structure: volatility interpolation on strike", volExpected, volComputed, TOLERANCE_VOL);
  }
View Full Code Here

    final double[] vol100 = SMILE_TERM.getVolatilityTerm()[3].getVolatility();
    final double[] vol = new double[vol050.length];
    for (int loopvol = 0; loopvol < vol050.length; loopvol++) {
      vol[loopvol] = Math.sqrt(((vol050[loopvol] * vol050[loopvol] * TIME_TO_EXPIRY[2] + vol100[loopvol] * vol100[loopvol] * TIME_TO_EXPIRY[3]) / 2.0) / timeToExpiration);
    }
    final SmileDeltaParameters smile = new SmileDeltaParameters(timeToExpiration, DELTA, vol);
    final double[] strikes = smile.getStrike(forward);
    final ArrayInterpolator1DDataBundle volatilityInterpolation = new ArrayInterpolator1DDataBundle(strikes, vol);
    final LinearInterpolator1D interpolator = new LinearInterpolator1D();
    final double volExpected = interpolator.interpolate(volatilityInterpolation, strike);
    final double volComputed = SMILE_TERM.getVolatility(timeToExpiration, strike, forward);
    assertEquals("Smile by delta term structure: volatility interpolation on strike", volExpected, volComputed, TOLERANCE_VOL);
View Full Code Here

      for (int loopexp = 0; loopexp < TIME_TO_EXPIRY.length; loopexp++) {
        for (int loopsmile = 0; loopsmile < 2 * DELTA.length + 1; loopsmile++) {
          System.arraycopy(SMILE_TERM.getVolatilityTerm(), 0, volData, 0, TIME_TO_EXPIRY.length);
          System.arraycopy(SMILE_TERM.getVolatilityTerm()[loopexp].getVolatility(), 0, volBumped, 0, 2 * DELTA.length + 1);
          volBumped[loopsmile] += shift;
          volData[loopexp] = new SmileDeltaParameters(TIME_TO_EXPIRY[loopexp], DELTA, volBumped);
          final SmileDeltaTermStructureParametersStrikeInterpolation smileTermBumped = new SmileDeltaTermStructureParametersStrikeInterpolation(volData, INTERPOLATOR_STRIKE);
          bucketTest[loopexp][loopsmile] = (smileTermBumped.getVolatility(timeToExpiration[looptest], strike[looptest], forward) - volComputed.getVolatility()) / shift;
          // FIXME: the strike sensitivity to volatility is missing. To be corrected when [PLAT-1396] is fixed.
          assertEquals("Smile by delta term structure: (test: " + looptest + ") volatility bucket sensitivity " + loopexp + " - " + loopsmile, bucketTest[loopexp][loopsmile],
              bucketSensi[loopexp][loopsmile], tolerance[looptest]);
View Full Code Here

              * TIME_TO_EXPIRY[indexLower + 1];
          variancePeriodT[loopvol] = weight0 * variancePeriod0[loopvol] + (1 - weight0) * variancePeriod1[loopvol];
          volatilityT[loopvol] = Math.sqrt(variancePeriodT[loopvol] / expiries[loopexp]);
        }
      }
      final SmileDeltaParameters smile = new SmileDeltaParameters(expiries[loopexp], DELTA, volatilityT);
      strikes[loopexp] = smile.getStrike(forward);
    }
  }
View Full Code Here

    }
    final SmileDeltaParameters[] surface = new SmileDeltaParameters[allSmiles.getNumberExpiration()];
    final int atmIndex = (allSmiles.getNumberStrike() - 1) / 2;
    final double[] deltas = {delta };
    for (int i = 0; i < allSmiles.getNumberExpiration(); i++) {
      final SmileDeltaParameters parameters = allSmiles.getSmileForTime(i);
      final double timeToExpiration = parameters.getTimeToExpiry();
      final double[] volatilities = new double[3];
      final double[] allVolatilities = parameters.getVolatility();
      volatilities[0] = allVolatilities[putDeltaIndex];
      volatilities[1] = allVolatilities[atmIndex];
      volatilities[2] = allVolatilities[2 * atmIndex - putDeltaIndex];
      surface[i] = new SmileDeltaParameters(timeToExpiration, deltas, volatilities);
    }
    final Interpolator1D interpolator = allSmiles.getTimeInterpolator();
    final SmileDeltaTermStructureParameters resultSmiles = new SmileDeltaTermStructureParameters(surface, interpolator);
    final Currency ccy1;
    final Currency ccy2;
View Full Code Here

      final ForexOptionVanillaDefinition forexOptionDefinition = new ForexOptionVanillaDefinition(forexUnderlyingDefinition, optionExpiry, isCall, isLong);
      forexOption[loopstrike] = forexOptionDefinition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    }
    final double forward = METHOD_BLACK.forwardForexRate(forexOption[0], SMILE_BUNDLE);
    final double dfDomestic = CURVES.getCurve(CURVES_NAME[1]).getDiscountFactor(forexOption[0].getUnderlyingForex().getPaymentTime()); // USD
    final SmileDeltaParameters smileAtTime = SMILE_BUNDLE.getSmile(EUR, USD, forexOption[0].getTimeToExpiry());
    final double[] strikesVV = smileAtTime.getStrike(forward);
    final double[] volVV = smileAtTime.getVolatility();
    for (int loopstrike = 0; loopstrike <= nbStrike; loopstrike++) {
      final double[] weightsComputed = METHOD_VANNA_VOLGA.vannaVolgaWeights(forexOption[loopstrike], forward, dfDomestic, strikesVV, volVV);
      final double[] vega = new double[3];
      final BlackFunctionData dataBlackATM = new BlackFunctionData(forward, dfDomestic, volVV[1]);
      for (int loopvv = 0; loopvv < 3; loopvv++) {
View Full Code Here

    final ZonedDateTime optionPay = ScheduleCalculator.getAdjustedDate(optionExpiry, SETTLEMENT_DAYS, CALENDAR);
    final ForexDefinition forexUnderlyingSpotDefinition = new ForexDefinition(EUR, USD, optionPay, notional, SPOT);
    final ForexOptionVanillaDefinition forexOptionSpotDefinition = new ForexOptionVanillaDefinition(forexUnderlyingSpotDefinition, optionExpiry, isCall, isLong);
    final ForexOptionVanilla forexOptionSpot = forexOptionSpotDefinition.toDerivative(REFERENCE_DATE, CURVES_NAME);
    final double forward = METHOD_BLACK.forwardForexRate(forexOptionSpot, SMILE_BUNDLE_STRIKE_INT);
    final SmileDeltaParameters smileTime = SMILE_TERM.getSmileForTime(forexOptionSpot.getTimeToExpiry());
    final double[] strikes = smileTime.getStrike(forward);
    final int nbStrike = strikes.length;
    final ForexOptionVanilla[] forexOption = new ForexOptionVanilla[nbStrike];
    for (int loopstrike = 0; loopstrike < nbStrike; loopstrike++) {
      final ForexDefinition forexUnderlyingDefinition = new ForexDefinition(EUR, USD, optionPay, notional, strikes[loopstrike]);
      final ForexOptionVanillaDefinition forexOptionDefinition = new ForexOptionVanillaDefinition(forexUnderlyingDefinition, optionExpiry, isCall, isLong);
View Full Code Here

TOP

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

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.