Package com.opengamma.financial.analytics

Examples of com.opengamma.financial.analytics.DoubleLabelledMatrix1D


  @Test
  public void testDouble() {
    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 m1 = new DoubleLabelledMatrix1D(keys, labels, values);
    final DoubleLabelledMatrix1D m2 = cycleObject(DoubleLabelledMatrix1D.class, m1);
    assertEquals(m1, m2);
    final DoubleLabelledMatrix1D m3 = new DoubleLabelledMatrix1D(keys, values);
    final DoubleLabelledMatrix1D m4 = cycleObject(DoubleLabelledMatrix1D.class, m3);
    assertEquals(m3, m4);
    final DoubleLabelledMatrix1D m5 = new DoubleLabelledMatrix1D(keys, keys, values);
    final DoubleLabelledMatrix1D m6 = cycleObject(DoubleLabelledMatrix1D.class, m5);
    assertEquals(m5, m6);
    final DoubleLabelledMatrix1D m7 = new DoubleLabelledMatrix1D(keys, labels, "labels", values, "values");
    final DoubleLabelledMatrix1D m8 = cycleObject(DoubleLabelledMatrix1D.class, m7);
    assertEquals(m7, m8);
  }
View Full Code Here


                .with(CURVE, curveName)
                .get();
            final CurveDefinition curveDefinition = (CurveDefinition) inputs.getValue(new ValueRequirement(CURVE_DEFINITION, ComputationTargetSpecification.NULL,
                ValueProperties.builder().with(CURVE, curveName).get()));
            final ValueSpecification spec = new ValueSpecification(YIELD_CURVE_NODE_SENSITIVITIES, target.toSpecification(), properties);
            final DoubleLabelledMatrix1D ycns = MultiCurveUtils.getLabelledMatrix(entry.getValue(), curveDefinition);
            return Collections.singleton(new ComputedValue(spec, ycns));
          }
        }
        throw new OpenGammaRuntimeException("Could not get sensitivities to " + curveName + " for " + target.getName());
      }
View Full Code Here

    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()) / 10000d;
    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

                .with(CURVE, curveName)
                .get();
            final CurveDefinition curveDefinition = (CurveDefinition) inputs.getValue(new ValueRequirement(CURVE_DEFINITION, ComputationTargetSpecification.NULL,
                ValueProperties.builder().with(CURVE, curveName).get()));
            final ValueSpecification spec = new ValueSpecification(YIELD_CURVE_NODE_SENSITIVITIES, target.toSpecification(), properties);
            final DoubleLabelledMatrix1D ycns = MultiCurveUtils.getLabelledMatrix(entry.getValue(), curveDefinition);
            return Collections.singleton(new ComputedValue(spec, ycns));
          }
        }
        throw new OpenGammaRuntimeException("Could not get sensitivities to " + curveName + " for " + target.getName());
      }
View Full Code Here

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
      final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
    final Position position = target.getPosition();
    final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
    final DoubleLabelledMatrix1D sensitivities = ((DoubleLabelledMatrix1D) inputs.getValue(YIELD_CURVE_NODE_SENSITIVITIES));
    final String currency = inputs.getComputedValue(YIELD_CURVE_NODE_SENSITIVITIES).getSpecification().getProperty(CURRENCY);
    final double[] ycns = sensitivities.getValues();
    final Object[] labels = sensitivities.getLabels();
    final CurveSpecification curveSpec = (CurveSpecification) inputs.getValue(CURVE_SPECIFICATION);
    final int n = ycns.length;
    if (n != curveSpec.getNodes().size()) {
      throw new OpenGammaRuntimeException("Do not have a sensitivity for each node");
    }
View Full Code Here

          ccyPair = Pair.of(currency2, currency1);
        }
        final double[] sensitivities = CALCULATOR.presentValueForwardPointsSensitivity(forex, data, forwardPoints, ccyPair);
        final CurveDefinition definition = (CurveDefinition) inputs.getValue(
            new ValueRequirement(CURVE_DEFINITION, ComputationTargetSpecification.NULL, ValueProperties.with(CURVE, fxForwardCurveName).get()));
        final DoubleLabelledMatrix1D matrix = MultiCurveUtils.getLabelledMatrix(new DoubleMatrix1D(sensitivities), definition);
        final ValueProperties properties = desiredValue.getConstraints().copy().get();
        final ValueSpecification spec = new ValueSpecification(FX_FORWARD_POINTS_NODE_SENSITIVITIES, target.toSpecification(), properties);
        return Collections.singleton(new ComputedValue(spec, matrix));
      }
    };
View Full Code Here

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
      final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
    final Position position = target.getPosition();
    final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
    final DoubleLabelledMatrix1D sensitivities = ((DoubleLabelledMatrix1D) inputs.getValue(FX_FORWARD_POINTS_NODE_SENSITIVITIES));
    final String currency = inputs.getComputedValue(FX_FORWARD_POINTS_NODE_SENSITIVITIES).getSpecification().getProperty(CURRENCY);
    final double[] fcns = sensitivities.getValues();
    final Object[] labels = sensitivities.getLabels();
    final CurveSpecification curveSpec = (CurveSpecification) inputs.getValue(CURVE_SPECIFICATION);
    final int n = fcns.length;
    if (n != curveSpec.getNodes().size()) {
      throw new OpenGammaRuntimeException("Do not have a sensitivity for each node");
    }
View Full Code Here

                .with(CURVE, curveName)
                .get();
            final CurveDefinition curveDefinition = (CurveDefinition) inputs.getValue(new ValueRequirement(CURVE_DEFINITION, ComputationTargetSpecification.NULL,
                ValueProperties.builder().with(CURVE, curveName).get()));
            final ValueSpecification spec = new ValueSpecification(YIELD_CURVE_NODE_SENSITIVITIES, target.toSpecification(), properties);
            final DoubleLabelledMatrix1D ycns = MultiCurveUtils.getLabelledMatrix(entry.getValue(), curveDefinition);
            return Collections.singleton(new ComputedValue(spec, ycns));
          }
        }
        s_logger.info("Could not get sensitivities to " + curveName + " for " + target.getName());
        return Collections.emptySet();
View Full Code Here

                .with(CURVE, curveName)
                .get();
            final CurveDefinition curveDefinition = (CurveDefinition) inputs.getValue(new ValueRequirement(CURVE_DEFINITION, ComputationTargetSpecification.NULL,
                ValueProperties.builder().with(CURVE, curveName).get()));
            final ValueSpecification spec = new ValueSpecification(YIELD_CURVE_NODE_SENSITIVITIES, target.toSpecification(), properties);
            final DoubleLabelledMatrix1D ycns = MultiCurveUtils.getLabelledMatrix(entry.getValue(), curveDefinition);
            return Collections.singleton(new ComputedValue(spec, ycns));
          }
        }
        throw new OpenGammaRuntimeException("Could not get sensitivities to " + curveName + " for " + target.getName());
      }
View Full Code Here

                .with(CURVE, curveName)
                .get();
            final CurveDefinition curveDefinition = (CurveDefinition) inputs.getValue(new ValueRequirement(CURVE_DEFINITION, ComputationTargetSpecification.NULL,
                ValueProperties.builder().with(CURVE, curveName).get()));
            final ValueSpecification spec = new ValueSpecification(YIELD_CURVE_NODE_SENSITIVITIES, target.toSpecification(), properties);
            final DoubleLabelledMatrix1D ycns = MultiCurveUtils.getLabelledMatrix(entry.getValue(), curveDefinition);
            return Collections.singleton(new ComputedValue(spec, ycns));
          }
        }
        s_logger.info("Could not get sensitivities to " + curveName + " for " + target.getName());
        return Collections.emptySet();
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.