/// <summary>
        /// Generate an array of PricingStructurePoint from a set of input arrays
        /// The array can then be added to the Matrix
        /// </summary>
        /// <param name="expiry">Expiry values to use</param>
        /// <param name="tenors">Tenor values to use</param>
        /// <param name="volatility">An array of volatility values</param>
        /// <param name="underlyingAssetReference">The underlying asset references.</param>
        /// <returns></returns>
        private PricingStructurePoint[] ProcessRawSurface(String[] expiry, String[] tenors, double[,] volatility, AssetReference underlyingAssetReference)
        {
            var expiryLength = expiry.Length;
            var tenorsLength = tenors.Length;
            var pointIndex   = 0;
            var points       = new PricingStructurePoint[expiryLength * tenorsLength];

            for (var expiryIndex = 0; expiryIndex < expiryLength; expiryIndex++)
            {
                // extract the current expiry
                var expiryKeyPart = expiry[expiryIndex];
                for (var strikeIndex = 0; strikeIndex < tenorsLength; strikeIndex++)
                {
                    // Extract the strike to use in the helper key
                    var tenorKeyPart = tenors[strikeIndex];
                    // Extract the row,column indexed volatility
                    var vol = (decimal)volatility[expiryIndex, strikeIndex];
                    var key = new ExpiryTenorStrikeKey(expiryKeyPart, tenorKeyPart);
                    _matrixIndexHelper.Add(key, pointIndex);
                    // Add the value to the points array (dataPoints entry in the matrix)
                    var coordinates = new PricingDataPointCoordinate[1];
                    coordinates[0] = PricingDataPointCoordinateFactory.Create(expiry[expiryIndex], tenors[strikeIndex], null, "ATMSurface");
                    var pt = new PricingStructurePoint {
                        value                    = vol,
                        valueSpecified           = true,
                        coordinate               = coordinates,
                        underlyingAssetReference = underlyingAssetReference
                    };
                    points[pointIndex++] = pt;
                }
            }
            return(points);
        }
        /// <summary>
        /// Generate an array of PricingStructurePoint from a set of input arrays
        /// The array can then be added to the Matrix
        /// </summary>
        /// <param name="expiry">Expiry values to use</param>
        /// <param name="strike">Strike values to use</param>
        /// <param name="volatility">An array of volatility values</param>
        /// <returns></returns>
        private static PricingStructurePoint[] ProcessRawSurface(String[] expiry, Double[] strike, double[,] volatility)
        {
            var expiryLength = expiry.Length;
            var strikeLength = strike.Length;
            var pointIndex   = 0;
            var points       = new PricingStructurePoint[expiryLength * strikeLength];

            for (var expiryIndex = 0; expiryIndex < expiryLength; expiryIndex++)
            {
                for (var strikeIndex = 0; strikeIndex < strikeLength; strikeIndex++)
                {
                    // Extract the row,column indexed volatility
                    var vol = (decimal)volatility[expiryIndex, strikeIndex];

                    // Add the value to the points array (dataPoints entry in the matrix)
                    var coordinates = new PricingDataPointCoordinate[1];
                    coordinates[0] = PricingDataPointCoordinateFactory.Create(expiry[expiryIndex], null, (Decimal)strike[strikeIndex]);
                    var pt = new PricingStructurePoint {
                        value = vol, valueSpecified = true, coordinate = coordinates
                    };
                    points[pointIndex++] = pt;
                }
            }
            return(points);
        }
Exemplo n.º 3
0
        private static PricingStructurePoint[] ProcessRawSurface(string[] expiries, string[] tenors, decimal[] strikes, decimal[,] volatility, PriceQuoteUnits strikeQuoteUnits, AssetReference underlyingAssetReference)
        {
            var expiryLength = expiries.Length;
            var strikeLength = strikes.Length;
            var tenorLength  = tenors.Length;
            var points       = new List <PricingStructurePoint>();

            for (var expiryIndex = 0; expiryIndex < expiryLength; expiryIndex++)
            {
                for (var strikeIndex = 0; strikeIndex < strikeLength; strikeIndex++)
                {
                    for (var tenorIndex = 0; tenorIndex < tenorLength; tenorIndex++)
                    {
                        // Extract the row,column indexed volatility
                        var vol = volatility[expiryIndex + tenorIndex * expiryLength, strikeIndex];

                        // Add the value to the points array (dataPoints entry in the matrix)
                        var coordinates = new PricingDataPointCoordinate[1];
                        coordinates[0] = PricingDataPointCoordinateFactory.Create(expiries[expiryIndex], tenors[tenorIndex],
                                                                                  strikes[strikeIndex]);
                        var point = new PricingStructurePoint
                        {
                            value                    = vol,
                            valueSpecified           = true,
                            coordinate               = coordinates,
                            underlyingAssetReference = underlyingAssetReference,
                            quoteUnits               = strikeQuoteUnits
                        };
                        points.Add(point);
                    }
                }
            }
            return(points.ToArray());
        }