Package com.opengamma.analytics.util.amount

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


   * Tests the toSingleValue method.
   */
  public void toSingleValue() {
    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);
    double amountComputed = surfPlus1.toSingleValue();
    assertEquals("Surface value - single value", amountComputed, value1 + value2, TOLERANCE);
  }
View Full Code Here


   * Test for a sensitivity with only one sensitivity point.
   */
  public void onePoint() {
    final DoublesPair point = new DoublesPair(1.25, 4.0);
    final double alphaValue = 12345.0;
    final SurfaceValue alpha = SurfaceValue.from(point, alphaValue);
    final double betaValue = 4321.0;
    final SurfaceValue beta = SurfaceValue.from(point, betaValue);
    final double rhoValue = 2345.0;
    final SurfaceValue rho = SurfaceValue.from(point, 2345.0);
    final double nuValue = 345.0;
    final SurfaceValue nu = SurfaceValue.from(point, 345.0);
    final PresentValueSABRSensitivityDataBundle onePoint = new PresentValueSABRSensitivityDataBundle(alpha, beta, rho, nu);
    final PresentValueSABRSensitivityDataBundle node = SABRSensitivityNodeCalculator.calculateNodeSensitivities(onePoint, SABR_PARAMETERS);
    final DoublesPair[] nodeExpected = new DoublesPair[4];
    nodeExpected[0] = new DoublesPair(1.0, 2.0);
    nodeExpected[1] = new DoublesPair(1.0, 5.0);
View Full Code Here

   * Test with a sensitivity with only one sensitivity point not in the center.
   */
  public void onePointBorder() {
    final DoublesPair point = new DoublesPair(1.25, 1.5);
    final double alphaValue = 12345.0;
    final SurfaceValue alpha = SurfaceValue.from(point, alphaValue);
    final double betaValue = 4321.0;
    final SurfaceValue beta = SurfaceValue.from(point, betaValue);
    final double rhoValue = 2345.6;
    final SurfaceValue rho = SurfaceValue.from(point, rhoValue);
    final double nuValue = 345.67;
    final SurfaceValue nu = SurfaceValue.from(point, nuValue);
    final PresentValueSABRSensitivityDataBundle onePoint = new PresentValueSABRSensitivityDataBundle(alpha, beta, rho, nu);
    final PresentValueSABRSensitivityDataBundle node = SABRSensitivityNodeCalculator.calculateNodeSensitivities(onePoint, SABR_PARAMETERS);
    final DoublesPair[] nodeExpected = new DoublesPair[4];
    nodeExpected[0] = new DoublesPair(1.0, 1.0);
    nodeExpected[1] = new DoublesPair(1.0, 2.0);
View Full Code Here

  /**
   * Test for a sensitivity with two sensitivity points.
   */
  public void twoPoints() {
    final DoublesPair point1 = new DoublesPair(1.25, 4.0);
    final SurfaceValue alpha1 = SurfaceValue.from(point1, 12345.0);
    final SurfaceValue beta1 = SurfaceValue.from(point1, 4321.0);
    final SurfaceValue rho1 = SurfaceValue.from(point1, 2345.6);
    final SurfaceValue nu1 = SurfaceValue.from(point1, 345.67);
    final DoublesPair point2 = new DoublesPair(5.5, 9.0);
    final SurfaceValue alpha2 = SurfaceValue.from(point2, 2345.0);
    final SurfaceValue beta2 = SurfaceValue.from(point2, 5432.0);
    final SurfaceValue rho2 = SurfaceValue.from(point2, 345.6);
    final SurfaceValue nu2 = SurfaceValue.from(point2, 45.67);
    final PresentValueSABRSensitivityDataBundle onePoint1 = new PresentValueSABRSensitivityDataBundle(alpha1, beta1, rho1, nu1);
    final PresentValueSABRSensitivityDataBundle onePoint2 = new PresentValueSABRSensitivityDataBundle(alpha2, beta2, rho2, nu2);
    final PresentValueSABRSensitivityDataBundle twoPoints = onePoint1.plus(onePoint2);
    final PresentValueSABRSensitivityDataBundle node1 = SABRSensitivityNodeCalculator.calculateNodeSensitivities(onePoint1, SABR_PARAMETERS);
    final PresentValueSABRSensitivityDataBundle node2 = SABRSensitivityNodeCalculator.calculateNodeSensitivities(onePoint2, SABR_PARAMETERS);
View Full Code Here

   */
  public void toDoubleLabelledMatrix2DFull() {
    double[] x = new double[] {0.5, 2.5, 5.0};
    double[] y = new double[] {1.0, 2.0, 5.0, 10.0};
    double[][] vIn = new double[y.length][x.length];
    SurfaceValue surf = new SurfaceValue();
    for (int loopx = 0; loopx < x.length; loopx++) {
      for (int loopy = 0; loopy < y.length; loopy++) {
        vIn[loopy][loopx] = x[loopx] * y[loopy];
        surf.add(new DoublesPair(x[loopx], y[loopy]), vIn[loopy][loopx]);
      }
    }
    DoubleLabelledMatrix2D vOut = SABRCubeUtils.toDoubleLabelledMatrix2D(surf);
    for (int loopx = 0; loopx < x.length; loopx++) {
      for (int loopy = 0; loopy < y.length; loopy++) {
View Full Code Here

   */
  public void toDoubleLabelledMatrix2DPartial() {
    double[] x = new double[] {0.5, 2.5, 5.0};
    double[] y = new double[] {1.0, 2.0, 5.0};
    double[][] vIn = new double[x.length][x.length];
    SurfaceValue surf = new SurfaceValue();
    for (int loopx = 0; loopx < x.length; loopx++) {
      vIn[loopx][loopx] = x[loopx] * y[loopx];
      surf.add(new DoublesPair(x[loopx], y[loopx]), vIn[loopx][loopx]);
    }
    DoubleLabelledMatrix2D vOut = SABRCubeUtils.toDoubleLabelledMatrix2D(surf);
    for (int loopx = 0; loopx < x.length; loopx++) {
      assertEquals("Surface value - toArray", vIn[loopx][loopx], vOut.getValues()[loopx][loopx], TOLERANCE);
    }
View Full Code Here

  @Test
  /**
   * Tests the currency pair and map getters.
   */
  public void getter() {
    SurfaceValue vega = new SurfaceValue();
    final double exp = 1.0;
    final double strike = 0.05;
    final double value = 10000;
    final DoublesPair point = new DoublesPair(exp, strike);
    vega.add(point, value);
    final PresentValueForexBlackVolatilitySensitivity sensi = new PresentValueForexBlackVolatilitySensitivity(CUR_1, CUR_2, SurfaceValue.from(point, value));
    final Pair<Currency, Currency> pair = ObjectsPair.of(CUR_1, CUR_2);
    assertEquals("Currency pair", pair, sensi.getCurrencyPair());
    assertEquals("Vega", vega, sensi.getVega());
  }
View Full Code Here

  public void equalHash() {
    final double exp = 1.0;
    final double strike = 0.05;
    final double value = 10000;
    final DoublesPair point = new DoublesPair(exp, strike);
    SurfaceValue vega = new SurfaceValue();
    vega.add(point, value);
    final PresentValueForexBlackVolatilitySensitivity sensitivities = new PresentValueForexBlackVolatilitySensitivity(CUR_1, CUR_2, vega);
    final SurfaceValue copy = new SurfaceValue();
    for (final Map.Entry<DoublesPair, Double> entry : vega.getMap().entrySet()) {
      copy.add(entry.getKey(), entry.getValue());
    }
    assertTrue(sensitivities.equals(new PresentValueForexBlackVolatilitySensitivity(CUR_1, CUR_2, copy)));
    vega = new SurfaceValue();
    final SurfaceValue newVega = new SurfaceValue();
    newVega.add(point, value / 2.0);
    PresentValueForexBlackVolatilitySensitivity other = new PresentValueForexBlackVolatilitySensitivity(CUR_1, CUR_2, newVega);
    other.add(point, value / 2.0);
    assertTrue(other.equals(sensitivities));
    assertEquals(other.hashCode(), sensitivities.hashCode());
    PresentValueForexBlackVolatilitySensitivity modified;
View Full Code Here

    final NormalSTIRFuturesSmileProviderDiscount blackPlus = new NormalSTIRFuturesSmileProviderDiscount(MULTICURVES, normalParameterPlus, EURIBOR3M);
    final NormalSTIRFuturesSmileProviderDiscount blackMinus = new NormalSTIRFuturesSmileProviderDiscount(MULTICURVES, NormalParameterMinus, EURIBOR3M);
    final double pricePlus = METHOD_SECURITY_OPTION_NORMAL.price(OPTION_ERU2, blackPlus);
    final double priceMinus = METHOD_SECURITY_OPTION_NORMAL.price(OPTION_ERU2, blackMinus);
    final double priceSensiExpected = (pricePlus - priceMinus) / (2 * VOL_SHIFT);
    final SurfaceValue priceSensiComputed = METHOD_SECURITY_OPTION_NORMAL.priceNormalSensitivity(OPTION_ERU2, NORMAL_MULTICURVES);
    final DoublesPair point = new DoublesPair(OPTION_ERU2.getExpirationTime(), STRIKE);
    assertEquals("Future option with Black volatilities: option security vol sensi", priceSensiExpected, priceSensiComputed.getMap().get(point), TOLERANCE_PRICE_DELTA);
    assertEquals("Future option with Black volatilities: option security vol sensi", 1, priceSensiComputed.getMap().size());
  }
View Full Code Here

  @Test
  /**
   * The sensitivity is added twice to the same point and it is checked that the value is twice the initial value.
   */
  public void addSamePoint() {
    SurfaceValue vega = new SurfaceValue();
    final double exp = 1.0;
    final double strike = 0.05;
    final double value = 10000;
    final DoublesPair point = new DoublesPair(exp, strike);
    vega.add(point, 2 * value);
    final PresentValueForexBlackVolatilitySensitivity first = new PresentValueForexBlackVolatilitySensitivity(CUR_1, CUR_2, vega);
    vega = new SurfaceValue();
    vega.add(point, value);
    PresentValueForexBlackVolatilitySensitivity second = new PresentValueForexBlackVolatilitySensitivity(CUR_1, CUR_2, vega);
    second.add(point, value);
    assertEquals(first, second);
  }
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.