Package com.opengamma.engine.marketdata

Examples of com.opengamma.engine.marketdata.MarketDataSnapshot


    assertEquals(ImmutableMap.<ValueSpecification, Object>of(SPEC1, 10.1d, SPEC2, 20.2d, SPEC3, 40.4d),
                 snapshot.query(ImmutableSet.of(SPEC1, SPEC2, SPEC3)));
  }

  private static MarketDataSnapshot historicalSnapshot1() {
    MarketDataSnapshot snapshot = mock(MarketDataSnapshot.class);
    when(snapshot.query(SPEC1)).thenReturn(1d);
    when(snapshot.query(SPEC2)).thenReturn(2d);
    when(snapshot.query(SPEC3)).thenReturn(4d);
    return snapshot;
  }
View Full Code Here


    when(snapshot.query(SPEC3)).thenReturn(4d);
    return snapshot;
  }

  private static MarketDataSnapshot historicalSnapshot2() {
    MarketDataSnapshot snapshot = mock(MarketDataSnapshot.class);
    when(snapshot.query(SPEC1)).thenReturn(1.1d);
    when(snapshot.query(SPEC2)).thenReturn(2.2d);
    when(snapshot.query(SPEC3)).thenReturn(4.4d);
    return snapshot;
  }
View Full Code Here

    when(snapshot.query(SPEC3)).thenReturn(4.4d);
    return snapshot;
  }

  private static MarketDataSnapshot baseSnapshot() {
    MarketDataSnapshot snapshot = mock(MarketDataSnapshot.class);
    when(snapshot.query(SPEC1)).thenReturn(10d);
    when(snapshot.query(SPEC2)).thenReturn(20d);
    when(snapshot.query(SPEC3)).thenReturn(40d);
    return snapshot;
  }
View Full Code Here

  public void init(final Set<ValueSpecification> values, final long timeout, final TimeUnit unit) {
    ArgumentChecker.notNull(values, "values");
    ArgumentChecker.notNull(unit, "unit");
    final List<Set<ValueSpecification>> valuesBySnapshot = _valueMap.getUnderlyingSpecifications(values);
    for (int i = 0; i < _snapshots.size(); i++) {
      final MarketDataSnapshot snapshot = _snapshots.get(i);
      final Set<ValueSpecification> snapshotSubscriptions = valuesBySnapshot.get(i);
      if (snapshotSubscriptions.isEmpty()) {
        snapshot.init();
      } else {
        // TODO whole timeout? or divide timeout between all delegate snapshots and keep track of how much is left?
        // the combined snapshot does this but that seems broken to me
        snapshot.init(snapshotSubscriptions, timeout, unit);
      }
    }
  }
View Full Code Here

  public Map<ValueSpecification, Object> query(final Set<ValueSpecification> values) {
    ArgumentChecker.notNull(values, "values");
    final Map<ValueSpecification, Object> results = Maps.newHashMapWithExpectedSize(values.size());
    final List<Set<ValueSpecification>> valuesBySnapshot = _valueMap.getUnderlyingSpecifications(values);
    for (int i = 0; i < _snapshots.size(); i++) {
      final MarketDataSnapshot snapshot = _snapshots.get(i);
      final Set<ValueSpecification> snapshotSubscriptions = valuesBySnapshot.get(i);
      if (!snapshotSubscriptions.isEmpty()) {
        final Map<ValueSpecification, Object> snapshotResults = snapshot.query(snapshotSubscriptions);
        for (final Map.Entry<ValueSpecification, Object> snapshotResult : snapshotResults.entrySet()) {
          results.put(_valueMap.convertUnderlyingSpecification(i, snapshotResult.getKey()), snapshotResult.getValue());
        }
      }
    }
View Full Code Here

    if (providers == 1) {
      return getProviders().get(0).snapshot(getSpecifications().get(0));
    }
    final List<MarketDataSnapshot> snapshots = Lists.newArrayListWithCapacity(providers);
    for (int i = 0; i < providers; i++) {
      final MarketDataSnapshot snapshot = getProviders().get(i).snapshot(getSpecifications().get(i));
      snapshots.add(snapshot);
    }
    return new CompositeMarketDataSnapshot(snapshots, new ValueSpecificationProvider(providers));
  }
View Full Code Here

  public HistoricalShockMarketDataSnapshot snapshot(MarketDataSpecification marketDataSpec) {
    if (!(marketDataSpec instanceof HistoricalShockMarketDataSpecification)) {
      throw new IllegalArgumentException("Market data spec not HistoricalShockMarketDataSpecification: " + marketDataSpec);
    }
    HistoricalShockMarketDataSpecification shockSpec = (HistoricalShockMarketDataSpecification) marketDataSpec;
    MarketDataSnapshot snapshot1 = _historicalProvider1.snapshot(shockSpec.getHistoricalSpecification1());
    MarketDataSnapshot snapshot2 = _historicalProvider2.snapshot(shockSpec.getHistoricalSpecification2());
    MarketDataSnapshot baseSnapshot = _baseProvider.snapshot(shockSpec.getBaseSpecification());
    return new HistoricalShockMarketDataSnapshot(shockSpec.getShockType(), snapshot1, snapshot2, baseSnapshot);
  }
View Full Code Here

          try {
            try {
              final SingleComputationCycle singleComputationCycle = cycleReference.get();
              final Map<String, Collection<ComputationTargetSpecification>> configToComputationTargets = new HashMap<>();
              final Map<String, Map<ValueSpecification, Set<ValueRequirement>>> configToTerminalOutputs = new HashMap<>();
              final MarketDataSnapshot marketDataSnapshot = snapshotManager.getSnapshot();

              for (DependencyGraphExplorer graphExp : compiledViewDefinition.getDependencyGraphExplorers()) {
                final DependencyGraph graph = graphExp.getWholeGraph();
                configToComputationTargets.put(graph.getCalculationConfigurationName(), graph.getAllComputationTargets());
                configToTerminalOutputs.put(graph.getCalculationConfigurationName(), graph.getTerminalOutputs());
              }
              if (isTerminated()) {
                return;
              }
              cycleStarted(new DefaultViewCycleMetadata(
                  cycleReference.get().getUniqueId(),
                  marketDataSnapshot.getUniqueId(),
                  compiledViewDefinition.getViewDefinition().getUniqueId(),
                  versionCorrection,
                  executionOptions.getValuationTime(),
                  singleComputationCycle.getAllCalculationConfigurationNames(),
                  configToComputationTargets,
View Full Code Here

    msg3b.add(_marketDataRequirement, 52.17);
    client.marketDataReceived(new LiveDataSpecification(client.getDefaultNormalizationRuleSetId(), getTicker("test1")), msg1);
    client.marketDataReceived(new LiveDataSpecification(client.getDefaultNormalizationRuleSetId(), getTicker("test2")), msg2);
    client.marketDataReceived(new LiveDataSpecification(client.getDefaultNormalizationRuleSetId(), getTicker("test3")), msg3a);
    client.marketDataReceived(new LiveDataSpecification(client.getDefaultNormalizationRuleSetId(), getTicker("test3")), msg3b);
    final MarketDataSnapshot snapshot = provider.snapshot(null);
    snapshot.init(Collections.<ValueSpecification>emptySet(), 0, TimeUnit.MILLISECONDS);
    final Double test1Value = (Double) snapshot.query(test1Specification);
    assertNotNull(test1Value);
    assertEquals(52.07, test1Value, 0.000001);
    final Double test2Value = (Double) snapshot.query(test2Specification);
    assertNotNull(test2Value);
    assertEquals(52.15, test2Value, 0.000001);
    final Double test3Value = (Double) snapshot.query(test3Specification);
    assertNotNull(test3Value);
    assertEquals(52.17, test3Value, 0.000001);
    assertNull(snapshot.query(constructSpecification("invalidticker")));
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.marketdata.MarketDataSnapshot

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.