Examples of CurveSpecification


Examples of com.opengamma.financial.analytics.curve.CurveSpecification

      final List<FudgeField> resolvedStripFields = message.getAllByName(RESOLVED_STRIPS_FIELD);
      final List<CurveNodeWithIdentifier> resolvedStrips = new ArrayList<>();
      for (final FudgeField resolvedStripField : resolvedStripFields) {
        resolvedStrips.add(deserializer.fieldValueToObject(CurveNodeWithIdentifier.class, resolvedStripField));
      }
      return new CurveSpecification(curveDate, name, resolvedStrips);
    }
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

            .with(ValuePropertyNames.CURVE, curveName)
            .get();
        final ValueRequirement bundleRequirement = new ValueRequirement(ValueRequirementNames.CURVE_HISTORICAL_TIME_SERIES, targetSpec, properties);
        final ValueRequirement specRequirement = new ValueRequirement(ValueRequirementNames.CURVE_SPECIFICATION, targetSpec, properties);
        final HistoricalTimeSeriesBundle bundleForCurve = (HistoricalTimeSeriesBundle) inputs.getValue(bundleRequirement);
        final CurveSpecification curveSpec = (CurveSpecification) inputs.getValue(specRequirement);
        for (final CurveNodeWithIdentifier node : curveSpec.getNodes()) {
          String dataField = node.getDataField();
          ExternalIdBundle ids = ExternalIdBundle.of(node.getIdentifier());
          HistoricalTimeSeries ts = bundleForCurve.get(dataField, ids);
          if (ts != null) {
            bundle.add(dataField, ids, bundleForCurve.get(dataField, ids));
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

        ExternalId.of("Test", "F"), "C", DataFieldType.OUTRIGHT));
  }

  @Test
  public void testCurveSpecification() {
    final CurveSpecification specification = new CurveSpecification(LocalDate.of(2013, 1, 1), "NAME", NODES);
    assertEquals(specification, cycleObject(CurveSpecification.class, specification));
  }
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final HistoricalTimeSeriesSource timeSeriesSource = OpenGammaExecutionContext.getHistoricalTimeSeriesSource(executionContext);
    final ConfigSource configSource = OpenGammaExecutionContext.getConfigSource(executionContext);
    final String idName = desiredValue.getConstraint(ValuePropertyNames.CURVE);
    final String curveName = idName;
    final CurveSpecification curveSpecification = CurveUtils.getCurveSpecification(now.toInstant(), configSource, now.toLocalDate(), curveName);
    final String dataField = desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY);
    final String resolutionKey;
    final Set<String> resolutionKeyConstraint = desiredValue.getConstraints().getValues(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY);
    if (resolutionKeyConstraint == null || resolutionKeyConstraint.size() != 1) {
      resolutionKey = "Null";
    } else {
      resolutionKey = Iterables.getOnlyElement(resolutionKeyConstraint);
    }
    final LocalDate startDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY));
    final boolean includeStart = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY));
    final Set<String> endDateConstraint = desiredValue.getConstraints().getValues(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY);
    final String endDateString;
    if (endDateConstraint == null || endDateConstraint.size() != 1) {
      endDateString = "Now";
    } else {
      endDateString = Iterables.getOnlyElement(endDateConstraint);
    }
    final LocalDate endDate = DateConstraint.evaluate(executionContext, endDateString);
    final boolean includeEnd = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY));
    final HistoricalTimeSeriesBundle bundle = new HistoricalTimeSeriesBundle();
    final Set<CurveNodeWithIdentifier> nodes = curveSpecification.getNodes();
    for (final CurveNodeWithIdentifier node : nodes) {
      final ExternalIdBundle identifier = ExternalIdBundle.of(node.getIdentifier());
      final HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, identifier, resolutionKey, startDate, includeStart, endDate, includeEnd);
      if (timeSeries != null) {
        bundle.add(dataField, identifier, timeSeries);
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

    final String resolutionKey = parseString(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY));
    final LocalDate startDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY));
    final boolean includeStart = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY));
    final LocalDate endDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY));
    final boolean includeEnd = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY));
    final CurveSpecification curve = (CurveSpecification) inputs.getAllValues().iterator().next().getValue();
    final HistoricalTimeSeriesBundle bundle = new HistoricalTimeSeriesBundle();
    for (final CurveNodeWithIdentifier node : curve.getNodes()) {
      ExternalIdBundle id = ExternalIdBundle.of(node.getIdentifier());
      String dataField = node.getDataField();
      HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, id, resolutionKey, startDate, includeStart, endDate, includeEnd);
      if (timeSeries != null) {
        if (timeSeries.getTimeSeries().isEmpty()) {
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

    final CreditSecurityToIdentifierVisitor identifierVisitor = new CreditSecurityToIdentifierVisitor(OpenGammaExecutionContext.getSecuritySource(executionContext));
    final FinancialSecurity security = (FinancialSecurity) target.getPosition().getSecurity();
    final String spreadCurveName = security.accept(identifierVisitor).getUniqueId().getValue();
    //TODO
    final String curveName = getCurvePrefix() + "_" + spreadCurveName;
    final CurveSpecification curveSpecification = CurveUtils.getCurveSpecification(snapshotClock.instant(), configSource, now, curveName);
    DoubleTimeSeries<?> fxSeries = null;
    boolean isInverse = true;
    if (!desiredCurrency.equals(currency)) {
      final Object fxSeriesObject = inputs.getValue(ValueRequirementNames.HISTORICAL_FX_TIME_SERIES);
      if (fxSeriesObject == null) {
        throw new OpenGammaRuntimeException("Could not get historical FX series");
      }
      @SuppressWarnings("unchecked")
      final Map.Entry<UnorderedCurrencyPair, DoubleTimeSeries<?>> entry = Iterables.getOnlyElement(((Map<UnorderedCurrencyPair, DoubleTimeSeries<?>>) fxSeriesObject).entrySet());
      final Object currencyPairObject = inputs.getValue(ValueRequirementNames.CURRENCY_PAIRS);
      if (currencyPairObject == null) {
        throw new OpenGammaRuntimeException("Could not get currency pairs");
      }
      final CurrencyPairs currencyPairs = (CurrencyPairs) currencyPairObject;
      if (desiredCurrency.equals(currencyPairs.getCurrencyPair(Currency.of(desiredCurrency), Currency.of(currency)).getCounter().getCode())) {
        isInverse = false;
      }
      fxSeries = entry.getValue();
    }
    final Object bucketedCS01Object = inputs.getValue(ValueRequirementNames.BUCKETED_CS01);
    if (bucketedCS01Object == null) {
      throw new OpenGammaRuntimeException("Could not get bucketed CS01");
    }
    final LocalDateLabelledMatrix1D bucketedCS01 = (LocalDateLabelledMatrix1D) bucketedCS01Object;
    final Object htsObject = inputs.getValue(ValueRequirementNames.CREDIT_SPREAD_CURVE_HISTORICAL_TIME_SERIES);
    if (htsObject == null) {
      throw new OpenGammaRuntimeException("Could not get credit spread curve historical time series");
    }
    final HistoricalTimeSeriesBundle hts = (HistoricalTimeSeriesBundle) htsObject;
    final NavigableSet<CurveNodeWithIdentifier> nodes = getNodes(now, security, curveSpecification.getNodes());
    DoubleTimeSeries<?> pnlSeries = getPnLSeries(nodes, bucketedCS01, hts, schedule, samplingFunction, fxSeries, isInverse);
    if (pnlSeries == null) {
      throw new OpenGammaRuntimeException("Could not get any values for security " + position.getSecurity());
    }
    pnlSeries = pnlSeries.multiply(position.getQuantity().doubleValue());
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

        final SingleCurveBundle<GeneratorPriceIndexCurve>[] singleCurves = new SingleCurveBundle[nCurves];
        for (final Map.Entry<String, List<CurveTypeConfiguration>> entry : group.getTypesForCurves().entrySet()) {
          final List<IndexPrice> inflation = new ArrayList<>();
          final String curveName = entry.getKey();
          final ValueProperties properties = ValueProperties.builder().with(CURVE, curveName).get();
          final CurveSpecification specification =
              (CurveSpecification) inputs.getValue(new ValueRequirement(CURVE_SPECIFICATION, ComputationTargetSpecification.NULL, properties));
          final CurveDefinition definition =
              (CurveDefinition) inputs.getValue(new ValueRequirement(CURVE_DEFINITION, ComputationTargetSpecification.NULL, properties));
          final SnapshotDataBundle snapshot =
              (SnapshotDataBundle) inputs.getValue(new ValueRequirement(CURVE_MARKET_DATA, ComputationTargetSpecification.NULL, properties));
          final int nNodes = specification.getNodes().size();
          final InstrumentDerivative[] derivativesForCurve = new InstrumentDerivative[nNodes];
          final double[] parameterGuessForCurves = new double[nNodes];
          int k = 0;
          for (final CurveNodeWithIdentifier node : specification.getNodes()) { // Node points - start
            final Double marketData = snapshot.getDataPoint(node.getIdentifier());
            if (marketData == null) {
              throw new OpenGammaRuntimeException("Could not get market data for " + node.getIdentifier());
            }
            final InstrumentDefinition<?> definitionForNode = node.getCurveNode().accept(getCurveNodeConverter(conventionSource, holidaySource, regionSource,
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

      } else {
        interpolatorName = Interpolator1DFactory.LINEAR;
        leftExtrapolatorName = Interpolator1DFactory.LINEAR_EXTRAPOLATOR;
        rightExtrapolatorName = Interpolator1DFactory.LINEAR_EXTRAPOLATOR;
      }
      final CurveSpecification specification = (CurveSpecification) inputs.getValue(CURVE_SPECIFICATION);
      final SnapshotDataBundle data = (SnapshotDataBundle) inputs.getValue(CURVE_MARKET_DATA);
      final DoubleArrayList tList = new DoubleArrayList();
      final DoubleArrayList fxList = new DoubleArrayList();
      for (final CurveNodeWithIdentifier nodeWithId : specification.getNodes()) {
        final CurveNode node = nodeWithId.getCurveNode();
        if (!(node instanceof FXForwardNode)) {
          throw new OpenGammaRuntimeException("Unexpected node " + nodeWithId + " found");
        }
        final Double fxForward = data.getDataPoint(nodeWithId.getIdentifier());
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

    final Clock snapshotClock = executionContext.getValuationClock();
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
    final ConventionSource conventionSource = OpenGammaExecutionContext.getConventionSource(executionContext);

    final CurveSpecification specification = (CurveSpecification) inputs.getValue(ValueRequirementNames.CURVE_SPECIFICATION);
    final SnapshotDataBundle snapshot = (SnapshotDataBundle) inputs.getValue(ValueRequirementNames.CURVE_MARKET_DATA);
    final LocalDate spotDate = (!desiredValue.getConstraints().getValues(ISDAFunctionConstants.ISDA_CURVE_DATE).isEmpty())
        ? LocalDate.parse(desiredValue.getConstraint(ISDAFunctionConstants.ISDA_CURVE_DATE))
        : now.toLocalDate();

    DepositConvention cashConvention = null;
    VanillaIborLegConvention floatLegConvention = null;
    SwapFixedLegConvention fixLegConvention = null;
    IborIndexConvention liborConvention = null;

    final int nNodes = specification.getNodes().size();
    final double[] marketDataForCurve = new double[nNodes];
    final ISDAInstrumentTypes[] instruments = new ISDAInstrumentTypes[nNodes];
    final Period[] tenors = new Period[nNodes];
    int k = 0;
    for (final CurveNodeWithIdentifier node : specification.getNodes()) {
      final Double marketData = snapshot.getDataPoint(node.getIdentifier());
      if (marketData == null) {
        throw new OpenGammaRuntimeException("Could not get market data for " + node.getIdentifier());
      }
      marketDataForCurve[k] = marketData;
View Full Code Here

Examples of com.opengamma.financial.analytics.curve.CurveSpecification

        for (final Map.Entry<String, List<CurveTypeConfiguration>> entry : group.getTypesForCurves().entrySet()) {
          final List<IborIndex> iborIndex = new ArrayList<>();
          final List<IndexON> overnightIndex = new ArrayList<>();
          final String curveName = entry.getKey();
          final ValueProperties properties = ValueProperties.builder().with(CURVE, curveName).get();
          final CurveSpecification specification =
              (CurveSpecification) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_SPECIFICATION, ComputationTargetSpecification.NULL, properties));
          final CurveDefinition definition =
              (CurveDefinition) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_DEFINITION, ComputationTargetSpecification.NULL, properties));
          final SnapshotDataBundle snapshot =
              (SnapshotDataBundle) inputs.getValue(new ValueRequirement(ValueRequirementNames.CURVE_MARKET_DATA, ComputationTargetSpecification.NULL, properties));
          final int nNodes = specification.getNodes().size();
          final InstrumentDerivative[] derivativesForCurve = new InstrumentDerivative[nNodes];
          final double[] parameterGuessForCurves = new double[nNodes];
          int k = 0;
          for (final CurveNodeWithIdentifier node : specification.getNodes()) { // Node points - start
            Double marketData = snapshot.getDataPoint(node.getIdentifier());
            if (marketData == null) {
              marketData = 0.99;
            }
            if (node.getCurveNode() instanceof RateFutureNode) {
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.