Package com.opengamma.analytics.financial.greeks

Examples of com.opengamma.analytics.financial.greeks.GreekResultCollection


    Validate.notNull(definition, "definition");
    Validate.notNull(data, "data");
    Validate.notNull(requiredGreeks, "required greeks");
    Validate.notEmpty(requiredGreeks, "required greeks");
    final Function1D<U, Double> pricingFunction = getPricingFunction(definition);
    final GreekResultCollection results = new GreekResultCollection();
    for (final Greek greek : requiredGreeks) {
      if (greek != Greek.FAIR_PRICE) {
        s_logger.warn("Can only calculate price for two-asset options, not calculating " + greek);
      } else {
        results.put(greek, pricingFunction.evaluate(data));
      }
    }
    return results;
  }
View Full Code Here


public class GreekToValueGreekConverter extends Function1D<GreekDataBundle, Map<ValueGreek, Double>> {

  @Override
  public Map<ValueGreek, Double> evaluate(final GreekDataBundle data) {
    ArgumentChecker.notNull(data, "data");
    final GreekResultCollection greeks = data.getGreekResults();
    final Map<ValueGreek, Double> riskFactors = new HashMap<>();
    final Map<UnderlyingType, Double> underlyingData = data.getUnderlyingData();
    final OptionTradeData tradeData = data.getOptionTradeData();
    for (final Pair<Greek, Double> entry : greeks) {
      final Greek key = entry.getFirst();
View Full Code Here

    FFT_MODEL.getGreeks(ITM_CALL, BLACK_DATA, Sets.newHashSet(Greek.DELTA, Greek.GAMMA));
  }

  @Test
  public void testPricing() {
    GreekResultCollection fftPrice = FFT_MODEL.getGreeks(ITM_CALL, BLACK_DATA, GREEKS);
    GreekResultCollection bsmPrice = BSM_MODEL.getGreeks(ITM_CALL, BSM_DATA, GREEKS);
    assertEquals(fftPrice.size(), 1);
    assertEquals(fftPrice.get(Greek.FAIR_PRICE), bsmPrice.get(Greek.FAIR_PRICE), EPS);
    fftPrice = FFT_MODEL.getGreeks(OTM_CALL, BLACK_DATA, GREEKS);
    bsmPrice = BSM_MODEL.getGreeks(OTM_CALL, BSM_DATA, GREEKS);
    assertEquals(fftPrice.size(), 1);
    assertEquals(fftPrice.get(Greek.FAIR_PRICE), bsmPrice.get(Greek.FAIR_PRICE), EPS);
    fftPrice = FFT_MODEL.getGreeks(OTM_PUT, BLACK_DATA, GREEKS);
    bsmPrice = BSM_MODEL.getGreeks(OTM_PUT, BSM_DATA, GREEKS);
    assertEquals(fftPrice.size(), 1);
    assertEquals(fftPrice.get(Greek.FAIR_PRICE), bsmPrice.get(Greek.FAIR_PRICE), EPS);
    fftPrice = FFT_MODEL.getGreeks(ITM_PUT, BLACK_DATA, GREEKS);
    bsmPrice = BSM_MODEL.getGreeks(ITM_PUT, BSM_DATA, GREEKS);
    assertEquals(fftPrice.size(), 1);
    assertEquals(fftPrice.get(Greek.FAIR_PRICE), bsmPrice.get(Greek.FAIR_PRICE), EPS);
  }
View Full Code Here

    FOURIER_MODEL1.getGreeks(ITM_CALL, BLACK_DATA, Sets.newHashSet(Greek.DELTA, Greek.GAMMA));
  }

  @Test
  public void testPricing() {
    GreekResultCollection fourierPrice = FOURIER_MODEL1.getGreeks(ITM_CALL, BLACK_DATA, GREEKS);
    double bsmPrice = BSM_MODEL.getGreeks(ITM_CALL, BSM_DATA, GREEKS).get(Greek.FAIR_PRICE);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL2.getGreeks(ITM_CALL, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL3.getGreeks(ITM_CALL, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL4.getGreeks(ITM_CALL, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);

    fourierPrice = FOURIER_MODEL1.getGreeks(OTM_CALL, BLACK_DATA, GREEKS);
    bsmPrice = BSM_MODEL.getGreeks(OTM_CALL, BSM_DATA, GREEKS).get(Greek.FAIR_PRICE);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL2.getGreeks(OTM_CALL, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL3.getGreeks(OTM_CALL, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL4.getGreeks(OTM_CALL, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);

    fourierPrice = FOURIER_MODEL1.getGreeks(ITM_PUT, BLACK_DATA, GREEKS);
    bsmPrice = BSM_MODEL.getGreeks(ITM_PUT, BSM_DATA, GREEKS).get(Greek.FAIR_PRICE);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL2.getGreeks(ITM_PUT, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL3.getGreeks(ITM_PUT, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL4.getGreeks(ITM_PUT, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);

    fourierPrice = FOURIER_MODEL1.getGreeks(OTM_PUT, BLACK_DATA, GREEKS);
    bsmPrice = BSM_MODEL.getGreeks(OTM_PUT, BSM_DATA, GREEKS).get(Greek.FAIR_PRICE);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL2.getGreeks(OTM_PUT, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL3.getGreeks(OTM_PUT, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
    fourierPrice = FOURIER_MODEL4.getGreeks(OTM_PUT, BLACK_DATA, GREEKS);
    assertEquals(fourierPrice.size(), 1);
    assertEquals(fourierPrice.get(Greek.FAIR_PRICE), bsmPrice, EPS);
  }
View Full Code Here

    for (int i = 0; i < n; i++) {
      k[i] = prices[i][0];
      price[i] = prices[i][1];
    }
    final double fairValue = INTERPOLATOR.interpolate(INTERPOLATOR.getDataBundleFromSortedArrays(k, price), definition.getStrike());
    final GreekResultCollection result = new GreekResultCollection();
    result.put(Greek.FAIR_PRICE, fairValue);
    return result;
  }
View Full Code Here

    }
    final ZonedDateTime date = dataBundle.getDate();
    final EuropeanVanillaOption option = EuropeanVanillaOption.fromDefinition(definition, date);
    final BlackFunctionData data = BlackFunctionData.fromDataBundle(dataBundle, definition);
    final double price = _pricer.price(data, option, _characteristicExponent, _alpha, _limitTolerance, _useVarianceReduction);
    final GreekResultCollection result = new GreekResultCollection();
    result.put(Greek.FAIR_PRICE, price);
    return result;
  }
View Full Code Here

public class GreekToPositionGreekConverter extends Function1D<GreekDataBundle, Map<PositionGreek, Double>> {

  @Override
  public Map<PositionGreek, Double> evaluate(final GreekDataBundle data) {
    ArgumentChecker.notNull(data, "Risk factor data bundle");
    final GreekResultCollection greeks = data.getGreekResults();
    final Map<PositionGreek, Double> riskFactors = new HashMap<>();
    PositionGreek positionGreek;
    for (final Pair<Greek, Double> entry : greeks) {
      positionGreek = new PositionGreek(entry.getFirst());
      riskFactors.put(positionGreek, entry.getSecond() * data.getOptionTradeData().getNumberOfContracts());
 
View Full Code Here

        s_logger.warn("Can only produce fair price");
      }
    } else {
      throw new IllegalArgumentException("Can only produce fair price");
    }
    final GreekResultCollection greeks = new GreekResultCollection();
    final Function1D<U, Double> price = getPricingFunction(definition);
    greeks.put(Greek.FAIR_PRICE, price.evaluate(data));
    return greeks;
  }
View Full Code Here

      @SuppressWarnings("synthetic-access")
      @Override
      public Double evaluate(final StandardOptionDataBundle data) {
        Validate.notNull(data);
        final GreekResultCollection bsmResult = BSM.getGreeks(definition, data, PRICE);
        final double bsmPrice = bsmResult.get(Greek.FAIR_PRICE);
        final double s = data.getSpot();
        final double k = definition.getStrike();
        final double t = definition.getTimeToExpiry(data.getDate());
        final double r = data.getInterestRate(t);
        final double b = data.getCostOfCarry();
View Full Code Here

    return new Function1D<Double, Double>() {

      @SuppressWarnings("synthetic-access")
      @Override
      public Double evaluate(final Double x) {
        final GreekResultCollection bsmPrice = BSM.getGreeks(definition, data.withSpot(x), PRICE);
        final double price = bsmPrice.get(Greek.FAIR_PRICE);
        return phi * (df * NORMAL.getCDF(phi * getD1(x, k, t, sigma, b)) + lambda * (phi * (x - k) - price) / x - 1);
      }

    };
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.financial.greeks.GreekResultCollection

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.