Package com.opengamma.engine.function

Examples of com.opengamma.engine.function.FunctionInputsImpl


    input.addTimeSeries(timeSeriesSpecification(0), localDateDoubleTimeSeries(10));
    input.addTimeSeries(timeSeriesSpecification(1), localDateDoubleTimeSeries(10));
    input.addTimeSeries(timeSeriesSpecification(2), localDateDoubleTimeSeries(10));
    input.addTimeSeries(timeSeriesSpecification(3), localDateDoubleTimeSeries(10));
    input.addTimeSeries(timeSeriesSpecification(4), localDateDoubleTimeSeries(10));
    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    final Set<ComputedValue> result = FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
    assertEquals(result.size(), 1);
    final ComputedValue value = result.iterator().next();
    assertEquals(value.getValue().getClass(), DoubleLabelledMatrix2D.class);
    final DoubleLabelledMatrix2D matrix = (DoubleLabelledMatrix2D) value.getValue();
View Full Code Here


  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testExecuteNoData() {
    final HistoricalViewEvaluationMarketData input = new HistoricalViewEvaluationMarketData();
    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
  }
View Full Code Here

    input.addTimeSeries(timeSeriesSpecification(1), localDateObjectTimeSeries(10));
    input.addTimeSeries(timeSeriesSpecification(2), localDateDoubleTimeSeries(10, 0, 5));
    input.addTimeSeries(timeSeriesSpecification(3), localDateObjectTimeSeries(10));
    input.addTimeSeries(timeSeriesSpecification(4), localDateDoubleTimeSeries(10, 0, 5));
    input.addTimeSeries(timeSeriesSpecification(5), localDateDoubleTimeSeries(0, 0, 5));
    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    final Set<ComputedValue> result = FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
    assertEquals(result.size(), 1);
    final ComputedValue value = result.iterator().next();
    assertEquals(value.getValue().getClass(), DoubleLabelledMatrix2D.class);
    final DoubleLabelledMatrix2D matrix = (DoubleLabelledMatrix2D) value.getValue();
View Full Code Here

    input.addTimeSeries(timeSeriesSpecification(0), localDateDoubleTimeSeries(10, 0, 5));
    input.addTimeSeries(timeSeriesSpecification(1), localDateDoubleTimeSeries(15, 3, 7));
    input.addTimeSeries(timeSeriesSpecification(2), localDateDoubleTimeSeries(10, 1, 5));
    input.addTimeSeries(timeSeriesSpecification(3), localDateDoubleTimeSeries(15, 0, 7));
    input.addTimeSeries(timeSeriesSpecification(4), localDateDoubleTimeSeries(10, 2, 5));
    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    final Set<ComputedValue> result = FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
    assertEquals(result.size(), 1);
    final ComputedValue value = result.iterator().next();
    assertEquals(value.getValue().getClass(), DoubleLabelledMatrix2D.class);
    final DoubleLabelledMatrix2D matrix = (DoubleLabelledMatrix2D) value.getValue();
View Full Code Here

    final HistoricalViewEvaluationMarketData input = new HistoricalViewEvaluationMarketData();
    input.addTimeSeries(timeSeriesSpecification(0), localDateDoubleTimeSeries(LocalDate.of(2013, 1, 1), 10));
    input.addTimeSeries(timeSeriesSpecification(1), localDateDoubleTimeSeries(LocalDate.of(2013, 1, 1), 15));
    input.addTimeSeries(timeSeriesSpecification(2), localDateDoubleTimeSeries(LocalDate.of(2013, 2, 1), 10));
    input.addTimeSeries(timeSeriesSpecification(3), localDateDoubleTimeSeries(LocalDate.of(2013, 2, 1), 15));
    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
  }
View Full Code Here

    for (ValueRequirement requirement : inRequirements) {
      assertEquals(requirement.getValueName(), MarketDataRequirementNames.MARKET_VALUE);
      assertEquals(requirement.getTargetReference(), inRequirementTarget);
      assertTrue(requirement.getConstraints().isSatisfiedBy(ValueProperties.none()));
    }
    Set<ComputedValue> outputs = _function.execute(_functionExecutionContext, new FunctionInputsImpl(resolver.atVersionCorrection(VersionCorrection.LATEST), new ComputedValue(new ValueSpecification(
        MarketDataRequirementNames.MARKET_VALUE, ComputationTargetSpecification.of(UniqueId.of("ExternalId-LiveData", "USD_GBP")), properties), _rateUSD_GBP)), _matrixTarget,
        Collections.singleton(outRequirement));
    assertEquals(1, outputs.size());
    ComputedValue output = outputs.iterator().next();
    assertTrue(output.getValue() instanceof Double);
    assertEquals(_rateUSD_GBP, (Double) output.getValue(), Double.MIN_NORMAL);

    // Require value the "wrong" way up
    // [PLAT-2290] Execute should be taking a ValueSpecification, getRequirements should be taking a ValueRequirement
    outRequirement = new ValueRequirement(ValueRequirementNames.SPOT_RATE, _matrixTarget.toSpecification(), ValueProperties
        .with(AbstractCurrencyMatrixSourcingFunction.SOURCE_CURRENCY_PROPERTY, "GBP").with(AbstractCurrencyMatrixSourcingFunction.TARGET_CURRENCY_PROPERTY, "USD")
        .with(ValuePropertyNames.FUNCTION, "CMSF").get());
    inRequirements = _function.getRequirements(_functionCompilationContext, _matrixTarget, outRequirement);
    assertEquals(1, inRequirements.size());
    for (ValueRequirement requirement : inRequirements) {
      assertEquals(requirement.getValueName(), MarketDataRequirementNames.MARKET_VALUE);
      assertEquals(requirement.getTargetReference(), inRequirementTarget);
      assertTrue(requirement.getConstraints().isSatisfiedBy(ValueProperties.none()));
    }
    outputs = _function.execute(_functionExecutionContext,
        new FunctionInputsImpl(resolver.atVersionCorrection(VersionCorrection.LATEST), new ComputedValue(new ValueSpecification(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetSpecification.of(UniqueId.of("ExternalId-LiveData", "USD_GBP")), properties), _rateUSD_GBP)), _matrixTarget, Collections.singleton(outRequirement));
    assertEquals(1, outputs.size());
    output = outputs.iterator().next();
    assertTrue(output.getValue() instanceof Double);
    assertEquals(1.0 / _rateUSD_GBP, (Double) output.getValue(), Double.MIN_NORMAL);

    // Require no additional live data
    // [PLAT-2290] Execute should be taking a ValueSpecification, getRequirements should be taking a ValueRequirement
    outRequirement = new ValueRequirement(ValueRequirementNames.SPOT_RATE, _matrixTarget.toSpecification(), ValueProperties
        .with(AbstractCurrencyMatrixSourcingFunction.SOURCE_CURRENCY_PROPERTY, "GBP").with(AbstractCurrencyMatrixSourcingFunction.TARGET_CURRENCY_PROPERTY, "EUR")
        .with(ValuePropertyNames.FUNCTION, "CMSF").get());
    inRequirements = _function.getRequirements(_functionCompilationContext, _matrixTarget, outRequirement);
    assertEquals(0, inRequirements.size());
    outputs = _function.execute(_functionExecutionContext, new EmptyFunctionInputs(), _matrixTarget, Collections.singleton(outRequirement));
    assertEquals(1, outputs.size());
    output = outputs.iterator().next();
    assertTrue(output.getValue() instanceof Double);
    assertEquals(1.0 / _rateEUR_GBP, (Double) output.getValue(), Double.MIN_NORMAL);

    // Require intermediate value
    // [PLAT-2290] Execute should be taking a ValueSpecification, getRequirements should be taking a ValueRequirement
    outRequirement = new ValueRequirement(ValueRequirementNames.SPOT_RATE, _matrixTarget.toSpecification(), ValueProperties
        .with(AbstractCurrencyMatrixSourcingFunction.SOURCE_CURRENCY_PROPERTY, "EUR").with(AbstractCurrencyMatrixSourcingFunction.TARGET_CURRENCY_PROPERTY, "USD")
        .with(ValuePropertyNames.FUNCTION, "CMSF").get());
    inRequirements = _function.getRequirements(_functionCompilationContext, _matrixTarget, outRequirement);
    assertEquals(1, inRequirements.size());
    for (ValueRequirement requirement : inRequirements) {
      assertEquals(requirement.getValueName(), MarketDataRequirementNames.MARKET_VALUE);
      assertEquals(requirement.getTargetReference(), inRequirementTarget);
      assertTrue(requirement.getConstraints().isSatisfiedBy(ValueProperties.none()));
    }
    outputs = _function.execute(_functionExecutionContext,
        new FunctionInputsImpl(resolver.atVersionCorrection(VersionCorrection.LATEST), new ComputedValue(new ValueSpecification(MarketDataRequirementNames.MARKET_VALUE,
            ComputationTargetSpecification.of(UniqueId.of("ExternalId-LiveData", "USD_GBP")), properties), _rateUSD_GBP)), _matrixTarget, Collections.singleton(outRequirement));
    assertEquals(1, outputs.size());
    output = outputs.iterator().next();
    assertTrue(output.getValue() instanceof Double);
    assertEquals(_rateEUR_GBP / _rateUSD_GBP, (Double) output.getValue(), Double.MIN_NORMAL);
View Full Code Here

    return function.compile(compContext, execContext.getValuationTime());
  }

  private ComputedValue execute(final FunctionExecutionContext context, final CompiledFunctionDefinition function, final ComputationTarget target, final ValueRequirement output,
      final ComputedValue... inputs) {
    final FunctionInputsImpl functionInputs = new FunctionInputsImpl(context.getComputationTargetResolver().getSpecificationResolver(), Arrays.asList(inputs));
    Set<ComputedValue> results;
    try {
      results = function.getFunctionInvoker().execute(context, functionInputs, target, Collections.singleton(output));
    } catch (final AsynchronousExecution ex) {
      results = AsynchronousOperation.getResult(ex);
View Full Code Here

        postEvaluationErrors(jobItem.getOutputs(), MissingOutput.MISSING_INPUTS);
        resultItemBuilder.withMissingInputs(missing);
        return;
      }
    }
    final FunctionInputs functionInputs = new FunctionInputsImpl(getTargetResolver().getSpecificationResolver(), inputs, missing);
    if (target == null) {
      try {
        target = targetFuture.get();
      } catch (final Throwable t) {
        s_logger.warn("Error resolving target", t);
View Full Code Here

TOP

Related Classes of com.opengamma.engine.function.FunctionInputsImpl

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.