Package com.opengamma.analytics.financial.greeks

Examples of com.opengamma.analytics.financial.greeks.PDEResultCollection$BackingMapGreekIterator


      final double xVanna = getXVanna(volShift, pdeResVolUp, pdeResVolDown, i, moneyness);
      final double surfaceVanna = getSurfaceVanna(pdeResForwardUpVolUp, pdeResForwardUpVolDown, pdeResForwardDownVolUp, pdeResForwardDownVolDown, volShift, forwardShift, i);
      modelVanna.add(getModelVanna(xVanna, surfaceVanna));
      modelVomma.add(getModelVomma(pdeRes, pdeResVolUp, pdeResVolDown, volShift, i));
    }
    final PDEResultCollection result = new PDEResultCollection(strikes.toDoubleArray());
    result.put(PDEResultCollection.GRID_PRICE, prices.toDoubleArray());
    result.put(PDEResultCollection.GRID_BLACK_PRICE, blackPrices.toDoubleArray());
    result.put(PDEResultCollection.GRID_IMPLIED_VOL, impliedVolatilities.toDoubleArray());
    result.put(PDEResultCollection.GRID_BLACK_DELTA, bsDelta.toDoubleArray());
    result.put(PDEResultCollection.GRID_BLACK_DUAL_DELTA, bsDualDelta.toDoubleArray());
    result.put(PDEResultCollection.GRID_BLACK_GAMMA, bsGamma.toDoubleArray());
    result.put(PDEResultCollection.GRID_BLACK_DUAL_GAMMA, bsDualGamma.toDoubleArray());
    result.put(PDEResultCollection.GRID_BLACK_VEGA, bsVega.toDoubleArray());
    result.put(PDEResultCollection.GRID_BLACK_VANNA, bsVanna.toDoubleArray());
    result.put(PDEResultCollection.GRID_BLACK_VOMMA, bsVomma.toDoubleArray());
    result.put(PDEResultCollection.GRID_DELTA, modelDelta.toDoubleArray());
    result.put(PDEResultCollection.GRID_DUAL_DELTA, modelDualDelta.toDoubleArray());
    result.put(PDEResultCollection.GRID_GAMMA, modelGamma.toDoubleArray());
    result.put(PDEResultCollection.GRID_DUAL_GAMMA, modelDualGamma.toDoubleArray());
    result.put(PDEResultCollection.GRID_VEGA, modelVega.toDoubleArray());
    result.put(PDEResultCollection.GRID_VANNA, modelVanna.toDoubleArray());
    result.put(PDEResultCollection.GRID_VOMMA, modelVomma.toDoubleArray());
    result.put(PDEResultCollection.GRID_DOMESTIC_PV_QUOTE, absoluteDomesticPrice.toDoubleArray());
    return result;
  }
View Full Code Here


    private static final String GRID_VOMMA_FIELD = "gridVommaField";

    @Override
    public PDEResultCollection buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final double[] strikes = deserializer.fieldValueToObject(double[].class, message.getByName(STRIKES_FIELD));
      final PDEResultCollection result = new PDEResultCollection(strikes);
      if (message.getByName(GRID_IMPLIED_VOLS_FIELD) != null) {
        final double[] impliedVol = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_IMPLIED_VOLS_FIELD));
        result.put(PDEResultCollection.GRID_IMPLIED_VOL, impliedVol);
      }
      //DEBUG trying to get a new number out
      if (message.getByName(GRID_FOREX_PV_QUOTES_FIELD) != null) {
        final double[] domesticAbsolute = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_FOREX_PV_QUOTES_FIELD));
        result.put(PDEResultCollection.GRID_DOMESTIC_PV_QUOTE, domesticAbsolute);
      }

      if (message.getByName(GRID_PRICE_FIELD) != null) {
        final double[] price = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_PRICE_FIELD));
        result.put(PDEResultCollection.GRID_PRICE, price);
      }
      if (message.getByName(GRID_BLACK_PRICE_FIELD) != null) {
        final double[] price = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_BLACK_PRICE_FIELD));
        result.put(PDEResultCollection.GRID_BLACK_PRICE, price);
      }
      if (message.getByName(GRID_BLACK_DELTA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_BLACK_DELTA_FIELD));
        result.put(PDEResultCollection.GRID_BLACK_DELTA, greek);
      }
      if (message.getByName(GRID_BLACK_DUAL_DELTA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_BLACK_DUAL_DELTA_FIELD));
        result.put(PDEResultCollection.GRID_BLACK_DUAL_DELTA, greek);
      }
      if (message.getByName(GRID_BLACK_GAMMA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_BLACK_GAMMA_FIELD));
        result.put(PDEResultCollection.GRID_BLACK_GAMMA, greek);
      }
      if (message.getByName(GRID_BLACK_DUAL_GAMMA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_BLACK_DUAL_GAMMA_FIELD));
        result.put(PDEResultCollection.GRID_BLACK_DUAL_GAMMA, greek);
      }
      if (message.getByName(GRID_BLACK_VEGA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_BLACK_VEGA_FIELD));
        result.put(PDEResultCollection.GRID_BLACK_VEGA, greek);
      }
      if (message.getByName(GRID_BLACK_VANNA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_BLACK_VANNA_FIELD));
        result.put(PDEResultCollection.GRID_BLACK_VANNA, greek);
      }
      if (message.getByName(GRID_BLACK_VOMMA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_BLACK_VOMMA_FIELD));
        result.put(PDEResultCollection.GRID_BLACK_VOMMA, greek);
      }
      if (message.getByName(GRID_DELTA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_DELTA_FIELD));
        result.put(PDEResultCollection.GRID_DELTA, greek);
      }
      if (message.getByName(GRID_DUAL_DELTA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_DUAL_DELTA_FIELD));
        result.put(PDEResultCollection.GRID_DUAL_DELTA, greek);
      }
      if (message.getByName(GRID_GAMMA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_GAMMA_FIELD));
        result.put(PDEResultCollection.GRID_GAMMA, greek);
      }
      if (message.getByName(GRID_DUAL_GAMMA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_DUAL_GAMMA_FIELD));
        result.put(PDEResultCollection.GRID_DUAL_GAMMA, greek);
      }
      if (message.getByName(GRID_VEGA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_VEGA_FIELD));
        result.put(PDEResultCollection.GRID_VEGA, greek);
      }
      if (message.getByName(GRID_VANNA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_VANNA_FIELD));
        result.put(PDEResultCollection.GRID_VANNA, greek);
      }
      if (message.getByName(GRID_VOMMA_FIELD) != null) {
        final double[] greek = deserializer.fieldValueToObject(double[].class, message.getByName(GRID_VOMMA_FIELD));
        result.put(PDEResultCollection.GRID_VOMMA, greek);
      }
      return result;
    }
View Full Code Here

    }
  }

  @Test
  public void testPDEGreeks() {
    final PDEResultCollection pdeGreeks = cycleObject(PDEResultCollection.class, PDE_GREEKS);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_BLACK_DELTA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_BLACK_DELTA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_BLACK_DUAL_DELTA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_BLACK_DUAL_DELTA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_BLACK_GAMMA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_BLACK_GAMMA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_BLACK_DUAL_GAMMA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_BLACK_DUAL_GAMMA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_BLACK_VEGA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_BLACK_VEGA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_BLACK_VANNA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_BLACK_VANNA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_BLACK_VOMMA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_BLACK_VOMMA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_DELTA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_DELTA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_DUAL_DELTA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_DUAL_DELTA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_GAMMA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_GAMMA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_DUAL_GAMMA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_DUAL_GAMMA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_VEGA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_VEGA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_VANNA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_VANNA), 1e-9);
    assertArrayEquals(PDE_GREEKS.getGridGreeks(PDEResultCollection.GRID_VOMMA), pdeGreeks.getGridGreeks(PDEResultCollection.GRID_VOMMA), 1e-9);
  }
View Full Code Here

    final Object greekObject = inputs.getValue(getGreekRequirement(target, surfaceName, surfaceType, xAxis, yAxis, yAxisType,
        forwardCurveCalculationMethod, forwardCurveName, theta, timeSteps, spaceSteps, timeGridBunching, spaceGridBunching, maxMoneyness, h, pdeDirection));
    if (greekObject == null) {
      throw new OpenGammaRuntimeException("Could not get greeks");
    }
    final PDEResultCollection greeks = (PDEResultCollection) greekObject;
    final Object spotFXObject = inputs.getValue(getSpotRequirement(fxOption));
    if (spotFXObject == null) {
      throw new OpenGammaRuntimeException("Could not get spot FX");
    }
    final double[] strikes = greeks.getStrikes();
    final double[] lvPutPips = greeks.getGridGreeks(PDEResultCollection.GRID_PRICE);
    final double[] blackPutPips = greeks.getGridGreeks(PDEResultCollection.GRID_BLACK_PRICE);
    final double spotFX = (Double) spotFXObject;
    final Currency putCurrency = fxOption.getPutCurrency();
    final Currency callCurrency = fxOption.getCallCurrency();
    final double putAmount = fxOption.getPutAmount();
    final double callAmount = fxOption.getCallAmount();
View Full Code Here

      throw new OpenGammaRuntimeException("Grid greeks were null");
    }
    final CurrencyPairs currencyPairs = OpenGammaExecutionContext.getCurrencyPairsSource(executionContext).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
    final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(fxOption.getPutCurrency(), fxOption.getCallCurrency());
    final double strike = getStrike(fxOption, currencyPair);
    final PDEResultCollection gridGreeks = (PDEResultCollection) gridGreeksObject;
    final ComputationTargetSpecification spec = target.toSpecification();
    final Set<ComputedValue> result = new HashSet<ComputedValue>();
    for (final ValueRequirement value : desiredValues) {
      final Greek greek = s_greekNamesToGreeks.get(value.getValueName());
      final String strikeInterpolatorName = value.getConstraint(PROPERTY_RESULT_STRIKE_INTERPOLATOR);
      final Double point = gridGreeks.getPointGreek(greek, strike, Interpolator1DFactory.getInterpolator(strikeInterpolatorName));
      if (point == null) {
        throw new OpenGammaRuntimeException("Grid greeks for " + greek + " were null");
      }
      final ValueSpecification resultSpec = new ValueSpecification(value.getValueName(), spec, value.getConstraints());
      result.add(new ComputedValue(resultSpec, point));
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.greeks.PDEResultCollection$BackingMapGreekIterator

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.