@Override
public CompiledFunctionDefinition compile(final FunctionCompilationContext compilationContext, final Instant atInstant) {
final ConfigSource configSource = OpenGammaCompilationContext.getConfigSource(compilationContext);
final SyntheticSwaptionVolatilityCubeDefinitionSource definitionSource = new SyntheticSwaptionVolatilityCubeDefinitionSource(configSource);
final ConfigDBSwaptionVolatilityCubeSpecificationSource specificationSource = new ConfigDBSwaptionVolatilityCubeSpecificationSource(configSource);
final ZonedDateTime atZDT = ZonedDateTime.ofInstant(atInstant, ZoneOffset.UTC);
return new AbstractInvokingCompiledFunction() {
@SuppressWarnings("synthetic-access")
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
final ValueRequirement desiredValue = desiredValues.iterator().next();
final String cubeName = desiredValue.getConstraint(ValuePropertyNames.CUBE);
final String definitionName = desiredValue.getConstraint(SurfaceAndCubePropertyNames.PROPERTY_CUBE_DEFINITION);
final String specificationName = desiredValue.getConstraint(SurfaceAndCubePropertyNames.PROPERTY_CUBE_SPECIFICATION);
final Currency currency = target.getValue(PrimitiveComputationTargetType.CURRENCY);
final String fullSpecificationName = specificationName + "_" + currency.getCode();
final String fullDefinitionName = definitionName + "_" + currency.getCode();
final SwaptionVolatilityCubeSpecification specification = specificationSource.getSpecification(fullSpecificationName);
if (specification == null) {
throw new OpenGammaRuntimeException("Could not get swaption volatility cube specification named " + fullSpecificationName);
}
final VolatilityCubeDefinition definition = definitionSource.getDefinition(currency, fullDefinitionName);
if (definition == null) {