Package com.opengamma.engine.value

Examples of com.opengamma.engine.value.ComputedValue


    final ValueProperties properties = createCurrencyValueProperties(target)
        .with(ValuePropertyNames.CURVE, curveName)
        .with(ValuePropertyNames.CURVE_CURRENCY, curveCurrency)
        .with(ValuePropertyNames.CURVE_CALCULATION_CONFIG, curveCalculationConfig)
        .get();
    final ComputedValue computedValue = new ComputedValue(new ValueSpecification(PV01_REQUIREMENT, specification, properties), result);
    return Collections.singleton(computedValue);
  }
View Full Code Here


  // AbstractFunction

  @SuppressWarnings("unchecked")
  @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 ValueProperties constraints = desiredValues.iterator().next().getConstraints();
    final ValueProperties.Builder properties = createValueProperties();
    composeValueProperties(properties, input.getSpecification());
    final List<ComputedValue> values = sliceResults((List<ComputedValue>) input.getValue(), constraints, properties);
    return Collections.singleton(new ComputedValue(ValueSpecification.of(getValueName(), ComputationTargetType.PORTFOLIO_NODE, target.getUniqueId(), properties.get()), values));
  }
View Full Code Here

      final Currency sourceCurrency = Currency.of(desiredValue.getConstraint(SOURCE_CURRENCY_PROPERTY));
      final Currency targetCurrency = Currency.of(desiredValue.getConstraint(TARGET_CURRENCY_PROPERTY));
      final ValueSpecification valueSpec = new ValueSpecification(desiredValue.getValueName(), target.toSpecification(), desiredValue.getConstraints());
      final Object resultValue = getRate(matrix, desiredValue, executionContext, inputs, sourceCurrency, targetCurrency);
      if (resultValue != null) {
        result.add(new ComputedValue(valueSpec, resultValue));
      }
    }
    return result;
  }
View Full Code Here

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final Set<ComputedValue> results = Sets.newHashSetWithExpectedSize(desiredValues.size());
    for (ValueRequirement desiredValue : desiredValues) {
      final Object input = inputs.getValue(desiredValue.getValueName());
      results.add(new ComputedValue(new ValueSpecification(desiredValue.getValueName(), target.toSpecification(), desiredValue.getConstraints()), input));
    }
    return results;
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    ComputedValue inputValue = null;
    DoubleTimeSeries<LocalDate> exchangeRates = null;
    Double exchangeRate = null;
    for (final ComputedValue input : inputs.getAllValues()) {
      if (ValueRequirementNames.HISTORICAL_FX_TIME_SERIES.equals(input.getSpecification().getValueName())) {
        if (input.getValue() instanceof Double) {
          // Note: The rate might be a DOUBLE if the matrix being used has a hard coded constant in it. Improbable for a time-series conversion, but possible.
          exchangeRate = (Double) input.getValue();
        } else if (input.getValue() instanceof DoubleTimeSeries) {
          // TODO: Note the unchecked cast. We'll either get a zero intersection and empty result if the values aren't the same type or a class cast exception.
          exchangeRates = (DoubleTimeSeries) input.getValue();
        } else {
          return null;
        }
      } else {
        inputValue = input;
      }
    }
    if (inputValue == null) {
      return null;
    }
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final String outputCurrency = desiredValue.getConstraint(ValuePropertyNames.CURRENCY);
    final String inputCurrency = inputValue.getSpecification().getProperty(ValuePropertyNames.CURRENCY);
    if (outputCurrency.equals(inputCurrency)) {
      // Don't think this should happen
      return Collections.singleton(inputValue);
    } else {
      s_logger.debug("Converting from {} to {}", inputCurrency, outputCurrency);
      final Object converted;
      if (exchangeRates != null) {
        converted = convertValue(inputValue, desiredValue, exchangeRates);
      } else if (exchangeRate != null) {
        converted = convertValue(inputValue, desiredValue, exchangeRate);
      } else {
        return null;
      }
      if (converted != null) {
        return Collections.singleton(new ComputedValue(new ValueSpecification(desiredValue.getValueName(), target.toSpecification(), desiredValue.getConstraints()), converted));
      } else {
        return null;
      }
    }
  }
View Full Code Here

  public Set<ComputedValue> execute(FunctionExecutionContext executionContext, FunctionInputs inputs, ComputationTarget target, Set<ValueRequirement> desiredValues) {
    //final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.YIELD_CURVE, target.toSpecification(), properties);
    ValueProperties outputProperties = createValueProperties().get();
    ValueSpecification spec = new ValueSpecification(ValueRequirementNames.TARGET, target.toSpecification(), outputProperties);
    //return new ValueSpecification(_newValueName, inputSpec.getTargetSpecification(), outputProperties);
    return ImmutableSet.of(new ComputedValue(spec, target.getValue()));
  }
View Full Code Here

      final ValueRequirement requirement = getNestedRequirement(executionContext.getComputationTargetResolver(), target, desiredValue.getConstraints());
      if (requirement != null) {
        @SuppressWarnings("rawtypes")
        final TimeSeries ts = evaluationResult.getTimeSeries(requirement);
        if (ts != null) {
          results.add(new ComputedValue(new ValueSpecification(desiredValue.getValueName(), targetSpec, desiredValue.getConstraints()), ts));
        } else {
          s_logger.warn("Nested requirement {} did not produce a time series for {}", requirement, desiredValue);
        }
      } else {
        s_logger.error("Couldn't produce nested requirement for {}", desiredValue);
View Full Code Here

    public MyCompiledFunction(final ZonedDateTime earliestInvocation, final ZonedDateTime latestInvocation, final CurveSpecification specification,
        final ValueSpecification spec) {
      super(earliestInvocation, latestInvocation);
      _spec = spec;
      _result = Collections.singleton(new ComputedValue(spec, specification));
    }
View Full Code Here

        }
        timeSeries.add(timeSeriesRequirement.getConstraint(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY), timeSeriesSource.getExternalIdBundle(hts.getUniqueId()), hts);
      }
    }
    final ValueProperties properties = createValueProperties().with(ValuePropertyNames.CURVE_CALCULATION_CONFIG, curveCalculationConfigName).get();
    return Collections.singleton(new ComputedValue(new ValueSpecification(ValueRequirementNames.YIELD_CURVE_INSTRUMENT_CONVERSION_HISTORICAL_TIME_SERIES, targetSpec, properties), timeSeries));
  }
View Full Code Here

public class HistoricalTimeSeriesLatestPositionProviderIdValueFunction extends AbstractFunction.NonCompiledInvoker {

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs,
      final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final ComputedValue latestHtsValue = inputs.getComputedValue(ValueRequirementNames.HISTORICAL_TIME_SERIES_LATEST);
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    return Collections.singleton(new ComputedValue(new ValueSpecification(desiredValue.getValueName(), target.toSpecification(), desiredValue.getConstraints()), latestHtsValue.getValue()));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.value.ComputedValue

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.