Package com.opengamma.financial.analytics.parameters

Examples of com.opengamma.financial.analytics.parameters.G2ppParameters


      final ExternalId firstVolatilityParameterId = deserializer.fieldValueToObject(ExternalId.class, firstVolatilityParameterIds.get(i));
      final ExternalId secondVolatilityParameterId = deserializer.fieldValueToObject(ExternalId.class, secondVolatilityParameterIds.get(i));
      volatilityTermStructure.put(tenor, Pair.of(firstVolatilityParameterId, secondVolatilityParameterId));
    }
    final ExternalId correlationId = deserializer.fieldValueToObject(ExternalId.class, message.getByName(CORRELATION_ID));
    final G2ppParameters parameters = new G2ppParameters(currency, firstMeanReversionId, secondMeanReversionId, firstInitialVolatilityId,
        secondInitialVolatilityId, volatilityTermStructure, correlationId);
    parameters.setUniqueId(uniqueId);
    return parameters;
  }
View Full Code Here


    final SortedMap<Tenor, Pair<ExternalId, ExternalId>> volatilityParameterIds = new TreeMap<>();
    for (int i = 1; i < 10; i++) {
      volatilityParameterIds.put(Tenor.ofMonths(i), Pair.of(ExternalId.of("Test", "1V" + i), ExternalId.of("Test", "2V" + i)));
    }
    final ExternalId correlationId = ExternalId.of("Test", "rho");
    final G2ppParameters object = new G2ppParameters(currency, firstMeanReversionId, secondMeanReversionId, firstInitialVolatilityId,
        secondInitialVolatilityId, volatilityParameterIds, correlationId);
    object.setUniqueId(UniqueId.of("Test", "123"));
    assertEquals(object, cycleObject(G2ppParameters.class, object));
  }
View Full Code Here

      }
      final ConfigSearchRequest<G2ppParameters> g2ppSearchRequest = new ConfigSearchRequest<>();
      g2ppSearchRequest.setType(G2ppParameters.class);
      for (final ConfigDocument configDocument : ConfigSearchIterator.iterable(getConfigMaster(), g2ppSearchRequest)) {
        final String configurationName = configDocument.getName();
        final G2ppParameters g2ppParameters = ((ConfigItem<G2ppParameters>) configDocument.getConfig()).getValue();
        final Currency currency = g2ppParameters.getCurrency();
        functions.add(functionConfiguration(G2ppParametersFunction.class, configurationName, currency.getCode()));
      }
    }
View Full Code Here

    final ConfigSource configSource = OpenGammaCompilationContext.getConfigSource(context);
    final Collection<ConfigItem<G2ppParameters>> configs = configSource.get(G2ppParameters.class, _name, VersionCorrection.LATEST);
    if (configs == null) {
      throw new OpenGammaRuntimeException("G2ppParameter configuration called " + _name + " was null");
    }
    final G2ppParameters parameters = configs.iterator().next().getValue();
    requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getFirstMeanReversionId()));
    requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getSecondMeanReversionId()));
    requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getFirstInitialVolatilityId()));
    requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getSecondInitialVolatilityId()));
    requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getCorrelationId()));
    final Map<Tenor, Pair<ExternalId, ExternalId>> volatilityTermStructure = parameters.getVolatilityTermStructure();
    for (final Map.Entry<Tenor, Pair<ExternalId, ExternalId>> entry : volatilityTermStructure.entrySet()) {
      final ExternalScheme firstScheme = entry.getValue().getFirst().getScheme();
      final ExternalScheme secondScheme = entry.getValue().getSecond().getScheme();
      final String firstId = entry.getValue().getFirst().getValue();
      final String secondId = entry.getValue().getSecond().getValue();
      final ExternalId firstTenorAppendedId = ExternalId.of(firstScheme, createId(entry.getKey(), firstId));
      final ExternalId secondTenorAppendedId = ExternalId.of(secondScheme, createId(entry.getKey(), secondId));
      requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, firstTenorAppendedId));
      requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, secondTenorAppendedId));
    }
    final ZonedDateTime atZDT = ZonedDateTime.ofInstant(atInstant, ZoneOffset.UTC);
    return new AbstractInvokingCompiledFunction(atZDT.with(LocalTime.MIDNIGHT), atZDT.plusDays(1).with(LocalTime.MIDNIGHT).minusNanos(1000000)) {

      @Override
      public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
          final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
        final Clock snapshotClock = executionContext.getValuationClock();
        final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
        final Object firstMeanReversionObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getFirstMeanReversionId()));
        if (firstMeanReversionObject == null) {
          throw new OpenGammaRuntimeException("Could not get first mean reversion value");
        }
        final Object secondMeanReversionObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getSecondMeanReversionId()));
        if (secondMeanReversionObject == null) {
          throw new OpenGammaRuntimeException("Could not get second mean reversion value");
        }
        final Object firstInitialVolatilityObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getFirstInitialVolatilityId()));
        if (firstInitialVolatilityObject == null) {
          throw new OpenGammaRuntimeException("Could not get first initial volatility value");
        }
        final Object secondInitialVolatilityObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getSecondInitialVolatilityId()));
        if (secondInitialVolatilityObject == null) {
          throw new OpenGammaRuntimeException("Could not get second initial volatility value");
        }
        final Object correlationObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetType.PRIMITIVE, parameters.getCorrelationId()));
        if (correlationObject == null) {
          throw new OpenGammaRuntimeException("Could not get correlation value");
        }
        final Double firstMeanReversion = (Double) firstMeanReversionObject;
        final Double secondMeanReversion = (Double) secondMeanReversionObject;
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.parameters.G2ppParameters

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.