示例#1
0
        /// <summary>
        /// Create a Sortedlist of volatility curves from the data matrix
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="nameSpace">The client namespace</param>
        /// <param name="properties">The properties, including the engine handle.</param>
        /// <param name="instruments">An array of instrument types.</param>
        /// <param name="rawVolatilityGrid">The raw grid used to build the engines. Assume that all volatility and strike values are 100x true</param>
        /// <returns></returns>
        private SortedList <decimal, VolatilityCurve> VolatilityCurveCreate(ILogger logger, ICoreCache cache, string nameSpace,
                                                                            NamedValueSet properties, String[] instruments,
                                                                            Decimal[] rawVolatilityGrid)
        {
            var clonedProperties = properties.Clone();
            // Create engine
            var quotedAssetSet = AssetHelper.Parse(instruments, rawVolatilityGrid, null);
            var engines        = new SortedList <decimal, VolatilityCurve>();
            // Create a new ATM CapletBootstrap engine. The default decimal should be 0
            var volatilityCurve = PricingStructureFactory.CreateCurve(logger, cache, nameSpace, null, null, clonedProperties, quotedAssetSet);

            // Add engine
            if (volatilityCurve is VolatilityCurve vCurve)
            {
                engines.Add(0, vCurve);
            }
            return(engines);
        }
示例#2
0
        /// <summary>
        /// Create a Sortedlist of bootstrap engines from the data matrix
        /// </summary>
        /// <param name="logger">The logger.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="nameSpace">The client namespace</param>
        /// <param name="properties">The properties, including the engine handle.</param>
        /// <param name="instruments">An array of instrument types.</param>
        /// <param name="strikes">The strike array.</param>
        /// <param name="rawVolatilityGrid">The raw grid used to build the engines. Assume that all volatility and strike values are 100x true</param>
        /// <returns></returns>
        private SortedList <decimal, VolatilityCurve> VolatilityCurvesCreate(ILogger logger, ICoreCache cache, string nameSpace,
                                                                             NamedValueSet properties, String[] instruments,
                                                                             Decimal[] strikes, Decimal[,] rawVolatilityGrid)
        {
            var clonedProperties = properties.Clone();

            // Check there are valid strikes
            if (strikes != null && rawVolatilityGrid != null)
            {
                //The matrix is zero based, but the upper bound returns the last column index.
                var volColumns = rawVolatilityGrid.GetUpperBound(1) + 1;
                var columns    = Math.Min(strikes.Length, volColumns);
                var engines    = new SortedList <decimal, VolatilityCurve>();
                // Loop through the strikes to create each new engine
                for (var i = 0; i < columns; i++)
                {
                    decimal[] adjustedRates = GenerateVolatilityMatrix(instruments, i, rawVolatilityGrid);
                    clonedProperties.Set("Strike", strikes[i]);
                    clonedProperties.Set("StrikeQuoteUnits", StrikeQuoteUnitsEnum.DecimalRate.ToString());
                    // Create engine
                    var quotedAssetSet = AssetHelper.Parse(instruments, adjustedRates, null);
                    var engine         = PricingStructureFactory.CreateCurve(logger, cache, nameSpace, null, null, clonedProperties, quotedAssetSet) as VolatilityCurve;
                    // Add engine
                    engines.Add(strikes[i], engine);
                }
                return(engines);
            }
            {
                var engines = new SortedList <decimal, VolatilityCurve>();
                // Create a new ATM CapletBootstrap engine. The default decimal should be 0
                var engine = PricingStructureFactory.CreateCurve(logger, cache, nameSpace, null, null, clonedProperties,
                                                                 instruments, null, null) as VolatilityCurve;
                // Add engine
                engines.Add(0, engine);
                return(engines);
            }
        }
示例#3
0
 /// <summary>
 /// Create intial Curve
 /// store it in _initialCurve
 /// </summary>
 private void SetInitialCurve(ILogger logger, ICoreCache cache, string nameSpace, IBusinessCalendar fixingCalendar, IBusinessCalendar rollCalendar,
                              NamedValueSet properties, string[] instruments, decimal[] rates)
 {
     _initialCurve = PricingStructureFactory.CreateCurve(logger, cache, nameSpace, fixingCalendar, rollCalendar, properties, instruments, rates, null) as RateCurve;
 }