Package com.opengamma.analytics.util.amount

Examples of com.opengamma.analytics.util.amount.SurfaceValue


    final EuropeanVanillaOption option = new EuropeanVanillaOption(strike, expiryTime, !optionForex.isCall());
    final double[] priceAdjoint = BLACK_FUNCTION.getPriceAdjoint(option, dataBlack);
    // Backward sweep
    final double volatilitySensitivityValue = priceAdjoint[2] * Math.abs(optionForex.getUnderlyingNDF().getNotionalCurrency1()) * (optionForex.isLong() ? 1.0 : -1.0);
    final DoublesPair point = DoublesPair.of(optionForex.getExpiryTime(), (optionForex.getCurrency1() == smile.getCurrencyPair().getFirst()) ? strike : 1.0 / strike);
    final SurfaceValue result = SurfaceValue.from(point, volatilitySensitivityValue);
    final PresentValueForexBlackVolatilitySensitivity sensi = new PresentValueForexBlackVolatilitySensitivity(optionForex.getCurrency1(), optionForex.getCurrency2(), result);
    return sensi;
  }
View Full Code Here


    //    price *= Math.abs(optionForex.getUnderlyingForex().getPaymentCurrency1().getAmount()) * (optionForex.isLong() ? 1.0 : -1.0);
    final double[] vegaReference = new double[3];
    vegaReference[0] = x[0] * vegaSmile[0];
    vegaReference[2] = x[2] * vegaSmile[2];
    vegaReference[1] = vega[1] - x[0] * vega[0] - x[2] * vega[2];
    final SurfaceValue result = new SurfaceValue();
    for (int loopvv = 0; loopvv < 3; loopvv++) {
      final DoublesPair point = DoublesPair.of(optionForex.getTimeToExpiry(), strikesVV[loopvv]);
      result.add(point, vegaReference[loopvv] * Math.abs(optionForex.getUnderlyingForex().getPaymentCurrency1().getAmount()) * (optionForex.isLong() ? 1.0 : -1.0));
    }
    final PresentValueForexBlackVolatilitySensitivity sensi = new PresentValueForexBlackVolatilitySensitivity(optionForex.getUnderlyingForex().getCurrency1(), optionForex.getUnderlyingForex()
        .getCurrency2(), result);
    // TODO: Review when the currency order is not in the standard order.
    return sensi;
View Full Code Here

   * Constructor with empty sensitivity.
   * @param generatorSwap The standard swap generator for which the volatility surface is valid.
   */
  public PresentValueBlackSwaptionSensitivity(final GeneratorInstrument<GeneratorAttributeIR> generatorSwap) {
    ArgumentChecker.notNull(generatorSwap, "Swap generator");
    _sensitivity = new SurfaceValue();
    _generatorSwap = generatorSwap;
  }
View Full Code Here

    final double[] priceAdjoint = BLACK_FUNCTION.getPriceAdjoint(optionForex, dataBlack);
    final double volatilitySensitivityValue = priceAdjoint[2] * Math.abs(optionForex.getUnderlyingForex().getPaymentCurrency1().getAmount()) * (optionForex.isLong() ? 1.0 : -1.0);
    final DoublesPair point = DoublesPair.of(optionForex.getTimeToExpiry(),
        (optionForex.getCurrency1() == black.getCurrencyPair().getFirst()) ? optionForex.getStrike() : 1.0 / optionForex.getStrike());
    // Implementation note: The strike should be in the same currency order as the input data.
    final SurfaceValue result = SurfaceValue.from(point, volatilitySensitivityValue);
    final PresentValueForexBlackVolatilitySensitivity sensi = new PresentValueForexBlackVolatilitySensitivity(optionForex.getUnderlyingForex().getCurrency1(), optionForex.getUnderlyingForex()
        .getCurrency2(), result);
    return sensi;
  }
View Full Code Here

    @Override
    public PresentValueForexBlackVolatilitySensitivity buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final Currency firstCurrency = Currency.of(message.getString(FIRST_CURRENCY_FIELD_NAME));
      final Currency secondCurrency = Currency.of(message.getString(SECOND_CURRENCY_FIELD_NAME));
      final SurfaceValue vega = new SurfaceValue();
      final List<FudgeField> vegaEntryFields = message.getAllByName(VEGA_ENTRY_NAME);
      for (int i = 0; i < vegaEntryFields.size(); i++) {
        final double time = ((FudgeMsg) vegaEntryFields.get(i).getValue()).getDouble(TIME_FIELD_NAME);
        final double strike = ((FudgeMsg) vegaEntryFields.get(i).getValue()).getDouble(STRIKE_FIELD_NAME);
        final Double vegaValue = ((FudgeMsg) vegaEntryFields.get(i).getValue()).getDouble(VEGA_FIELD_NAME);
        vega.add(DoublesPair.of(time, strike), vegaValue);
      }
      return new PresentValueForexBlackVolatilitySensitivity(firstCurrency, secondCurrency, vega);
    }
View Full Code Here

    @Override
    protected void buildMessage(final FudgeSerializer serializer, final MutableFudgeMsg message, final PresentValueForexBlackVolatilitySensitivity object) {
      final Pair<Currency, Currency> currencies = object.getCurrencyPair();
      message.add(FIRST_CURRENCY_FIELD_NAME, currencies.getFirst().getCode());
      message.add(SECOND_CURRENCY_FIELD_NAME, currencies.getSecond().getCode());
      final SurfaceValue vegas = object.getVega();
      final HashMap<DoublesPair, Double> map = vegas.getMap();
      for (final Map.Entry<DoublesPair, Double> entry : map.entrySet()) {
        final MutableFudgeMsg perEntryMessage = serializer.newMessage();
        perEntryMessage.add(TIME_FIELD_NAME, entry.getKey().first);
        perEntryMessage.add(STRIKE_FIELD_NAME, entry.getKey().second);
        perEntryMessage.add(VEGA_FIELD_NAME, entry.getValue());
View Full Code Here

  private static final double TOLERANCE = 1.0E-10;

  @Test
  public void constructor() {
    SurfaceValue surf0 = new SurfaceValue();
    assertEquals("Surface value - constructor", 0, surf0.getMap().size());
    DoublesPair point1 = new DoublesPair(1.0, 2.0);
    double value1 = 2345.678;
    SurfaceValue surf1 = SurfaceValue.from(point1, value1);
    assertEquals("Surface value - constructor", 1, surf1.getMap().size());
    assertTrue("Surface value - constructor", surf1.getMap().containsKey(point1));
    assertEquals("Surface value - constructor", value1, surf1.getMap().get(point1), TOLERANCE);
  }
View Full Code Here

  @Test
  public void plus() {
    DoublesPair point1 = new DoublesPair(1.0, 2.0);
    double value1 = 2345.678;
    SurfaceValue surf1 = SurfaceValue.from(point1, value1);
    DoublesPair point2 = new DoublesPair(2.0, Math.PI);
    double value2 = 10 * Math.E;
    SurfaceValue surfPlus1 = SurfaceValue.plus(surf1, point2, value2);
    assertEquals("Surface value - plus", 2, surfPlus1.getMap().size());
    assertTrue("Surface value - plus", surfPlus1.getMap().containsKey(point1));
    assertTrue("Surface value - plus", surfPlus1.getMap().containsKey(point2));
    assertEquals("Surface value - plus", value1, surfPlus1.getMap().get(point1), TOLERANCE);
    assertEquals("Surface value - plus", value2, surfPlus1.getMap().get(point2), TOLERANCE);
    SurfaceValue surf2 = SurfaceValue.from(point2, value2);
    SurfaceValue surfPlus2 = SurfaceValue.plus(surf1, surf2);
    assertEquals("Surface value - plus", 2, surfPlus2.getMap().size());
    assertTrue("Surface value - plus", surfPlus2.getMap().containsKey(point1));
    assertTrue("Surface value - plus", surfPlus2.getMap().containsKey(point2));
    assertEquals("Surface value - plus", value1, surfPlus2.getMap().get(point1), TOLERANCE);
    assertEquals("Surface value - plus", value2, surfPlus2.getMap().get(point2), TOLERANCE);
    assertTrue("Surface value - plus", SurfaceValue.compare(SurfaceValue.plus(surfPlus2, surfPlus2), SurfaceValue.multiplyBy(surfPlus2, 2), TOLERANCE));
    DoublesPair point3 = new DoublesPair(2.0, 2.0);
    double value3 = 12.345;
    SurfaceValue surf3 = SurfaceValue.from(point3, value3);
    assertTrue("Surface value - plus", SurfaceValue.compare(SurfaceValue.plus(surfPlus2, point3, value3), SurfaceValue.plus(surfPlus2, surf3), TOLERANCE));
  }
View Full Code Here

  @Test
  public void multipliedBy() {
    DoublesPair point1 = new DoublesPair(1.0, 2.0);
    double value1 = 2345.678;
    SurfaceValue surf1 = SurfaceValue.from(point1, value1);
    double factor = 3;
    SurfaceValue surf2 = SurfaceValue.multiplyBy(surf1, factor);
    SurfaceValue surf3 = SurfaceValue.from(point1, factor * value1);
    assertTrue("Surface value - multipliedBy", SurfaceValue.compare(surf3, surf2, TOLERANCE));
  }
View Full Code Here

  @Test
  public void compare() {
    DoublesPair point1 = new DoublesPair(1.0, 2.0);
    double value1 = 2345.678;
    SurfaceValue surf1 = SurfaceValue.from(point1, value1);
    DoublesPair point2 = new DoublesPair(2.0, Math.PI);
    double value2 = 10 * Math.E;
    SurfaceValue surf2 = SurfaceValue.from(point2, value2);
    SurfaceValue surfPlus1 = SurfaceValue.plus(surf1, surf2);
    SurfaceValue surfPlus2 = SurfaceValue.plus(surf2, surf1);
    assertTrue("Surface value - compare", SurfaceValue.compare(surfPlus1, surfPlus2, TOLERANCE));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.util.amount.SurfaceValue

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.