Examples of VolatilitySurface


Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

    final double t = DateUtils.getDifferenceInYears(now, expiry.getExpiry());
    final double b = discountCurve.getInterestRate(t); // TODO cost-of-carry model
    @SuppressWarnings("unused")
    final StandardOptionDataBundle data = new StandardOptionDataBundle(discountCurve, b, null, spotPrice, now);
    // TODO Map<OptionDefinition, Double> of options that will be used to form surface
    final VolatilitySurface surface = null; // TODO
    final ValueSpecification specification = createResultSpecification(target);
    final ComputedValue result = new ComputedValue(specification, surface);
    return Collections.singleton(result);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

@Test(groups = TestGroup.UNIT)
public class ModelVolatilitySurfaceTest extends AnalyticsTestBase {

  @Test
  public void testConstantVolatilitySurface() {
    final VolatilitySurface vs1 = new VolatilitySurface(ConstantDoublesSurface.from(0.2));
    final VolatilitySurface vs2 = cycleObject(VolatilitySurface.class, vs1);
    assertEquals(vs1, vs2);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

    final Map<DoublesPair, Double> data = new HashMap<>();
    data.put(Pair.of(0., 1.), sigma);
    data.put(Pair.of(1., 0.), sigma);
    data.put(Pair.of(0., 0.), sigma);
    data.put(Pair.of(1., 1.), sigma);
    final VolatilitySurface vs1 = new VolatilitySurface(InterpolatedDoublesSurface.from(data, interpolator));
    final VolatilitySurface vs2 = cycleObject(VolatilitySurface.class, vs1);
    assertEquals(vs1, vs2);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

    assertEquals(other.hashCode(), DATA.hashCode());
    other = new GeneralLogNormalOptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(0.02)), DRIFT_SURFACE, VOLATILITY_SURFACE, SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new GeneralLogNormalOptionDataBundle(YIELD, new DriftSurface(ConstantDoublesSurface.from(0.01)), VOLATILITY_SURFACE, SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new GeneralLogNormalOptionDataBundle(YIELD, DRIFT_SURFACE, new VolatilitySurface(ConstantDoublesSurface.from(0.4)), SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new GeneralLogNormalOptionDataBundle(YIELD, DRIFT_SURFACE, VOLATILITY_SURFACE, SPOT + 1, DATE);
    assertFalse(other.equals(DATA));
    other = new GeneralLogNormalOptionDataBundle(YIELD, DRIFT_SURFACE, VOLATILITY_SURFACE, SPOT, DATE.plusDays(1));
    assertFalse(other.equals(DATA));
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

  public void testBuilders() {
    final ZonedDateTime newDate = DATE.plusDays(1);
    assertEquals(DATA.withDate(newDate), new GeneralLogNormalOptionDataBundle(YIELD, DRIFT_SURFACE, VOLATILITY_SURFACE, SPOT, newDate));
    final YieldCurve newCurve = YieldCurve.from(ConstantDoublesCurve.from(0.05));
    assertEquals(DATA.withInterestRateCurve(newCurve), new GeneralLogNormalOptionDataBundle(newCurve, DRIFT_SURFACE, VOLATILITY_SURFACE, SPOT, DATE));
    final VolatilitySurface newSurface = new VolatilitySurface(ConstantDoublesSurface.from(0.9));
    assertEquals(DATA.withVolatilitySurface(newSurface), new GeneralLogNormalOptionDataBundle(YIELD, DRIFT_SURFACE, newSurface, SPOT, DATE));
    final DriftSurface newDrift = new DriftSurface(ConstantDoublesSurface.from(0.9));
    assertEquals(DATA.withDriftSurface(newDrift), new GeneralLogNormalOptionDataBundle(YIELD, newDrift, VOLATILITY_SURFACE, SPOT, DATE));
    final double newSpot = SPOT + 1;
    assertEquals(DATA.withSpot(newSpot), new GeneralLogNormalOptionDataBundle(YIELD, DRIFT_SURFACE, VOLATILITY_SURFACE, newSpot, DATE));
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

    other = new OptionDataBundle(DATA);
    assertEquals(other, DATA);
    assertEquals(other.hashCode(), DATA.hashCode());
    other = new OptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(0.06)), SURFACE, DATE);
    assertFalse(other.equals(DATA));
    other = new OptionDataBundle(CURVE, new VolatilitySurface(ConstantDoublesSurface.from(0.6)), DATE);
    assertFalse(other.equals(DATA));
    other = new OptionDataBundle(CURVE, SURFACE, DATE.plusDays(1));
    assertFalse(other.equals(DATA));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

  public void testBuilders() {
    final ZonedDateTime newDate = DATE.plusDays(1);
    assertEquals(DATA.withDate(newDate), new OptionDataBundle(CURVE, SURFACE, newDate));
    final YieldCurve newCurve = YieldCurve.from(ConstantDoublesCurve.from(0.05));
    assertEquals(DATA.withInterestRateCurve(newCurve), new OptionDataBundle(newCurve, SURFACE, DATE));
    final VolatilitySurface newSurface = new VolatilitySurface(ConstantDoublesSurface.from(0.9));
    assertEquals(DATA.withVolatilitySurface(newSurface), new OptionDataBundle(CURVE, newSurface, DATE));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

    assertEquals(other.hashCode(), DATA.hashCode());
    other = new FXOptionDataBundle(FOREIGN, FOREIGN, SIGMA, SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new FXOptionDataBundle(DOMESTIC, DOMESTIC, SIGMA, SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new FXOptionDataBundle(DOMESTIC, FOREIGN, new VolatilitySurface(ConstantDoublesSurface.from(0.2)), SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new FXOptionDataBundle(DOMESTIC, FOREIGN, SIGMA, SPOT + 1, DATE);
    assertFalse(other.equals(DATA));
    other = new FXOptionDataBundle(DOMESTIC, FOREIGN, SIGMA, SPOT, DATE.plusDays(2));
    assertFalse(other.equals(DATA));
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final ComputedValue input = inputs.getAllValues().iterator().next();
    final ValueSpecification inputSpec = input.getSpecification();
    VolatilitySurface volatilitySurface = (VolatilitySurface) input.getValue();
    final ValueProperties.Builder properties = createValueProperties(inputSpec);
    final String shift = desiredValues.iterator().next().getConstraint(SHIFT);
    properties.with(SHIFT, shift);
    try {
      final double shiftAmount = Double.parseDouble(shift);
      volatilitySurface = volatilitySurface.withConstantMultiplicativeShift(shiftAmount);
    } catch (NumberFormatException e) {
      s_logger.error("Volatility surface shift not valid - {}", shift);
    }
    return Collections.singleton(new ComputedValue(new ValueSpecification(inputSpec.getValueName(), inputSpec.getTargetSpecification(), properties.get()), volatilitySurface));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.volatility.surface.VolatilitySurface

    assertEquals(other.hashCode(), DATA.hashCode());
    other = new GeneralNormalOptionDataBundle(YieldCurve.from(ConstantDoublesCurve.from(0.02)), DRIFT_SURFACE, VOLATILITY_SURFACE, SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new GeneralNormalOptionDataBundle(YIELD, new DriftSurface(ConstantDoublesSurface.from(0.01)), VOLATILITY_SURFACE, SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new GeneralNormalOptionDataBundle(YIELD, DRIFT_SURFACE, new VolatilitySurface(ConstantDoublesSurface.from(0.4)), SPOT, DATE);
    assertFalse(other.equals(DATA));
    other = new GeneralNormalOptionDataBundle(YIELD, DRIFT_SURFACE, VOLATILITY_SURFACE, SPOT + 1, DATE);
    assertFalse(other.equals(DATA));
    other = new GeneralNormalOptionDataBundle(YIELD, DRIFT_SURFACE, VOLATILITY_SURFACE, SPOT, DATE.plusDays(1));
    assertFalse(other.equals(DATA));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.