Esempio n. 1
0
        /// <summary>
        /// Values at.
        /// </summary>
        /// <param name="axisValue">The axis value.</param>
        /// <param name="extrapolation">if set to <c>true</c> [extrapolation].</param>
        /// <returns></returns>
        public double ValueAt(double axisValue, bool extrapolation)
        {
            string        engineHandle      = SettingsHandle;
            decimal       time              = Convert.ToDecimal(ExpiryTime);
            const decimal tenor             = 0;
            var           calibrationEngine =
                new SABRCalibrationEngine(engineHandle,
                                          CalibrationSettings,
                                          EngineHandles,
                                          AtmVolatility,
                                          AssetPrice,
                                          time,
                                          tenor
                                          );

            calibrationEngine.CalibrateInterpSABRModel();
            var sabrParameters = new SABRParameters(calibrationEngine.GetSABRParameters.Alpha,
                                                    calibrationEngine.GetSABRParameters.Beta,
                                                    calibrationEngine.GetSABRParameters.Nu,
                                                    calibrationEngine.GetSABRParameters.Rho);
            var     sabrImpliedVol = new SABRImpliedVolatility(sabrParameters, false);
            var     value          = Convert.ToDecimal(axisValue) * AssetPrice;
            string  errMsg         = "Error interpolating";
            decimal result         = 0.0m;

            sabrImpliedVol.SABRInterpolatedVolatility(AssetPrice, time, value, ref errMsg, ref result, true);
            return(Convert.ToDouble(result));
        }
        /// <summary>
        /// Create an Interpolated calibration engine. Such an engine is designed for a single value
        /// derived from a set of base engines.
        /// </summary>
        /// <param name="settings">The settings object to use</param>
        /// <param name="calibrationEngineId">The id of this engine</param>
        /// <param name="engines">The array of engine handles to use</param>
        /// <param name="atmVolatility">The ATM volatility</param>
        /// <param name="assetPrice">Asset Price to use</param>
        /// <param name="optionExpiry">The ATM pointer</param>
        /// <param name="tenor">The tenor to create the new engine for. This must be a valid tenor</param>
        private static SortedDictionary <SABRKey, SABRCalibrationEngine> BuildEngineCollection(SABRCalibrationSettings settings, string calibrationEngineId, IEnumerable <KeyValuePair <SABRKey, SABRCalibrationEngine> > engines, decimal atmVolatility, decimal assetPrice, string optionExpiry, string tenor)
        {
            var engineCollection = new SortedDictionary <SABRKey, SABRCalibrationEngine>(new SABRKey());
            var exerciseTime     = (decimal)SABRHelper.GenerateDayValue(optionExpiry, 365.0d);
            var indexTenor       = (decimal)SABRHelper.GenerateDayValue(tenor, 365.0d);
            // Create a new instance of the engine
            var calibrationEngine =
                new SABRCalibrationEngine(calibrationEngineId, settings, engines, atmVolatility, assetPrice, exerciseTime, indexTenor);

            // Calibrate the engine
            calibrationEngine.CalibrateInterpSABRModel();
            // Add the new engine to our collection
            var key = new SABRKey(optionExpiry, tenor);

            engineCollection.Add(key, calibrationEngine);
            return(engineCollection);
        }
Esempio n. 3
0
        /// <summary>
        /// Create an Interpolated calibration engine. Such an engine is designed for a single value
        /// derived from a set of base engines.
        /// </summary>
        /// <param name="settings">The settings object to use</param>
        /// <param name="calibrationEngineId">The id of this engine</param>
        /// <param name="engines">The array of engine handles to use</param>
        /// <param name="atmVolatility">The ATM volatility</param>
        /// <param name="assetPrice">Asset Price to use</param>
        /// <param name="optionExpiry">The ATM pointer</param>
        /// <param name="tenor">The tenor to create the new engine for. This must be a valid tenor</param>
        private SortedDictionary <SABRKey, SABRCalibrationEngine> BuildEngineCollection(SABRCalibrationSettings settings,
                                                                                        string calibrationEngineId, ref SortedDictionary <SABRKey, SABRCalibrationEngine> engines,
                                                                                        decimal atmVolatility, decimal assetPrice, string optionExpiry, string tenor)
        {
            var     engineCollection = new SortedDictionary <SABRKey, SABRCalibrationEngine>(new SABRKey());
            decimal exerciseTime     = GenerateDayValue(optionExpiry, 365.0m);
            decimal indexTenor       = GenerateDayValue(tenor, 365.0m);
            // Create a new instance of the engine
            //(string handle, SABRCalibrationSettings calibrationSettings,
            var calibrationEngine =
                new SABRCalibrationEngine(calibrationEngineId, settings, engines,
                                          atmVolatility, assetPrice, exerciseTime, indexTenor);

            // Calibrate the engine
            calibrationEngine.CalibrateInterpSABRModel();
            // Add the new engine to our collection
            var key = new SABRKey(optionExpiry, tenor);

            engineCollection.Add(key, calibrationEngine);
            return(engineCollection);
        }