Examples of SnapshotDataBundle


Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

    private VolatilityCubeData buildMarketDataMap(final ComputationTargetResolver.AtVersionCorrection targetResolver, final FunctionInputs inputs) {
      final HashMap<VolatilityPoint, Double> dataPoints = new HashMap<>();
      final HashMap<VolatilityPoint, ExternalIdBundle> dataIds = new HashMap<>();
      final HashMap<VolatilityPoint, Double> relativeStrikes = new HashMap<>();
      final HashMap<Pair<Tenor, Tenor>, Double> strikes = new HashMap<>();
      final SnapshotDataBundle otherData = new SnapshotDataBundle();
      final ExternalIdBundleResolver resolver = new ExternalIdBundleResolver(targetResolver);
      for (final ComputedValue value : inputs.getAllValues()) {
        if (!(value.getValue() instanceof Double)) {
          continue;
        }
        final Double dValue = (Double) value.getValue();
        final ExternalIdBundle identifiers = value.getSpecification().getTargetSpecification().accept(resolver);
        final VolatilityPoint volatilityPoint;
        final Pair<Tenor, Tenor> strikePoint;
        if (value.getSpecification().getValueName() == MarketDataRequirementNames.MARKET_VALUE) {
          volatilityPoint = getByIdentifier(_pointsById, identifiers);
          strikePoint = getByIdentifier(_strikesById, identifiers);
        } else {
          volatilityPoint = null;
          strikePoint = null;
        }
        if (volatilityPoint == null && strikePoint == null) {
          otherData.setDataPoint(identifiers, dValue);
        } else if (volatilityPoint != null && strikePoint == null) {
          if (volatilityPoint.getRelativeStrike() > -50) {
            final Double previous = dataPoints.put(volatilityPoint, dValue);
            final ExternalIdBundle previousIds = dataIds.put(volatilityPoint, identifiers);
            final Double previousRelativeStrike = relativeStrikes.put(volatilityPoint, volatilityPoint.getRelativeStrike());
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

        return result;
      }

      @Override
      public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
        final SnapshotDataBundle marketData = _helper.getMarketDataMap(inputs);
        // Gather market data rates
        // Note that this assumes that all strips are priced in decimal percent. We need to resolve
        // that ultimately in OG-LiveData normalization and pull out the OGRate key rather than
        // the crazy IndicativeValue name.
        final FixedIncomeStripIdentifierAndMaturityBuilder builder = new FixedIncomeStripIdentifierAndMaturityBuilder(OpenGammaExecutionContext.getRegionSource(executionContext),
            OpenGammaExecutionContext.getConventionBundleSource(executionContext), executionContext.getSecuritySource(), OpenGammaExecutionContext.getHolidaySource(executionContext));
        final InterpolatedYieldCurveSpecificationWithSecurities specWithSecurities = builder.resolveToSecurity(specification, marketData);
        final Clock snapshotClock = executionContext.getValuationClock();
        final ZonedDateTime today = ZonedDateTime.now(snapshotClock); // TODO: change to times
        final Map<Double, Double> timeInYearsToRates = new TreeMap<Double, Double>();
        boolean isFirst = true;
        for (final FixedIncomeStripWithSecurity strip : specWithSecurities.getStrips()) {
          Double price = marketData.getDataPoint(strip.getSecurityIdentifier());
          if (strip.getInstrumentType() == StripInstrumentType.FUTURE) {
            price = 100d - price;
          }
          price /= 100d;
          if (_isYieldCurve) {
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

    @Override
    public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
      try {
        final FixedIncomeStripIdentifierAndMaturityBuilder builder = new FixedIncomeStripIdentifierAndMaturityBuilder(OpenGammaExecutionContext.getRegionSource(executionContext),
            OpenGammaExecutionContext.getConventionBundleSource(executionContext), executionContext.getSecuritySource(), OpenGammaExecutionContext.getHolidaySource(executionContext));
        final SnapshotDataBundle marketData = getHelper().getMarketDataMap(inputs);
        final InterpolatedYieldCurveSpecificationWithSecurities curveSpecificationWithSecurities = builder.resolveToSecurity(getCurveSpecification(), marketData);
        return Collections.singleton(new ComputedValue(getResultSpecification(), curveSpecificationWithSecurities));
      } catch (final OpenGammaRuntimeException e) {
        throw new OpenGammaRuntimeException("Error in constructing " + _helper.getCurveName() + "_" + _helper.getCurrency() + ": " + e.getMessage());
      }
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

    }
    return Collections.unmodifiableSet(result);
  }

  private static SnapshotDataBundle buildMarketDataMap(final FunctionExecutionContext context, final FunctionInputs inputs) {
    final SnapshotDataBundle marketData = new SnapshotDataBundle();
    final ExternalIdBundleResolver resolver = new ExternalIdBundleResolver(context.getComputationTargetResolver());
    for (final ComputedValue value : inputs.getAllValues()) {
      final ExternalIdBundle identifiers = value.getSpecification().getTargetSpecification().accept(resolver);
      double rate = (Double) value.getValue();
      //TODO this is here because KWCDC Curncy is not normalized
      if (rate > 1.1) {
        s_logger.error("Normalizing {}, value {}", value.getSpecification(), rate);
        s_logger.warn("Performing normalization of rate in YieldCurveMarketDataFunction; if this is being used for anything other than KWCDC Curncy check market data normalization");
        rate /= 100;
      }
      marketData.setDataPoint(identifiers, rate);
    }
    return marketData;
  }
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

    }

    @Override
    public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs,
        final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
      final SnapshotDataBundle map = buildMarketDataMap(executionContext, inputs);
      return Sets.newHashSet(new ComputedValue(_marketDataResult, map));
    }
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

    @Override
    public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
      final FixedIncomeStripIdentifierAndMaturityBuilder builder = new FixedIncomeStripIdentifierAndMaturityBuilder(OpenGammaExecutionContext.getRegionSource(executionContext),
          OpenGammaExecutionContext.getConventionBundleSource(executionContext), executionContext.getSecuritySource(), OpenGammaExecutionContext.getHolidaySource(executionContext));
      final SnapshotDataBundle marketData = new SnapshotDataBundle();
      for (final FixedIncomeStripWithIdentifier strip : getCurveSpecification().getStrips()) {
        marketData.setDataPoint(strip.getSecurity(), 0);
      }
      final InterpolatedYieldCurveSpecificationWithSecurities curveSpecificationWithSecurities = resolveToDummySecurity(getCurveSpecification(), marketData, _currency);
      return Collections.singleton(new ComputedValue(_resultSpec, curveSpecificationWithSecurities));
    }
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

    private VolatilityCubeData buildMarketDataMap(final FunctionExecutionContext context, final FunctionInputs inputs) {
      final HashMap<VolatilityPoint, Double> dataPoints = new HashMap<>();
      final HashMap<VolatilityPoint, ExternalIdBundle> dataIds = new HashMap<>();
      final HashMap<VolatilityPoint, Double> relativeStrikes = new HashMap<>();
      final HashMap<Pair<Tenor, Tenor>, Double> strikes = new HashMap<>();
      final SnapshotDataBundle otherData = new SnapshotDataBundle();
      final ExternalIdBundleResolver resolver = new ExternalIdBundleResolver(context.getComputationTargetResolver());
      for (final ComputedValue value : inputs.getAllValues()) {
        if (!(value.getValue() instanceof Double)) {
          continue;
        }
        final Double dValue = (Double) value.getValue();
        final ExternalIdBundle identifiers = value.getSpecification().getTargetSpecification().accept(resolver);
        final VolatilityPoint volatilityPoint;
        final Pair<Tenor, Tenor> strikePoint;
        if (value.getSpecification().getValueName() == MarketDataRequirementNames.MARKET_VALUE) {
          volatilityPoint = getByIdentifier(_pointsById, identifiers);
          strikePoint = getByIdentifier(_strikesById, identifiers);
        } else {
          volatilityPoint = null;
          strikePoint = null;
        }
        if (volatilityPoint == null && strikePoint == null) {
          otherData.setDataPoint(identifiers, dValue);
        } else if (volatilityPoint != null && strikePoint == null) {
          if (volatilityPoint.getRelativeStrike() > -50) {
            final Double previous = dataPoints.put(volatilityPoint, dValue);
            final ExternalIdBundle previousIds = dataIds.put(volatilityPoint, identifiers);
            final Double previousRelativeStrike = relativeStrikes.put(volatilityPoint, volatilityPoint.getRelativeStrike());
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

  @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 ValueSpecification inputSpec = input.getSpecification();
    final SnapshotDataBundle marketData = (SnapshotDataBundle) input.getValue();
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final String shift = desiredValue.getConstraint(SHIFT);
    final ValueProperties.Builder properties = createValueProperties(inputSpec).with(SHIFT, shift);
    final OverrideOperationCompiler compiler = OpenGammaExecutionContext.getOverrideOperationCompiler(executionContext);
    if (compiler == null) {
      throw new IllegalStateException("No override operation compiler for " + shift + " in execution context");
    }
    s_logger.debug("Applying {} to {}", shift, marketData);
    final OverrideOperation operation = compiler.compile(shift, executionContext.getComputationTargetResolver());
    for (final Map.Entry<ExternalIdBundle, Double> dataPoint : marketData.getDataPointSet()) {
      s_logger.debug("Applying to {}", dataPoint);
      final Object result = operation.apply(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, dataPoint.getKey()),
          dataPoint.getValue());
      s_logger.debug("Got result {}", result);
      if (result instanceof Number) {
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

  }

  @Test(expectedExceptions = OpenGammaRuntimeException.class)
  public void testNoConventionForCash() {
    final ExternalId marketDataId = ExternalId.of(SCHEME, "Data");
    final SnapshotDataBundle marketValues = new SnapshotDataBundle();
    final double rate = 0.0012345;
    marketValues.setDataPoint(marketDataId, rate);
    final CashNode cashNode = new CashNode(Tenor.ONE_DAY, Tenor.FIVE_MONTHS, ExternalId.of(SCHEME, "Test"), "Mapper");
    final CurveNodeVisitor<InstrumentDefinition<?>> converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE,
        marketValues, marketDataId, NOW);
    cashNode.accept(converter);
  }
View Full Code Here

Examples of com.opengamma.core.marketdatasnapshot.SnapshotDataBundle

  }

  @Test(expectedExceptions = OpenGammaRuntimeException.class)
  public void testWrongConventionTypeForCash() {
    final ExternalId marketDataId = ExternalId.of(SCHEME, "Data");
    final SnapshotDataBundle marketValues = new SnapshotDataBundle();
    final double rate = 0.0012345;
    marketValues.setDataPoint(marketDataId, rate);
    final CashNode cashNode = new CashNode(Tenor.ONE_DAY, Tenor.FIVE_MONTHS, FIXED_LEG_ID, "Mapper");
    final CurveNodeVisitor<InstrumentDefinition<?>> converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE,
        marketValues, marketDataId, NOW);
    cashNode.accept(converter);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.