Package com.opengamma.financial.analytics.volatility.surface

Examples of com.opengamma.financial.analytics.volatility.surface.VolatilitySurfaceSpecification


    }
    final String name = message.getString("name");
    final FudgeField field = message.getByName("surfaceInstrumentProvider");
    final SurfaceInstrumentProvider<?, ?> surfaceInstrumentProvider = (SurfaceInstrumentProvider<?, ?>) deserializer.fieldValueToObject(field);

    return new VolatilitySurfaceSpecification(name, target, quoteType, quoteUnits, exerciseType, surfaceInstrumentProvider);
  }
View Full Code Here


      public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
          final Set<ValueRequirement> desiredValues) {
        final ValueRequirement desiredValue = desiredValues.iterator().next();
        final String surfaceName = desiredValue.getConstraint(ValuePropertyNames.SURFACE);
        final String instrumentType = desiredValue.getConstraint(InstrumentTypeProperties.PROPERTY_SURFACE_INSTRUMENT_TYPE);
        VolatilitySurfaceSpecification specification = null;
        if (instrumentType.equals(InstrumentTypeProperties.FOREX)) {
          final UnorderedCurrencyPair pair = UnorderedCurrencyPair.of(target.getUniqueId());
          String name = pair.getFirstCurrency().getCode() + pair.getSecondCurrency().getCode();
          String fullSpecificationName = surfaceName + "_" + name;
          specification = source.getSpecification(fullSpecificationName, instrumentType);
          if (specification == null) {
            name = pair.getSecondCurrency().getCode() + pair.getFirstCurrency().getCode();
            fullSpecificationName = surfaceName + "_" + name;
            specification = source.getSpecification(fullSpecificationName, instrumentType);
            if (specification == null) {
              throw new OpenGammaRuntimeException("Could not get volatility surface specification named " + fullSpecificationName);
            }
          }
        } else if (instrumentType.equals(InstrumentTypeProperties.EQUITY_OPTION) || instrumentType.equals(InstrumentTypeProperties.EQUITY_FUTURE_OPTION)) {
          final String fullSpecificationName = surfaceName + "_" + EquitySecurityUtils.getTrimmedTarget(UniqueId.parse(target.getValue().toString()));
          specification = source.getSpecification(fullSpecificationName, instrumentType);
          if (specification == null) {
            throw new OpenGammaRuntimeException("Could not get volatility surface specification named " + fullSpecificationName + " for instrument type " + instrumentType);
          }
        } else {
          final String fullSpecificationName = surfaceName + "_" + target.getUniqueId().getValue();
          specification = source.getSpecification(fullSpecificationName, instrumentType);
          if (specification == null) {
            throw new OpenGammaRuntimeException("Could not get volatility surface specification named " + fullSpecificationName + " for instrument type " + instrumentType);
          }
        }
        @SuppressWarnings("synthetic-access")
        final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.VOLATILITY_SURFACE_SPEC, target.toSpecification(),
            createValueProperties()
            .with(ValuePropertyNames.SURFACE, surfaceName)
            .with(InstrumentTypeProperties.PROPERTY_SURFACE_INSTRUMENT_TYPE, instrumentType)
            .with(SurfaceAndCubePropertyNames.PROPERTY_SURFACE_QUOTE_TYPE, specification.getSurfaceQuoteType())
            .with(SurfaceAndCubePropertyNames.PROPERTY_SURFACE_UNITS, specification.getQuoteUnits()).get());
        return Collections.singleton(new ComputedValue(spec, specification));
      }

      @Override
      public ComputationTargetType getTargetType() {
View Full Code Here

public class VolatilitySurfaceSpecificationFudgeEncodingTest extends FinancialTestBase {

  @Test
  public void testSwaptionCycle() {
    BloombergSwaptionVolatilitySurfaceInstrumentProvider instrumentProvider = new BloombergSwaptionVolatilitySurfaceInstrumentProvider("US", "SV", true, false, " Curncy");
    VolatilitySurfaceSpecification spec = new VolatilitySurfaceSpecification("DEFAULT", Currency.USD, SurfaceAndCubeQuoteType.PAY_RECEIVE_DELTA, instrumentProvider);
    AssertJUnit.assertEquals(spec, cycleObject(VolatilitySurfaceSpecification.class, spec));
    instrumentProvider = new BloombergSwaptionVolatilitySurfaceInstrumentProvider("US", "SV", true, false, " Curncy", MarketDataRequirementNames.MARKET_VALUE);
    spec = new VolatilitySurfaceSpecification("DEFAULT", Currency.USD, SurfaceAndCubeQuoteType.PAY_RECEIVE_DELTA, instrumentProvider);
    AssertJUnit.assertEquals(spec, cycleObject(VolatilitySurfaceSpecification.class, spec));
    instrumentProvider = new BloombergSwaptionVolatilitySurfaceInstrumentProvider("US", "SV", true, false, " Curncy", MarketDataRequirementNames.IMPLIED_VOLATILITY);
    spec = new VolatilitySurfaceSpecification("DEFAULT", Currency.USD, SurfaceAndCubeQuoteType.PAY_RECEIVE_DELTA, instrumentProvider);
    AssertJUnit.assertEquals(spec, cycleObject(VolatilitySurfaceSpecification.class, spec));
    AssertJUnit.assertFalse(spec.equals(
        cycleObject(VolatilitySurfaceSpecification.class,
            new VolatilitySurfaceSpecification("DEFAULT",
                Currency.USD,
                SurfaceAndCubeQuoteType.PAY_RECEIVE_DELTA,
                new BloombergSwaptionVolatilitySurfaceInstrumentProvider("US", "SV", true, false, " Curncy")))));
  }
View Full Code Here

  }

  @Test
  public void testEOCycle() {
    final BloombergEquityOptionVolatilitySurfaceInstrumentProvider instrumentProvider = new BloombergEquityOptionVolatilitySurfaceInstrumentProvider("DJX", "Index", MarketDataRequirementNames.IMPLIED_VOLATILITY);
    final VolatilitySurfaceSpecification spec = new VolatilitySurfaceSpecification("DEFAULT", UniqueId.of(ExternalSchemes.BLOOMBERG_TICKER_WEAK.getName(), "DJX Index"),
        SurfaceAndCubeQuoteType.CALL_AND_PUT_STRIKE, instrumentProvider);
    AssertJUnit.assertEquals(spec, cycleObject(VolatilitySurfaceSpecification.class, spec));
    AssertJUnit.assertFalse(spec.equals(
        cycleObject(VolatilitySurfaceSpecification.class,
            new VolatilitySurfaceSpecification("DEFAULT", UniqueId.of(ExternalSchemes.BLOOMBERG_TICKER.getName(), "DJX Index"),
                SurfaceAndCubeQuoteType.CALL_AND_PUT_STRIKE,
                new BloombergEquityOptionVolatilitySurfaceInstrumentProvider("DJX", "Index", MarketDataRequirementNames.MID_IMPLIED_VOLATILITY)))));
  }
View Full Code Here

  }

  private VolatilitySurfaceSpecification getSurfaceSpecification(final UnorderedCurrencyPair currencyPair, final String specificationName,
      final ConfigDBVolatilitySurfaceSpecificationSource specificationSource) {
    final String fullSpecificationName = specificationName + "_" + currencyPair.getUniqueId().getValue();
    final VolatilitySurfaceSpecification specification = specificationSource.getSpecification(fullSpecificationName, InstrumentTypeProperties.FOREX);
    if (specification == null) {
      throw new OpenGammaRuntimeException("Could not get volatility surface specification named " + fullSpecificationName);
    }
    return specification;
  }
View Full Code Here

      final FinancialSecurity security = (FinancialSecurity) position.getSecurity();
      final Currency putCurrency = security.accept(ForexVisitors.getPutCurrencyVisitor());
      final Currency callCurrency = security.accept(ForexVisitors.getCallCurrencyVisitor());
      final UnorderedCurrencyPair currencyPair = UnorderedCurrencyPair.of(putCurrency, callCurrency);
      final VolatilitySurfaceDefinition<Object, Object> definition = getSurfaceDefinition(currencyPair, surfaceName, definitionSource);
      final VolatilitySurfaceSpecification specification = getSurfaceSpecification(currencyPair, surfaceName, specificationSource);
      final Period samplingPeriod = getSamplingPeriod(desiredValue.getConstraint(ValuePropertyNames.SAMPLING_PERIOD));
      final LocalDate startDate = now.minus(samplingPeriod);
      final String scheduleCalculatorName = desiredValue.getConstraint(ValuePropertyNames.SCHEDULE_CALCULATOR);
      final Schedule scheduleCalculator = getScheduleCalculator(scheduleCalculatorName);
      final String samplingFunctionName = desiredValue.getConstraint(ValuePropertyNames.SAMPLING_FUNCTION);
View Full Code Here

        _knownVolDefNames.add(name);
      }
    }

    private void createVolatilitySpecification(final UniqueIdentifiable target, final String name, final SurfaceInstrumentProvider<?, ?> surfaceInstrumentProvider, String quoteUnits) {
      final VolatilitySurfaceSpecification volSurfaceSpec = new VolatilitySurfaceSpecification(name, target,
          SurfaceAndCubeQuoteType.CALL_AND_PUT_STRIKE, quoteUnits,
          surfaceInstrumentProvider);
      final ConfigItem<VolatilitySurfaceSpecification> volSpecConfig = ConfigItem.of(volSurfaceSpec, volSurfaceSpec.getName(), VolatilitySurfaceSpecification.class);
      if (!_dryRun) {
        ConfigMasterUtils.storeByName(_configMaster, volSpecConfig);
      }
      _knownVolSpecNames.add(name);
    }
View Full Code Here

  private static void populateVolatilitySurfaceSpecifications(final ConfigMaster configMaster, final Currency target, final String name) {
    final SurfaceInstrumentProvider<Tenor, Tenor> surfaceInstrumentProvider = new ExampleSwaptionVolatilitySurfaceInstrumentProvider(target.toString(), "ATMSWAPTION", false, true,
        "");
    final String fullName = name + SEPARATOR + target.toString() + SEPARATOR + InstrumentTypeProperties.SWAPTION_ATM;
    final VolatilitySurfaceSpecification specification = new VolatilitySurfaceSpecification(fullName, target, SurfaceAndCubeQuoteType.EXPIRY_MATURITY_ATM,
        surfaceInstrumentProvider);
    ConfigMasterUtils.storeByName(configMaster, makeConfigDocument(specification));
  }
View Full Code Here

  private static void populateVolatilitySurfaceSpecifications(final ConfigMaster configMaster, final UnorderedCurrencyPair target, final String name) {
    final SurfaceInstrumentProvider<Tenor, Pair<Number, FXVolQuoteType>> surfaceInstrumentProvider = new ExampleFXOptionVolatilitySurfaceInstrumentProvider(target.toString(), "FXVOL",
        MarketDataRequirementNames.MARKET_VALUE);
    final String fullName = name + SEPARATOR + target.toString() + SEPARATOR + InstrumentTypeProperties.FOREX;
    final VolatilitySurfaceSpecification spec = new VolatilitySurfaceSpecification(fullName, target, SurfaceAndCubeQuoteType.MARKET_STRANGLE_RISK_REVERSAL, surfaceInstrumentProvider);
    ConfigMasterUtils.storeByName(configMaster, makeConfigDocument(spec));
  }
View Full Code Here

  }

  private static void populateVolatilitySurfaceSpecifications(final ConfigMaster configMaster) {
    final SurfaceInstrumentProvider<LocalDate, Double> surfaceInstrumentProvider =
        new ExampleEquityOptionVolatilitySurfaceInstrumentProvider("DJX_IDX", "EQOPTIONVOL", MarketDataRequirementNames.IMPLIED_VOLATILITY);
    final VolatilitySurfaceSpecification usVolSurfaceDefinition = new VolatilitySurfaceSpecification("SECONDARY_EQUITY_OPTION",
        UniqueId.of(ExternalSchemes.OG_SYNTHETIC_TICKER.getName(), "DJX_IDX"), SurfaceAndCubeQuoteType.CALL_AND_PUT_STRIKE,
        surfaceInstrumentProvider);
    ConfigMasterUtils.storeByName(configMaster, makeConfigDocument(usVolSurfaceDefinition));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.volatility.surface.VolatilitySurfaceSpecification

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.