/// <summary> /// Create a surface from an FpML /// </summary> /// <param name="logger">The logger.</param> /// <param name="cache">The cache.</param> /// <param name="nameSpace">The nameSpace</param> /// <param name="fpmlData">The data.</param> /// <param name="properties">The properties.</param> protected ExtendedExpiryTermStrikeVolatilitySurface(ILogger logger, ICoreCache cache, String nameSpace, Pair <PricingStructure, PricingStructureValuation> fpmlData, NamedValueSet properties) { var surfaceId = new VolatilitySurfaceIdentifier(properties); Algorithm = surfaceId.Algorithm; PricingStructureIdentifier = surfaceId; var data = (VolatilityMatrix)fpmlData.Second; var holder = new PricingStructureAlgorithmsHolder(logger, cache, nameSpace, surfaceId.PricingStructureType, surfaceId.Algorithm); //Get the forwards from the surface. var adjustments = new ParametricAdjustment(); if (data.adjustment != null) { //assume the forwards are the first parameter set. adjustments = data.adjustment[0]; } //Creates the property collection. This should be backward compatable with V1. PricingStructureIdentifier = new VolatilitySurfaceIdentifier(properties); var xDimensionInterpolationMethod = InterpolationMethodHelper.Parse(holder.GetValue("xDimensionInterpolation")); var yDimensionInterpolationMethod = InterpolationMethodHelper.Parse(holder.GetValue("yDimensionInterpolation")); // Generate an interpolator to use if (adjustments?.datapoint != null) { Interpolator = new ExtendedVolatilitySurfaceInterpolator(data.dataPoints, adjustments.datapoint, xDimensionInterpolationMethod.Value, yDimensionInterpolationMethod.Value); } SetFpMLData(fpmlData); _matrixIndexHelper = new SortedList <ExpiryTenorStrikeKey, int>(new ExpiryTenorStrikeKey()); ProcessVolatilityRepresentation(); }
private static ParametricAdjustment[] GenerateForwards(IEnumerable <double> forwards) { var parametricAdjustment = new ParametricAdjustment { name = "Forwards", datapoint = forwards.Select( forward => new ParametricAdjustmentPoint { parameterValue = (decimal)forward }). ToArray() }; return(new[] { parametricAdjustment }); }