Package com.opengamma.analytics.financial.model.interestrate.curve

Examples of com.opengamma.analytics.financial.model.interestrate.curve.ForwardCurve


   * @param newForwardCurve New Forward Curve
   * @return New expiry-moneyness local volatility surface, such that the expiry-strike surface would be unchanged
   */
  public static LocalVolatilitySurfaceMoneyness shiftForwardCurve(final LocalVolatilitySurfaceMoneyness from, final ForwardCurve newForwardCurve) {

    final ForwardCurve forwardCurve = from.getForwardCurve();

    final Function<Double, Double> surFunc = new Function<Double, Double>() {

      @Override
      public Double evaluate(final Double... tx) {
        final double t = tx[0];
        final double x = tx[1];
        final double f = forwardCurve.getForward(t);
        final double fPrime = newForwardCurve.getForward(t);
        final double xPrime = x * fPrime / f;
        return from.getVolatilityForMoneyness(t, xPrime);
      }
    };
View Full Code Here


   * @param shift fraction shift amount, i.e. 0.1 with produce a forward curve 10% larger than the original
   * @return New expiry-moneyness local volatility surface, such that the expiry-strike surface would be unchanged
   */
  public static LocalVolatilitySurfaceMoneyness shiftForwardCurve(final LocalVolatilitySurfaceMoneyness from, final double shift) {
    Validate.isTrue(shift > -1, "shift must be > -1");
    final ForwardCurve newForwardCurve = from.getForwardCurve().withFractionalShift(shift);

    final Function<Double, Double> surFunc = new Function<Double, Double>() {

      @Override
      public Double evaluate(final Double... tx) {
View Full Code Here

  }

  public PDEFullResults1D solve(final SmileSurfaceDataBundle data, final LocalVolatilitySurface<?> localVolatility) {
    ArgumentChecker.notNull(data, "data");
    ArgumentChecker.notNull(localVolatility, "local volatility surface");
    final ForwardCurve forwardCurve = data.getForwardCurve();
    final double[] expiries = data.getExpiries();
    //    final double[][] strikes = data.getStrikes();
    //    final double[][] impliedVols = data.getVolatilities();
    final boolean isCall = true; //TODO have this as an option  data.isCallData();
    return runPDESolver(forwardCurve, localVolatility, expiries, isCall);
View Full Code Here

  public PDEResultCollection getGridGreeks(final SmileSurfaceDataBundle data, final LocalVolatilitySurface<?> localVolatility, final EuropeanVanillaOption option) {
    ArgumentChecker.notNull(data, "data");
    ArgumentChecker.notNull(option, "option");
    ArgumentChecker.notNull(localVolatility, "local volatility surface");
    final ForwardCurve forwardCurve = data.getForwardCurve();
    final boolean isCall = true; //TODO have this as an option  data.isCallData();
    LocalVolatilitySurfaceStrike strikeLocalVolatility;
    if (localVolatility instanceof LocalVolatilitySurfaceStrike) {
      strikeLocalVolatility = (LocalVolatilitySurfaceStrike) localVolatility;
    } else if (localVolatility instanceof LocalVolatilitySurfaceMoneyness) {
View Full Code Here

   * bumped each input volatility by 1bs and record the effect on the representative point by following the chain
   * of refitting the implied volatility surface, the local volatility surface and running the forward PDE solver
   */
  private BucketedGreekResultCollection bucketedVega(final LocalVolatilitySurfaceStrike localVolatility, final SmileSurfaceDataBundle data, final EuropeanVanillaOption option) {
    final double[] expiries = data.getExpiries();
    final ForwardCurve forwardCurve = data.getForwardCurve();
    final boolean isCall = true; //TODO have this as an option  data.isCallData();

    final double[][] strikes = data.getStrikes();
    final int nExpiries = expiries.length;
    final double forward = forwardCurve.getForward(option.getTimeToExpiry());
    final double maxT = option.getTimeToExpiry();
    final double x = option.getStrike() / forward;

    final PDEFullResults1D pdeRes = runForwardPDESolver(forwardCurve, localVolatility, isCall, _theta, maxT, _maxAbsProxyDelta,
        _timeSteps, _spaceSteps, _timeGridBunching, _spaceGridBunching, 1.0);
View Full Code Here

  public Interpolator1DDataBundle getResult(final LocalVolatilitySurfaceMoneyness localVolatility, final ForwardCurve forwardCurve, final EuropeanVanillaOption option,
      final YieldAndDiscountCurve discountingCurve) {
    final LocalVolatilitySurfaceStrike lvStrike = LocalVolatilitySurfaceConverter.toStrikeSurface(localVolatility);
    final LocalVolatilitySurfaceStrike localVolatilityUp = new LocalVolatilitySurfaceStrike(SurfaceShiftFunctionFactory.getShiftedSurface(lvStrike.getSurface(), VOL_SHIFT, true));
    final LocalVolatilitySurfaceStrike localVolatilityDown = new LocalVolatilitySurfaceStrike(SurfaceShiftFunctionFactory.getShiftedSurface(lvStrike.getSurface(), -VOL_SHIFT, true));
    final ForwardCurve forwardCurveUp = forwardCurve.withFractionalShift(FWD_SHIFT);
    final ForwardCurve forwardCurveDown = forwardCurve.withFractionalShift(-FWD_SHIFT);
    final PDETerminalResults1D pdeGrid = _pdeCalculator.runPDESolver(localVolatility, option);
    final PDETerminalResults1D pdeGridUp = _pdeCalculator.runPDESolver(localVolatilityUp, forwardCurve, option);
    final PDETerminalResults1D pdeGridDown = _pdeCalculator.runPDESolver(localVolatilityDown, forwardCurve, option);
    final PDETerminalResults1D pdeGridUpUp = _pdeCalculator.runPDESolver(localVolatilityUp, forwardCurveUp, option);
    final PDETerminalResults1D pdeGridUpDown = _pdeCalculator.runPDESolver(localVolatilityDown, forwardCurveUp, option);
View Full Code Here

  @Override
  public Interpolator1DDataBundle getResult(final LocalVolatilitySurfaceStrike localVolatility, final ForwardCurve forwardCurve, final EuropeanVanillaOption option,
      final YieldAndDiscountCurve discountingCurve) {
    final LocalVolatilitySurfaceStrike localVolatilityUp = new LocalVolatilitySurfaceStrike(SurfaceShiftFunctionFactory.getShiftedSurface(localVolatility.getSurface(), VOL_SHIFT, true));
    final LocalVolatilitySurfaceStrike localVolatilityDown = new LocalVolatilitySurfaceStrike(SurfaceShiftFunctionFactory.getShiftedSurface(localVolatility.getSurface(), -VOL_SHIFT, true));
    final ForwardCurve forwardCurveUp = forwardCurve.withFractionalShift(FWD_SHIFT);
    final ForwardCurve forwardCurveDown = forwardCurve.withFractionalShift(-FWD_SHIFT);
    final PDETerminalResults1D pdeGrid = _pdeCalculator.runPDESolver(localVolatility, forwardCurve, option);
    final PDETerminalResults1D pdeGridUp = _pdeCalculator.runPDESolver(localVolatilityUp, forwardCurve, option);
    final PDETerminalResults1D pdeGridDown = _pdeCalculator.runPDESolver(localVolatilityDown, forwardCurve, option);
    final PDETerminalResults1D pdeGridUpUp = _pdeCalculator.runPDESolver(localVolatilityUp, forwardCurveUp, option);
    final PDETerminalResults1D pdeGridUpDown = _pdeCalculator.runPDESolver(localVolatilityDown, forwardCurveUp, option);
View Full Code Here

        ArrayUtils.toPrimitive(other.getForwardCurve().getForwardCurve().getXData()), 0);
    assertArrayEquals(ArrayUtils.toPrimitive(DATA.getForwardCurve().getForwardCurve().getYData()),
        ArrayUtils.toPrimitive(other.getForwardCurve().getForwardCurve().getYData()), 0);
    assertEquals(((InterpolatedDoublesCurve) DATA.getForwardCurve().getForwardCurve()).getInterpolator(),
        ((InterpolatedDoublesCurve) other.getForwardCurve().getForwardCurve()).getInterpolator());
    final ForwardCurve otherCurve = new ForwardCurve(InterpolatedDoublesCurve.from(EXPIRIES, EXPIRIES, INTERPOLATOR));
    other = new ForexSmileDeltaSurfaceDataBundle(otherCurve, EXPIRIES, DELTAS, ATM, RR, STRANGLE, IS_CALL_DATA);
    assertFalse(DATA.equals(other));
    other = new ForexSmileDeltaSurfaceDataBundle(FORWARD_CURVE, new double[] {7. / 365, 14 / 365., 21 / 365., 1 / 12., 3 / 12., 0.5, 0.75, 1, 5, 9 }, DELTAS, ATM, RR, STRANGLE, IS_CALL_DATA);
    assertFalse(DATA.equals(other));
    other = new ForexSmileDeltaSurfaceDataBundle(FORWARD_CURVE, EXPIRIES, new double[] {0.15, 0.35 }, ATM, RR, STRANGLE, IS_CALL_DATA);
View Full Code Here

        ArrayUtils.toPrimitive(other.getForwardCurve().getForwardCurve().getXData()), 0);
    assertArrayEquals(ArrayUtils.toPrimitive(DATA.getForwardCurve().getForwardCurve().getYData()),
        ArrayUtils.toPrimitive(other.getForwardCurve().getForwardCurve().getYData()), 0);
    assertEquals(((InterpolatedDoublesCurve) DATA.getForwardCurve().getForwardCurve()).getInterpolator(),
        ((InterpolatedDoublesCurve) other.getForwardCurve().getForwardCurve()).getInterpolator());
    final ForwardCurve otherCurve = new ForwardCurve(InterpolatedDoublesCurve.from(ArrayUtils.add(EXPIRIES, 0, 0), ArrayUtils.add(EXPIRIES, 0, SPOT), INTERPOLATOR));
    other = new StandardSmileSurfaceDataBundle(otherCurve, EXPIRIES, STRIKES, VOLS);
    assertFalse(DATA.equals(other));
    other = new StandardSmileSurfaceDataBundle(FORWARD_CURVE, new double[] {0, 0.01, 0.02 }, STRIKES, VOLS);
    assertFalse(DATA.equals(other));
    other = new StandardSmileSurfaceDataBundle(FORWARD_CURVE, EXPIRIES, VOLS, VOLS);
View Full Code Here

    _expiries = expiries;
    _forwards = forwards;

    final double[] t = ArrayUtils.add(expiries, 0, 0.0);
    final double[] f = ArrayUtils.add(forwards, 0, spot);
    _forwardCurve = new ForwardCurve(InterpolatedDoublesCurve.from(t, f, forwardCurveInterpolator));
    _strikes = strikes;
    _impliedVols = impliedVols;
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.model.interestrate.curve.ForwardCurve

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.