Package com.opengamma.financial.view

Examples of com.opengamma.financial.view.HistoricalViewEvaluationMarketData


  // FunctionInvoker

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final HistoricalViewEvaluationMarketData marketData = (HistoricalViewEvaluationMarketData) inputs.getValue(ValueRequirementNames.HISTORICAL_TIME_SERIES);
    final ValueSpecification[] marketDataSpecs = marketData.getValueSpecifications().toArray(new ValueSpecification[marketData.getValueSpecifications().size()]);
    final LocalDateDoubleTimeSeries[] timeSeries = new LocalDateDoubleTimeSeries[marketDataSpecs.length];
    for (int i = 0; i < marketDataSpecs.length; i++) {
      timeSeries[i] = marketData.getDoubleTimeSeries(marketDataSpecs[i]);
    }
    final ValueRequirement desiredValueReq = desiredValues.iterator().next();
    final ValueSpecification desiredValueSpec = new ValueSpecification(ValueRequirementNames.COVARIANCE_MATRIX, target.toSpecification(), desiredValueReq.getConstraints());
    return Collections.singleton(new ComputedValue(desiredValueSpec, createCovarianceMatrix(timeSeries, marketDataSpecs)));
  }
View Full Code Here


    }
    return ImmutableLocalDateObjectTimeSeries.of(d, v);
  }

  public void testExecuteFullData() {
    final HistoricalViewEvaluationMarketData input = new HistoricalViewEvaluationMarketData();
    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);
View Full Code Here

    assertEquals(matrix.getYLabels().length, 5);
  }

  @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

    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
  }

  public void testExecuteMissingData() {
    final HistoricalViewEvaluationMarketData input = new HistoricalViewEvaluationMarketData();
    input.addTimeSeries(timeSeriesSpecification(0), localDateDoubleTimeSeries(10, 0, 5));
    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);
View Full Code Here

    assertEquals(matrix.getXLabels().length, 3);
    assertEquals(matrix.getYLabels().length, 3);
  }

  public void testExecuteSlightMisalignedData() {
    final HistoricalViewEvaluationMarketData input = new HistoricalViewEvaluationMarketData();
    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);
View Full Code Here

    assertEquals(matrix.getYLabels().length, 5);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testExecuteTotalMisalignedData() {
    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

TOP

Related Classes of com.opengamma.financial.view.HistoricalViewEvaluationMarketData

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.