private Set<ComputedValue> getResultsForExternalRiskFactors(final SecuritySource secSource, final FunctionInputs inputs, final ComputationTarget target, final RawSecurity security) {
final List<FactorExposureData> factors = decodeSensitivities(secSource, security);
Collections.sort(factors, new FactorExposureDataComparator());
final List<String> indices = Lists.newArrayList();
final List<String> labels = Lists.newArrayList();
final DoubleList values = new DoubleArrayList();
for (final FactorExposureData factor : factors) {
if (!(factor.getFactorType().equals(FactorType.YIELD) && factor.getFactorName().contains(SWAP_TEXT))) {
final ComputedValue computedValue = inputs.getComputedValue(getSensitivityRequirement(factor.getExposureExternalId()));
if (computedValue != null) {
indices.add(factor.getFactorExternalId().getValue());
labels.add(factor.getExposureExternalId().getValue());
values.add((Double) computedValue.getValue());
} else {
s_logger.error("Value was null when getting required input data " + factor.getExposureExternalId());
}
}
}
final StringLabelledMatrix1D labelledMatrix = new StringLabelledMatrix1D(indices.toArray(new String[] {}), labels.toArray(), values.toDoubleArray());
final ValueSpecification valueSpecification = new ValueSpecification(EXTERNAL_SENSITIVITIES_REQUIREMENT, target.toSpecification(), createCurrencyValueProperties(target).get());
return Collections.singleton(new ComputedValue(valueSpecification, labelledMatrix));
}