final HullWhiteOneFactorParameters parameters = configs.iterator().next().getValue();
requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getMeanReversionId()));
requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, parameters.getInitialVolatilityId()));
final Map<Tenor, ExternalId> volatilityTermStructure = parameters.getVolatilityTermStructure();
for (final Map.Entry<Tenor, ExternalId> entry : volatilityTermStructure.entrySet()) {
final ExternalScheme scheme = entry.getValue().getScheme();
final String id = entry.getValue().getValue();
final ExternalId tenorAppendedId = ExternalId.of(scheme, createId(entry.getKey(), id));
requirements.add(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, tenorAppendedId));
}
final ZonedDateTime atZDT = ZonedDateTime.ofInstant(atInstant, ZoneOffset.UTC);
return new AbstractInvokingCompiledFunction(atZDT.with(LocalTime.MIDNIGHT), atZDT.plusDays(1).with(LocalTime.MIDNIGHT).minusNanos(1000000)) {
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
final Clock snapshotClock = executionContext.getValuationClock();
final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
Object meanReversionObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
ComputationTargetType.PRIMITIVE, parameters.getMeanReversionId()));
if (meanReversionObject == null) {
// Jim - these are hacks that should be removed.
meanReversionObject = MEAN_REVERSION_DEFAULT;
s_logger.warn("Using default mean reversion");
//throw new OpenGammaRuntimeException("Could not get mean reversion value");
}
Object initialVolatilityObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
ComputationTargetType.PRIMITIVE, parameters.getInitialVolatilityId()));
if (initialVolatilityObject == null) {
// Jim - these are hacks that should be removed.
initialVolatilityObject = INITIAL_VOLATILITY_DEFAULT;
s_logger.warn("Using default initial volatility");
//throw new OpenGammaRuntimeException("Could not get initial volatility value");
}
final Double meanReversion = (Double) meanReversionObject;
final Double initialVolatility = (Double) initialVolatilityObject;
final DoubleArrayList volatility = new DoubleArrayList();
volatility.add(initialVolatility);
final DoubleArrayList volatilityTime = new DoubleArrayList();
for (final Map.Entry<Tenor, ExternalId> entry : volatilityTermStructure.entrySet()) {
final ExternalScheme scheme = entry.getValue().getScheme();
final String id = entry.getValue().getValue();
final ExternalId tenorAppendedId = ExternalId.of(scheme, createId(entry.getKey(), id));
Object volatilityObject = inputs.getValue(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE,
ComputationTargetType.PRIMITIVE, tenorAppendedId));
// Jim - next block is a hack that should be removed.