Package com.opengamma.financial.analytics

Examples of com.opengamma.financial.analytics.DoubleLabelledMatrix1D


    final ComputationTargetSpecification specification = target.toSpecification();
    final Object value = inputs.getValue(new ValueRequirement(YCNS_REQUIREMENT, specification));
    if (!(value instanceof LabelledMatrix1D)) {
      throw new OpenGammaRuntimeException("Yield Curve Node Sensitivities result was not of type LabelledMatrix1D");
    }
    final DoubleLabelledMatrix1D ycns = (DoubleLabelledMatrix1D) value;
    final double result = sum(ycns.getValues());
    final ValueProperties properties = createCurrencyValueProperties(target)
        .with(ValuePropertyNames.CURVE, curveName)
        .with(ValuePropertyNames.CURVE_CURRENCY, curveCurrency)
        .with(ValuePropertyNames.CURVE_CALCULATION_CONFIG, curveCalculationConfig)
        .get();
View Full Code Here


      final Double[] keysArray = new Double[matrixSize];
      keys.toArray(keysArray);
      final Object[] labelsArray = new Object[matrixSize];
      labels.toArray(labelsArray);
      final double[] valuesArray = Doubles.toArray(values);
      return new DoubleLabelledMatrix1D(keysArray, labelsArray, labelsTitle, valuesArray, valuesTitle);
    }
View Full Code Here

  }

  @Override
  public YieldCurveNodeSensitivityDataBundle buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
    final Currency ccy = deserializer.fieldValueToObject(Currency.class, message.getByName(CURRENCY_FIELD_NAME));
    final DoubleLabelledMatrix1D labelledMatrix = deserializer.fieldValueToObject(DoubleLabelledMatrix1D.class, message.getByName(MATRIX_FIELD_NAME));
    final String curveName = deserializer.fieldValueToObject(String.class, message.getByName(CURVE_FIELD_NAME));
    return new YieldCurveNodeSensitivityDataBundle(ccy, labelledMatrix, curveName);
  }
View Full Code Here

    final ConfigDBCurveCalculationConfigSource curveCalculationConfigSource = new ConfigDBCurveCalculationConfigSource(configSource);
    DoubleTimeSeries<?> result = null;
    final MultiCurveCalculationConfig curveCalculationConfig = curveCalculationConfigSource.getConfig(curveCalculationConfigName);
    for (final String yieldCurveName : yieldCurveNames) {
      final ValueRequirement ycnsRequirement = getYCNSRequirement(currencyString, curveCalculationConfigName, yieldCurveName, surfaceName, target);
      final DoubleLabelledMatrix1D ycns = (DoubleLabelledMatrix1D) inputs.getValue(ycnsRequirement);
      final HistoricalTimeSeriesBundle ychts = (HistoricalTimeSeriesBundle) inputs.getValue(getYCHTSRequirement(currency, yieldCurveName, samplingPeriod.toString()));
      final DoubleTimeSeries<?> pnLSeries;
      if (curveCalculationConfig.getCalculationMethod().equals(FXImpliedYieldCurveFunction.FX_IMPLIED)) {
        pnLSeries = getPnLSeries(ycns, ychts, schedule, samplingFunction);
      } else {
View Full Code Here

  @Test
  public void test() {
    final Double[] keys = new Double[] {1., 2., 3., 4., 5.};
    final Object[] labels = new Object[] {"1y", "2y", "3y", "4y", "5y"};
    final double[] values = new double[] {0.1, 0.2, 0.3, 0.4, 0.5};
    final DoubleLabelledMatrix1D m = new DoubleLabelledMatrix1D(keys, labels, values);
    final Currency ccy = Currency.USD;
    final String curveName = "S";
    final YieldCurveNodeSensitivityDataBundle d1 = new YieldCurveNodeSensitivityDataBundle(ccy, m, curveName);
    final YieldCurveNodeSensitivityDataBundle d2 = cycleObject(YieldCurveNodeSensitivityDataBundle.class, d1);
    assertEquals(d1, d2);
View Full Code Here

    assertEquals(data, other);
    assertEquals(data.hashCode(), other.hashCode());
    assertEquals(data.getCurrency(), CCY);
    assertEquals(data.getLabelledMatrix(), M);
    assertEquals(data.getYieldCurveName(), NAME);
    other = new YieldCurveNodeSensitivityDataBundle(CCY, new DoubleLabelledMatrix1D(T, LABELS, X), NAME);
    assertFalse(other.equals(data));
    other = new YieldCurveNodeSensitivityDataBundle(Currency.GBP, M, NAME);
    assertFalse(other.equals(data));
    other = new YieldCurveNodeSensitivityDataBundle(CCY, M, "PPP");
    assertFalse(other.equals(data));
View Full Code Here

    final ComputationTargetSpecification targetSpec = target.toSpecification();
    final Object forwardCurveSensitivitiesObject = inputs.getValue(new ValueRequirement(ValueRequirementNames.YIELD_CURVE_NODE_SENSITIVITIES, targetSpec, forwardCurveProperties));
    if (forwardCurveSensitivitiesObject == null) {
      throw new OpenGammaRuntimeException("Could not get sensitivities for " + forwardCurveName);
    }
    final DoubleLabelledMatrix1D forwardCurveSensitivities = (DoubleLabelledMatrix1D) forwardCurveSensitivitiesObject;
    final Object fundingCurveSensitivitiesObject = inputs.getValue(new ValueRequirement(ValueRequirementNames.YIELD_CURVE_NODE_SENSITIVITIES, targetSpec, fundingCurveProperties));
    if (fundingCurveSensitivitiesObject == null) {
      throw new OpenGammaRuntimeException("Could not get sensitivities for " + fundingCurveName);
    }
    final DoubleLabelledMatrix1D fundingCurveSensitivities = (DoubleLabelledMatrix1D) fundingCurveSensitivitiesObject;
    final Period samplingPeriod = getSamplingPeriod(constraints.getValues(ValuePropertyNames.SAMPLING_PERIOD));
    final LocalDate startDate = now.minus(samplingPeriod);
    final Schedule scheduleCalculator = getScheduleCalculator(constraints.getValues(ValuePropertyNames.SCHEDULE_CALCULATOR));
    final TimeSeriesSamplingFunction samplingFunction = getSamplingFunction(constraints.getValues(ValuePropertyNames.SAMPLING_FUNCTION));
    final LocalDate[] schedule = HOLIDAY_REMOVER.getStrippedSchedule(scheduleCalculator.getSchedule(startDate, now, true, false), WEEKEND_CALENDAR); //REVIEW emcleod should "fromEnd" be hard-coded?
View Full Code Here

      final ValueRequirement ycnsRequirement = getYCNSRequirement(currencyString, curveCalculationConfigName, yieldCurveName, target, constraints);
      final Object ycnsObject = inputs.getValue(ycnsRequirement);
      if (ycnsObject == null) {
        throw new OpenGammaRuntimeException("Could not get yield curve node sensitivities; " + ycnsRequirement);
      }
      final DoubleLabelledMatrix1D ycns = (DoubleLabelledMatrix1D) ycnsObject;
      final ValueRequirement ychtsRequirement = getYCHTSRequirement(currency, yieldCurveName, samplingPeriod.toString());
      final Object ychtsObject = inputs.getValue(ychtsRequirement);
      if (ychtsObject == null) {
        throw new OpenGammaRuntimeException("Could not get yield curve historical time series; " + ychtsRequirement);
      }
View Full Code Here

      if (name == null) {
        name = node.getClass().getSimpleName() + " " + node.getResolvedMaturity().getPeriod();
      }
      labels[i] = name;
    }
    return new DoubleLabelledMatrix1D(keys, labels, values);
  }
View Full Code Here

      final ValueProperties constraints = desiredValue.getConstraints();
      final Set<String> resultCurrencies = constraints.getValues(CURRENCY);
      final FXForwardSecurity security = (FXForwardSecurity) position.getSecurity();
      final TenorLabelledLocalDateDoubleTimeSeriesMatrix1D ycReturnSeries = (TenorLabelledLocalDateDoubleTimeSeriesMatrix1D) inputs.getValue(ValueRequirementNames.YIELD_CURVE_RETURN_SERIES);
      final TenorLabelledLocalDateDoubleTimeSeriesMatrix1D fcReturnSeries = (TenorLabelledLocalDateDoubleTimeSeriesMatrix1D) inputs.getValue(ValueRequirementNames.FX_FORWARD_CURVE_RETURN_SERIES);
      final DoubleLabelledMatrix1D sensitivities = (DoubleLabelledMatrix1D) inputs.getValue(ValueRequirementNames.YIELD_CURVE_NODE_SENSITIVITIES);
      final Currency payCurrency = security.getPayCurrency();
      final Currency receiveCurrency = security.getReceiveCurrency();
      final CurrencyPair currencyPair = _currencyPairs.getCurrencyPair(payCurrency, receiveCurrency);
      final String curveCurrency = desiredValue.getConstraint(CURVE_CURRENCY);

      final Currency baseCurrency = currencyPair.getBase();
      final ValueProperties resultProperties = desiredValues.iterator().next().getConstraints();
      TenorLabelledLocalDateDoubleTimeSeriesMatrix1D returnSeries;
      if (ycReturnSeries != null) {
        returnSeries = ycReturnSeries;
      } else if (fcReturnSeries != null) {
        returnSeries = fcReturnSeries;
      } else {
        throw new OpenGammaRuntimeException("Could not get return series for either yield curve or FX forward curve");
      }
      if (returnSeries.size() != sensitivities.size()) {
        throw new OpenGammaRuntimeException("Yield Curve Node Sensitivities vector of size " + sensitivities.size() + " but return series vector of size " + returnSeries.size());
      }
      TenorLabelledLocalDateDoubleTimeSeriesMatrix1D pnlSeriesVector;
      if (resultCurrencies == null || resultCurrencies.size() != 1) {
        s_logger.warn("No Currency property - returns result in base currency");
        pnlSeriesVector = getPnLVector(returnSeries, sensitivities);
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.DoubleLabelledMatrix1D

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.