/// <summary>
 /// Master function used to validate all constructor arguments.
 /// </summary>
 /// /// <param name="atmBootstrapEngine">An existing At-the-Money (ATM)
 /// Caplet bootstrap engine.
 /// </param>
 /// <param name="smileSettings">An existing Smile settings
 /// object that will be used in the calibration of the Caplet smile.
 /// </param>
 /// <param name="fixedStrikeBootstrapEngines">List of existing fixed
 /// strike Caplet bootstrap engines.
 /// when applied to each Caplet bootstrap engine in the list.</param>
 /// <param name="handle">Unique name that will identify the object
 /// that will be instantiated.</param>
 private static void ValidateConstructorArguments
     (VolatilityCurve atmBootstrapEngine,
     SmileCalibrationSettings smileSettings,
     ICollection <VolatilityCurve> fixedStrikeBootstrapEngines,
     string handle)
 {
     ValidateATMBootstrapEngine(atmBootstrapEngine);
     ValidateSmileSettings(smileSettings);
     ValidateFixedStrikeBootstrapEngines(fixedStrikeBootstrapEngines);
     ValidateHandle(handle);
 }
        /// <summary>
        /// Helper function used by the master function that validates all
        /// constructor arguments.
        /// Exception: ArgumentNullException.
        /// </summary>
        /// <param name="smileSettings">An existing Smile settings
        /// object that will be used in the calibration of the Caplet smile.
        /// </param>
        private static void ValidateSmileSettings
            (SmileCalibrationSettings smileSettings)
        {
            if (!smileSettings.Equals(null))
            {
            }
            else
            {
// Null object found.
                const string errorMessage =
                    "Null settings object found in Caplet smile calibration";
                throw new ArgumentException("capletSmileSettings", errorMessage);
            }
        }
 /// <summary>
 /// Constructor for the class <see cref="CapletSmileCalibrationEngine"/>
 /// </summary>
 /// <param name="atmBootstrapEngine">An existing At-the-Money (ATM)
 /// Caplet bootstrap engine.
 /// Precondition: Method IsCapletBootstrapSuccessful returns true.
 /// </param>
 /// <param name="capletSmileSettings">An existing Caplet Smile settings
 /// object that will be used in the calibration of the Caplet smile.
 /// </param>
 /// <param name="fixedStrikeBootstrapEngines">List of existing fixed
 /// strike Caplet bootstrap engines.
 /// Precondition: Method IsCapletBootstrapSuccessful returns true
 /// when applied to each Caplet bootstrap engine in the list.</param>
 /// <param name="handle">Unique name that will identify the object
 /// that will be instantiated.
 /// Precondition: Non empty string.</param>
 public SmileCalibrationEngine
     (VolatilityCurve atmBootstrapEngine,
     SmileCalibrationSettings capletSmileSettings,
     List <VolatilityCurve> fixedStrikeBootstrapEngines,
     string handle)
 {
     ValidateConstructorArguments
         (atmBootstrapEngine,
         capletSmileSettings,
         fixedStrikeBootstrapEngines,
         handle);
     InitialisePrivateFields
         (atmBootstrapEngine,
         capletSmileSettings,
         fixedStrikeBootstrapEngines,
         handle);
 }
 /// <summary>
 /// Master function used to initialise all private fields.
 /// </summary>
 /// <param name="atmBootstrapEngine">An existing At-the-Money (ATM)
 /// Caplet bootstrap engine.</param>
 /// <param name="capletSmileSettings">An existing Caplet Smile settings
 /// object that will be used in the calibration of the Caplet smile.
 /// </param>
 /// <param name="fixedStrikeBootstrapEngines">List of existing fixed
 /// strike Caplet bootstrap engines.</param>
 /// <param name="handle">Unique name that will identify the object
 /// that will be instantiated.</param>
 private void InitialisePrivateFields
     (VolatilityCurve atmBootstrapEngine,
     SmileCalibrationSettings capletSmileSettings,
     List <VolatilityCurve> fixedStrikeBootstrapEngines,
     string handle)
 {
     _atmBootstrapEngine          = atmBootstrapEngine;
     _smileSettings               = capletSmileSettings;
     _fixedStrikeBootstrapEngines = fixedStrikeBootstrapEngines;
     Handle = handle;
     InitialiseSABRSettings();
     // Initialise the remaining private fields to an appropriate
     // default.
     _assetPrice       = -1.0m;
     _excerciseTime    = -1.0m;
     _sabrEngine       = null;
     _sabrStrikes      = null;
     _sabrVolatilities = null;
 }
Beispiel #5
0
        /// <summary>
        /// Create a settings object to use with SABR Calibration
        /// </summary>
        /// <param name="settingsHandle">The settings engine</param>
        /// <param name="beta">The beta value</param>
        /// <param name="interpolationType">Interpolation type to use</param>
        /// <returns></returns>
        public string SABRCalibrationSettings(string settingsHandle, decimal beta, string interpolationType)
        {
            // Extract the correct interpolation type from the parameter
            var volatilityInterpolation = ExpiryInterpolationType.CubicHermiteSpline;

            if (!string.IsNullOrEmpty(interpolationType))
            {
                var found   = false;
                var interps = Enum.GetValues(typeof(ExpiryInterpolationType));
                foreach (ExpiryInterpolationType interpType in interps)
                {
                    if (interpType.ToString() != interpolationType)
                    {
                        continue;
                    }
                    volatilityInterpolation = interpType;
                    found = true;
                    break;
                }
                if (!found)
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Unknown interpolation method {0} specified.", new object[] { interpolationType }));
                }
            }
            // Create a new Caplet Smile Calibration Settings object and store it
            var settings = new SmileCalibrationSettings(beta, volatilityInterpolation, settingsHandle);

            if (_sabrSettings.ContainsKey(settingsHandle))
            {
                _sabrSettings[settingsHandle] = settings;
            }
            else
            {
                _sabrSettings.Add(settingsHandle, settings);
            }
            return(settingsHandle);
        }