Package com.opengamma.analytics.math.surface

Examples of com.opengamma.analytics.math.surface.FunctionalDoublesSurface


        result.put("ys", yLabels);
        result.put("surface", surface);
        result.put("missingValues", missingValues);
      }
    } else if (value.getSurface() instanceof FunctionalDoublesSurface) {
      FunctionalDoublesSurface functional = (FunctionalDoublesSurface) value.getSurface();
      result.put("xCount", 20);
      result.put("yCount", 20);
      if (mode == ConversionMode.FULL) {
        String[] xLabels = new String[20];
        String[] yLabels = new String[20];
        double[][] surface = new double[20][20];
        boolean[][] missingValues = new boolean[20][20];
       
        double[] expiries = {0.1, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3., 4., 5., 6., 7., 8., 9., 10., 12., 15., 20., 30.};
        for (int i = 0; i < 20; i++) {
          double t = expiries[i];
          xLabels[i] = LABEL_FORMAT.format(t);
          double m = .1;
          for (int j = 0; j < 20; j++) {
            if (i == 0) {
              yLabels[j] = LABEL_FORMAT.format(m);
            }
            surface[j][i] = 100 * functional.getZValue(t, m);
            m += 0.1;
          }
         
        }
        result.put("xs", xLabels);
View Full Code Here


  private static final double Z_MIN = 0;
  private static final double Z_MAX = 200;

  @Test
  public void testObject() {
    final FunctionalDoublesSurface f = getSurface();
    final VolatilitySurface vol = new VolatilitySurface(f);
    final FunctionalVolatilitySurfaceData data = new FunctionalVolatilitySurfaceData(vol, X_LABEL, X_MIN, X_MAX, NX, Y_LABEL,
        Y_MIN, Y_MAX, NY, Z_MIN, Z_MAX);
    assertEquals(X_LABEL, data.getXLabel());
    assertEquals(X_MIN, data.getXMinimum());
    assertEquals(X_MAX, data.getXMaximum());
    assertEquals(NX, data.getNXSamples());
    assertEquals(Y_LABEL, data.getYLabel());
    assertEquals(Y_MIN, data.getYMinimum());
    assertEquals(Y_MAX, data.getYMaximum());
    assertEquals(NY, data.getNYSamples());
    assertEquals(Z_MIN, data.getZMinimum());
    assertEquals(Z_MAX, data.getZMaximum());
    FunctionalVolatilitySurfaceData other = new FunctionalVolatilitySurfaceData(vol, X_LABEL, X_MIN, X_MAX, NX, Y_LABEL, Y_MIN, Y_MAX, NY, Z_MIN, Z_MAX);
    assertEquals(data, other);
    final FunctionalDoublesSurface otherF = FunctionalDoublesSurface.from(new Function<Double, Double>() {

      @Override
      public Double evaluate(final Double... x) {
        return 3 * x[0] - 5 * x[1];
      }
View Full Code Here

      }
    };

    //PDEUtilityTools.printSurface("start", surfaceStrike.getSurface(), 0.01, 2.0, 0.3, 3.0);

    final FunctionalDoublesSurface s = FunctionalDoublesSurface.from(temp2);
    PDEUtilityTools.printSurface("fitted", s, 0.01, 2.0, 0.3, 3.0);

    final DupireLocalVolatilityCalculator dCal = new DupireLocalVolatilityCalculator();
    final LocalVolatilitySurfaceStrike lv = dCal.getLocalVolatility(new BlackVolatilitySurfaceStrike(s), fwdCurve);
    PDEUtilityTools.printSurface("lv", lv.getSurface(), 0.01, 2.0, 0.3, 3.0);
View Full Code Here

    cycleObject(Surface.class, s);
  }

  @Test
  public void testFunctionalSurface1() {
    final FunctionalDoublesSurface s1 = FunctionalDoublesSurface.from(new TestStatelessFunction().getSurface(3., 4.));
    final Surface<Double, Double, Double> s2 = cycleObject(Surface.class, s1);
    assertSurfaceEquals(s1, s2);
  }
View Full Code Here

    assertSurfaceEquals(s1, s2);
  }

  @Test
  public void testFunctionalSurface2() {
    final FunctionalDoublesSurface s1 = FunctionalDoublesSurface.from(new TestStatefulFunction(true, 3).getSurface(5., 6.));
    final Surface<Double, Double, Double> s2 = cycleObject(Surface.class, s1);
    assertSurfaceEquals(s1, s2);
  }
View Full Code Here

        final double f = x[1];
        return BlackFormulaRepository.dualGamma(1.0, f, t, sigma);
      }
    };

    final FunctionalDoublesSurface density = FunctionalDoublesSurface.from(densityFunc);
    PDEUtilityTools.printSurface("density surface", density, 0.01, 10, 0.0, 4.0, 200, 100);

  }
View Full Code Here

        return dens;
      }
    };

    final FunctionalDoublesSurface density = FunctionalDoublesSurface.from(densityFunc);
    PDEUtilityTools.printSurface("density surface", density, 0.01, 10, 0.01, 5.0, 200, 100);

  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.surface.FunctionalDoublesSurface

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.