Package com.opengamma.core.marketdatasnapshot

Examples of com.opengamma.core.marketdatasnapshot.ValueSnapshot


    final HashMap<YieldCurveKey, YieldCurveSnapshot> yieldCurves = new HashMap<YieldCurveKey, YieldCurveSnapshot>();

    final ExternalIdBundle specA = ExternalId.of("XXX", "AAA").toBundle();
    final ExternalIdBundle specB = ExternalIdBundle.of(ExternalId.of("XXX", "B1"), ExternalId.of("XXX", "B2"));

    globalValues.putValue(specA, "X", new ValueSnapshot(Double.valueOf(12), null));
    globalValues.putValue(specA, "Y", new ValueSnapshot(Double.valueOf(1), null));
    globalValues.putValue(specA, "Z", new ValueSnapshot(null, null));
    globalValues.putValue(specB, "X", new ValueSnapshot(Double.valueOf(12), Double.valueOf(11)));

    final ManageableYieldCurveSnapshot manageableYieldCurveSnapshot = new ManageableYieldCurveSnapshot();
    manageableYieldCurveSnapshot.setValuationTime(Instant.now());
    manageableYieldCurveSnapshot.setValues(globalValues);
    yieldCurves.put(new YieldCurveKey(Currency.GBP, "Default"), manageableYieldCurveSnapshot);

    snapshot1.setYieldCurves(yieldCurves);

    final HashMap<Pair<Tenor, Tenor>, ValueSnapshot> strikes = new HashMap<Pair<Tenor, Tenor>, ValueSnapshot>();
    strikes.put(Pair.of(Tenor.DAY, Tenor.WORKING_WEEK), new ValueSnapshot(12.0, 12.0));
    strikes.put(Pair.of(Tenor.DAY, Tenor.WORKING_WEEK), null);

    final HashMap<VolatilityCubeKey, VolatilityCubeSnapshot> volCubes = new HashMap<VolatilityCubeKey, VolatilityCubeSnapshot>();
    final ManageableVolatilityCubeSnapshot volCube = new ManageableVolatilityCubeSnapshot();

    volCube.setOtherValues(globalValues);
    volCube.setValues(new HashMap<VolatilityPoint, ValueSnapshot>());
    volCube.setStrikes(strikes);
    volCube.getValues().put(new VolatilityPoint(Tenor.DAY, Tenor.YEAR, -1), new ValueSnapshot(null, null));

    volCubes.put(new VolatilityCubeKey(Currency.USD, "Default"), volCube);
    snapshot1.setVolatilityCubes(volCubes);

    MarketDataSnapshotDocument doc1 = new MarketDataSnapshotDocument(snapshot1);
View Full Code Here


    //fill with nulls
    VolatilityCubeDefinition definition = _cubeDefinitionSource.getDefinition(key.getCurrency(), key.getName());
   
    Iterable<VolatilityPoint> allPoints = definition.getAllPoints();
    for (VolatilityPoint point : allPoints) {
      values.put(point, new ValueSnapshot(null));
    }
   
    for (Entry<VolatilityPoint, Double> ycp : volatilityCubeData.getDataPoints().entrySet()) {
      values.put(ycp.getKey(), new ValueSnapshot(ycp.getValue()));
    }  

    Map<Pair<Tenor, Tenor>, ValueSnapshot> strikes = new HashMap<Pair<Tenor, Tenor>, ValueSnapshot>();
    for (Entry<Pair<Tenor, Tenor>, Double> strike : volatilityCubeData.getATMStrikes().entrySet()) {
      strikes.put(strike.getKey(), new ValueSnapshot(strike.getValue()));
    }

    ret.setOtherValues(otherValues);
    ret.setValues(values);
    ret.setStrikes(strikes);
View Full Code Here

        resolvedValues.add(computedValue.getSpecification());
        final DependencyNode nodeProducing = graph.getNodeProducing(computedValue.getSpecification());
        if ((nodeProducing != null) && isTerminalUnstructuredOutput(nodeProducing, graph)) {
          ExternalIdBundle identifiers = resolveExternalIdBundle(resolver, computedValue.getSpecification());
          if (identifiers != null) {
            snapshot.putValue(identifiers, computedValue.getSpecification().getValueName(), new ValueSnapshot(computedValue.getValue()));
          }
        }
      }
      //missing values go over the wire as nulls
      SetView<ValueSpecification> missingValues = Sets.difference(graph.getAllRequiredMarketData(), resolvedValues);
View Full Code Here

  protected static ManageableUnstructuredMarketDataSnapshot getUnstructured(final SnapshotDataBundle bundle) {
    final Set<Entry<ExternalIdBundle, Double>> bundlePoints = bundle.getDataPointSet();
    final ManageableUnstructuredMarketDataSnapshot snapshot = new ManageableUnstructuredMarketDataSnapshot();
    for (final Map.Entry<ExternalIdBundle, Double> bundlePoint : bundle.getDataPointSet()) {
      snapshot.putValue(bundlePoint.getKey(), MarketDataRequirementNames.MARKET_VALUE, new ValueSnapshot(bundlePoint.getValue()));
    }
    return snapshot;
  }
View Full Code Here

    Map<Pair<Object, Object>, ValueSnapshot> dict = new HashMap<Pair<Object, Object>, ValueSnapshot>();
    for (Object x : volatilitySurfaceData.getXs()) {
      for (Object y : volatilitySurfaceData.getYs()) {
        Double volatility = volatilitySurfaceData.getVolatility(x, y);
        ObjectsPair<Object, Object> volKey = Pair.of(x, y);
        dict.put(volKey, new ValueSnapshot(volatility));
      }
    }

    ManageableVolatilitySurfaceSnapshot ret = new ManageableVolatilitySurfaceSnapshot();
    ret.setValues(dict);
View Full Code Here

  public void testPutGetRemove_externalId() {

    final ManageableUnstructuredMarketDataSnapshot object = new ManageableUnstructuredMarketDataSnapshot();
    assertTrue(object.isEmpty());
    object.putValue(_eid1, "V1", new ValueSnapshot(11d));
    object.putValue(_eid1, "V2", new ValueSnapshot(12d));
    object.putValue(_eid2, "V1", new ValueSnapshot(21d));
    object.putValue(_eid2, "V2", new ValueSnapshot(22d));
    assertFalse(object.isEmpty());
    assertEquals(object.getTargets(), ImmutableSet.of(_eid1.toBundle(), _eid2.toBundle()));
    assertEquals(object.getValue(_eid1, "V1"), new ValueSnapshot(11d));
    assertEquals(object.getValue(_eid1, "V2"), new ValueSnapshot(12d));
    assertNull(object.getValue(_eid1, "V3"));
    assertEquals(object.getValue(_eid2, "V1"), new ValueSnapshot(21d));
    assertEquals(object.getValue(_eid2, "V2"), new ValueSnapshot(22d));
    assertNull(object.getValue(_eid2, "V3"));
    assertNull(object.getValue(_eid3, "V1"));
    assertNull(object.getValue(_eid3, "V2"));
    assertEquals(object.getValue(ExternalIdBundle.of(_eid1, _eid3), "V1"), new ValueSnapshot(11d));
    final ManageableUnstructuredMarketDataSnapshot cloned = new ManageableUnstructuredMarketDataSnapshot(object);
    object.removeValue(_eid1, "V1");
    object.removeValue(_eid2, "V1");
    assertEquals(object.getTargets(), ImmutableSet.of(_eid1.toBundle(), _eid2.toBundle()));
    assertNull(object.getValue(_eid1, "V1"));
    assertEquals(object.getValue(_eid1, "V2"), new ValueSnapshot(12d));
    assertNull(object.getValue(_eid2, "V1"));
    assertEquals(object.getValue(_eid2, "V2"), new ValueSnapshot(22d));
    object.removeValue(_eid1, "V2");
    assertEquals(object.getTargets(), ImmutableSet.of(_eid2.toBundle()));
    object.removeValue(_eid2, "V2");
    assertEquals(object.getTargets(), Collections.emptySet());
    assertTrue(object.isEmpty());
    assertEquals(cloned.getValue(_eid1, "V1"), new ValueSnapshot(11d));
    assertEquals(cloned.getValue(_eid1, "V2"), new ValueSnapshot(12d));
    assertEquals(cloned.getValue(_eid2, "V1"), new ValueSnapshot(21d));
    assertEquals(cloned.getValue(_eid2, "V2"), new ValueSnapshot(22d));
  }
View Full Code Here

  }

  public void testPutGetRemove_externalIdBundle() {
    final ManageableUnstructuredMarketDataSnapshot object = new ManageableUnstructuredMarketDataSnapshot();
    assertTrue(object.isEmpty());
    object.putValue(ExternalIdBundle.of(_eid1, _eid2), "V1", new ValueSnapshot(1d));
    object.putValue(ExternalIdBundle.of(_eid2, _eid3), "V2", new ValueSnapshot(2d));
    assertEquals(object.getTargets(), ImmutableSet.of(ExternalIdBundle.of(_eid1, _eid2), ExternalIdBundle.of(_eid2, _eid3)));
    assertFalse(object.isEmpty());
    assertEquals(object.getValue(ExternalIdBundle.of(_eid1, _eid2), "V1"), new ValueSnapshot(1d));
    assertEquals(object.getValue(ExternalIdBundle.of(_eid1, _eid2), "V2"), new ValueSnapshot(2d));
    assertEquals(object.getValue(_eid1, "V1"), new ValueSnapshot(1d));
    assertNull(object.getValue(_eid1, "V2"));
    assertEquals(object.getValue(_eid2, "V1"), new ValueSnapshot(1d));
    assertEquals(object.getValue(_eid2, "V2"), new ValueSnapshot(2d));
    object.putValue(ExternalIdBundle.of(_eid2, _eid3), "V1", new ValueSnapshot(3d));
    assertEquals(object.getTargets(), ImmutableSet.of(ExternalIdBundle.of(_eid2, _eid3)));
    assertNull(object.getValue(_eid1, "V1"));
    assertNull(object.getValue(_eid1, "V2"));
    assertEquals(object.getValue(_eid2, "V1"), new ValueSnapshot(3d));
    assertEquals(object.getValue(_eid2, "V2"), new ValueSnapshot(2d));
    assertEquals(object.getValue(_eid3, "V1"), new ValueSnapshot(3d));
    assertEquals(object.getValue(_eid3, "V2"), new ValueSnapshot(2d));
    final ManageableUnstructuredMarketDataSnapshot cloned = new ManageableUnstructuredMarketDataSnapshot(object);
    object.removeValue(ExternalIdBundle.of(_eid2, _eid3), "V1");
    assertEquals(object.getTargets(), ImmutableSet.of(ExternalIdBundle.of(_eid2, _eid3)));
    assertNull(object.getValue(_eid2, "V1"));
    assertEquals(object.getValue(_eid2, "V2"), new ValueSnapshot(2d));
    assertNull(object.getValue(_eid3, "V1"));
    assertEquals(object.getValue(_eid3, "V2"), new ValueSnapshot(2d));
    object.removeValue(ExternalIdBundle.of(_eid1, _eid2), "V2");
    assertEquals(object.getTargets(), Collections.emptySet());
    assertTrue(object.isEmpty());
    assertEquals(cloned.getValue(_eid2, "V1"), new ValueSnapshot(3d));
    assertEquals(cloned.getValue(_eid2, "V2"), new ValueSnapshot(2d));
    assertEquals(cloned.getValue(_eid3, "V1"), new ValueSnapshot(3d));
  }
View Full Code Here

    for (final FudgeField fudgeField : message.getAllByOrdinal(1)) {
      final FudgeMsg innerValue = (FudgeMsg) fudgeField.getValue();
      final ExternalIdBundle identifiers = deserializer.fieldValueToObject(ExternalIdBundle.class, innerValue.getByName(IDENTIFIERS_FIELD_NAME));
      final String valueName = innerValue.getFieldValue(String.class, innerValue.getByName(VALUE_NAME_FIELD_NAME));
      final FudgeField valueField = innerValue.getByName(VALUE_FIELD_NAME);
      final ValueSnapshot value = valueField == null ? null : deserializer.fieldValueToObject(ValueSnapshot.class, valueField);
      object.putValue(identifiers, valueName, value);
    }
    return object;
  }
View Full Code Here

      int intValue = ordinal.intValue();
      if (intValue == 1) {
        key = ObjectsPairFudgeBuilder.buildObject(deserializer, (FudgeMsg) fudgeField.getValue(), Tenor.class, Tenor.class);
      } else if (intValue == 2) {
        ValueSnapshot value = deserializer.fieldValueToObject(ValueSnapshot.class, fudgeField);
        values.put(key, value);
        key = null;
      }
    }
    return values;
View Full Code Here

      }
      int intValue = ordinal.intValue();
      if (intValue == 1) {
        key = deserializer.fieldValueToObject(VolatilityPoint.class, fudgeField);
      } else if (intValue == 2) {
        ValueSnapshot value = deserializer.fieldValueToObject(ValueSnapshot.class, fudgeField);
        values.put(key, value);
        key = null;
      }
    }
    return values;
View Full Code Here

TOP

Related Classes of com.opengamma.core.marketdatasnapshot.ValueSnapshot

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.