Package com.opengamma.engine

Examples of com.opengamma.engine.ComputationTarget


          .with(ValuePropertyNames.CALCULATION_METHOD, ISDAFunctionConstants.ISDA_METHOD_NAME)
          .with(ISDAFunctionConstants.ISDA_IMPLEMENTATION, ISDAFunctionConstants.ISDA_IMPLEMENTATION_APPROX)
          .with(ISDAFunctionConstants.ISDA_HAZARD_RATE_STRUCTURE, ISDAFunctionConstants.ISDA_HAZARD_RATE_FLAT)
          .get());
   
    Set<ValueRequirement> result = testItem.getRequirements(functionCompilationContext, new ComputationTarget(ComputationTargetType.SECURITY, CDS_SECURITY), requirement);

    Assert.assertNotNull(result);
    Assert.assertEquals(result.size(), 2);

    TreeSet<String> r = new TreeSet<String>();
View Full Code Here


            "[ValueReq[SpotRate, CTSpec[SECURITY, dummy_scheme~dummy_value], EMPTY], ValueReq[YieldCurve, CTSpec[CURRENCY, CurrencyISO~GBP], {CalculationMethod=[ISDA]}]]");
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void getResults1() {
    testItem.getResults(null, new ComputationTarget(ComputationTargetType.SECURITY, CDS_SECURITY));
  }
View Full Code Here

    final ConfigSource configurationSource = OpenGammaCompilationContext.getConfigSource(context);
    final MultiCurveCalculationConfig impliedConfiguration = configurationSource.getLatestByName(MultiCurveCalculationConfig.class, _curveCalculationConfig);
    if (impliedConfiguration == null) {
      throw new OpenGammaRuntimeException("Multi-curve calculation called " + _curveCalculationConfig + " was null");
    }
    ComputationTarget target = context.getComputationTargetResolver().resolve(impliedConfiguration.getTarget());
    if (!(target.getValue() instanceof Currency)) {
      throw new OpenGammaRuntimeException("Target of curve calculation configuration was not a currency");
    }
    final Currency impliedCurrency = (Currency) target.getValue();
    if (!IMPLIED_DEPOSIT.equals(impliedConfiguration.getCalculationMethod())) {
      throw new OpenGammaRuntimeException("Curve calculation method was not " + IMPLIED_DEPOSIT + " for configuration called " + _curveCalculationConfig);
    }
    final String[] impliedCurveNames = impliedConfiguration.getYieldCurveNames();
    if (impliedCurveNames.length != 1) {
      throw new OpenGammaRuntimeException("Can only handle configurations with a single implied curve");
    }
    final LinkedHashMap<String, String[]> originalConfigurationName = impliedConfiguration.getExogenousConfigData();
    if (originalConfigurationName == null || originalConfigurationName.size() != 1) {
      throw new OpenGammaRuntimeException("Need a configuration with one exogenous configuration");
    }
    final Map.Entry<String, String[]> entry = Iterables.getOnlyElement(originalConfigurationName.entrySet());
    final String[] originalCurveNames = entry.getValue();
    if (originalCurveNames.length != 1) {
      s_logger.warn("Found more than one exogenous configuration name; using only the first");
    }
    final MultiCurveCalculationConfig originalConfiguration = configurationSource.getLatestByName(MultiCurveCalculationConfig.class, entry.getKey());
    if (originalConfiguration == null) {
      throw new OpenGammaRuntimeException("Multi-curve calculation called " + entry.getKey() + " was null");
    }
    target = context.getComputationTargetResolver().resolve(originalConfiguration.getTarget());
    if (!(target.getValue() instanceof Currency)) {
      throw new OpenGammaRuntimeException("Target of curve calculation configuration was not a currency");
    }
    final Currency originalCurrency = (Currency) target.getValue();
    if (!originalCurrency.equals(impliedCurrency)) {
      throw new OpenGammaRuntimeException("Currency targets for configurations " + _curveCalculationConfig + " and " + entry.getKey() + " did not match");
    }
    final YieldCurveDefinition impliedDefinition = configurationSource.getLatestByName(YieldCurveDefinition.class, impliedCurveNames[0] + "_" + impliedCurrency.getCode());
    if (impliedDefinition == null) {
View Full Code Here

  private DependencyGraph createGraph() {
    DependencyGraph graph = new DependencyGraph("testGraph");
    ComputationTargetSpecification targetSpecification = new ComputationTargetSpecification(ComputationTargetType.CURRENCY,
                                                                                            Currency.GBP.getUniqueId());
    DependencyNode yieldCurveNode = new DependencyNode(targetSpecification);
    ComputationTarget target = new ComputationTarget(targetSpecification, Currency.GBP);
    yieldCurveNode.setFunction(new MockFunction(target));
    yieldCurveNode.addOutputValue(new ValueSpecification("YieldCurveMarketData",
                                                         targetSpecification,
                                                         ValueProperties.builder().with("Curve", "Forward3M").with("Function", "someFunction").get()));
    graph.addDependencyNode(yieldCurveNode);
View Full Code Here

    _function.init(_functionCompilationContext);
  }

  @Test
  public void testGetResults1() {
    final ComputationTarget ct = new ComputationTarget(CurrencyPair.TYPE, CurrencyPair.parse("USD/EUD"));
    final Set<ValueSpecification> results = _function.getResults(_functionCompilationContext, ct);
    assertEquals(3, results.size());
  }
View Full Code Here

    assertEquals(3, results.size());
  }

  @Test
  public void testGetRequirements() {
    ComputationTarget target = new ComputationTarget(CurrencyPair.TYPE, CurrencyPair.parse("GBP/USD"));
    Set<ValueRequirement> requirements = _function.getRequirements(_functionCompilationContext, target, new ValueRequirement(ValueRequirementNames.SPOT_RATE, target.toSpecification()));
    assertEquals(Iterables.getOnlyElement(requirements),
        new ValueRequirement(ValueRequirementNames.SPOT_RATE, new ComputationTargetRequirement(CurrencyMatrixResolver.TYPE, ExternalId.of(CurrencyMatrixResolver.IDENTIFIER_SCHEME, "Foo")),
            ValueProperties.with(AbstractCurrencyMatrixSourcingFunction.SOURCE_CURRENCY_PROPERTY, "USD").with(AbstractCurrencyMatrixSourcingFunction.TARGET_CURRENCY_PROPERTY, "GBP").get()));
    requirements = _function.getRequirements(_functionCompilationContext, target,
        new ValueRequirement(ValueRequirementNames.SPOT_RATE, target.toSpecification(), ValueProperties.with(CurrencyMatrixLookupFunction.CURRENCY_MATRIX_NAME_PROPERTY, "Bar").get()));
    assertEquals(Iterables.getOnlyElement(requirements),
        new ValueRequirement(ValueRequirementNames.SPOT_RATE, new ComputationTargetRequirement(CurrencyMatrixResolver.TYPE, ExternalId.of(CurrencyMatrixResolver.IDENTIFIER_SCHEME, "Bar")),
            ValueProperties.with(AbstractCurrencyMatrixSourcingFunction.SOURCE_CURRENCY_PROPERTY, "USD").with(AbstractCurrencyMatrixSourcingFunction.TARGET_CURRENCY_PROPERTY, "GBP").get()));
    requirements = _function.getRequirements(_functionCompilationContext, target,
        new ValueRequirement(ValueRequirementNames.SPOT_RATE, target.toSpecification(), ValueProperties.with(CurrencyMatrixLookupFunction.CURRENCY_MATRIX_NAME_PROPERTY, "Bar", "Foo").get()));
    assertEquals(
        Iterables.getOnlyElement(requirements),
        new ValueRequirement(ValueRequirementNames.SPOT_RATE, new ComputationTargetRequirement(CurrencyMatrixResolver.TYPE, ExternalIdBundle.of(
            ExternalId.of(CurrencyMatrixResolver.IDENTIFIER_SCHEME, "Foo"), ExternalId.of(CurrencyMatrixResolver.IDENTIFIER_SCHEME, "Bar"))),
            ValueProperties.with(AbstractCurrencyMatrixSourcingFunction.SOURCE_CURRENCY_PROPERTY, "USD").with(AbstractCurrencyMatrixSourcingFunction.TARGET_CURRENCY_PROPERTY, "GBP").get()));
    requirements = _function.getRequirements(_functionCompilationContext, target,
        new ValueRequirement(ValueRequirementNames.SPOT_RATE, target.toSpecification(), ValueProperties.withAny(CurrencyMatrixLookupFunction.CURRENCY_MATRIX_NAME_PROPERTY).get()));
    assertEquals(Iterables.getOnlyElement(requirements),
        new ValueRequirement(ValueRequirementNames.SPOT_RATE, new ComputationTargetRequirement(CurrencyMatrixResolver.TYPE, ExternalId.of(CurrencyMatrixResolver.IDENTIFIER_SCHEME, "Foo")),
            ValueProperties.with(AbstractCurrencyMatrixSourcingFunction.SOURCE_CURRENCY_PROPERTY, "USD").with(AbstractCurrencyMatrixSourcingFunction.TARGET_CURRENCY_PROPERTY, "GBP").get()));
  }
View Full Code Here

            ValueProperties.with(AbstractCurrencyMatrixSourcingFunction.SOURCE_CURRENCY_PROPERTY, "USD").with(AbstractCurrencyMatrixSourcingFunction.TARGET_CURRENCY_PROPERTY, "GBP").get()));
  }

  @Test
  public void testGetResults2() {
    ComputationTarget target = new ComputationTarget(CurrencyPair.TYPE, CurrencyPair.parse("GBP/USD"));
    Set<ValueSpecification> results = _function.getResults(
        _functionCompilationContext,
        target,
        ImmutableMap.of(
            new ValueSpecification(ValueRequirementNames.SPOT_RATE, new ComputationTargetSpecification(CurrencyMatrixResolver.TYPE, UniqueId.of("Matrix", "0")), ValueProperties.with(
                ValuePropertyNames.FUNCTION, "Test").get()),
            new ValueRequirement(ValueRequirementNames.SPOT_RATE, new ComputationTargetRequirement(CurrencyMatrixResolver.TYPE, ExternalId.of(CurrencyMatrixResolver.IDENTIFIER_SCHEME, "Foo")))));
    assertEquals(
        Iterables.getOnlyElement(results),
        new ValueSpecification(ValueRequirementNames.SPOT_RATE, target.toSpecification(), ValueProperties.with(ValuePropertyNames.FUNCTION, "currencyMatrixLookup")
            .with(CurrencyMatrixLookupFunction.CURRENCY_MATRIX_NAME_PROPERTY, "Foo").get()));
  }
View Full Code Here

    SimpleCurrencyMatrix matrix = new SimpleCurrencyMatrix();
    matrix.setUniqueId(UniqueId.of("Matrix", "Test"));
    matrix.setLiveData(_currencyUSD, _currencyGBP, new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, ExternalId.of("LiveData", "USD_GBP")));
    matrix.setFixedConversion(_currencyEUR, _currencyGBP, _rateEUR_GBP);
    matrix.setCrossConversion(_currencyEUR, _currencyUSD, _currencyGBP);
    _matrixTarget = new ComputationTarget(CurrencyMatrixResolver.TYPE, matrix);
    _function = new CurrencyMatrixSpotSourcingFunction();
    _function.setUniqueId("currencyMatrixSourcing");
    _function.init(_functionCompilationContext);
  }
View Full Code Here

    }
    rowIdSet.add(rowId);
  }

  private String getTargetName(final ComputationTargetSpecification targetSpec) {
    final ComputationTarget target = getComputationTargetResolver().resolve(targetSpec, VersionCorrection.LATEST);
    if (target != null) {
      return target.getName();
    } else {
      final UniqueId uid = targetSpec.getUniqueId();
      if (uid != null) {
        return uid.toString();
      } else {
View Full Code Here

      final ComputationTargetSpecification targetSpec = valueSpec.getTargetSpecification();
      // TODO I don't think LATEST will do long term. resolution time available on the result model
      if (targetSpec.getType() == ComputationTargetType.NULL) {
        return getNullTargetName(valueSpec);
      } else {
        ComputationTarget target = _computationTargetResolver.resolve(targetSpec, VersionCorrection.LATEST);
        if (target != null) { // doubt this branch ever happens - don't think it will be executed for NULL targets.
          return target.getName();
        } else {
          UniqueId uid = targetSpec.getUniqueId();
          if (uid != null) {
            return uid.toString();
          } else {
View Full Code Here

TOP

Related Classes of com.opengamma.engine.ComputationTarget

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.