/// <summary> /// Calculate the SABR implied volatilities for the strike values. /// This method uses the calibration engine indexed by the exerciseTime/assetCode pair /// When an ATM engine is used then the assetCode is ignored. /// </summary> /// <param name="engineHandle">The CalibrationEngine to use</param> /// <param name="exerciseTime">Option Expiry index</param> /// <param name="assetCode">Swap Tenor index</param> /// <param name="strikes">The strike to calculate Volatilities for, as decimal</param> /// <returns></returns> public static decimal[] SabrInterpolateVolatilities(string engineHandle, string exerciseTime, string assetCode, double[] strikes) { decimal[] decimalStrikes = strikes.Select(a => (decimal)a).ToArray(); return(Swaption.Instance().SABRInterpolateVolatilities(engineHandle, exerciseTime, assetCode, decimalStrikes)); }
/// <summary> /// Generate an ATM (At-The-Money) Swaption Calibration engine using the supplied parameters /// This form of engine creates a single cell engine that does not support asset/volatility grid data. /// </summary> /// <param name="engineHandles">The engine identifier</param> /// <param name="settingsHandles">The settings identifier</param> /// <param name="nu">Nu value</param> /// <param name="rho">Rho value</param> /// <param name="atmVolatilities">The ATM volatility</param> /// <param name="assetPrices">Asset Price to use</param> /// <param name="exerciseTimes">Exercise time for the option</param> /// <returns></returns> public static string[] CalibrateSabrAtmModels(string[] engineHandles, string[] settingsHandles, decimal[] nu, decimal[] rho, decimal[] atmVolatilities, decimal[] assetPrices, string[] exerciseTimes) { // Create the parameters used in this engine return (Swaption.Instance().SABRCalibrateATMModels(engineHandles, settingsHandles, nu, rho, atmVolatilities, assetPrices, exerciseTimes)); }
/// <summary> /// Calculate the SABR implied volatility for the strike value. /// This method uses the calibration engine indexed by the exerciseTime/assetCode pair /// When an ATM engine is used then the assetCode is ignored. /// </summary> /// <param name="engineHandle">The CalibrationEngine to use</param> /// <param name="exerciseTime">Option Expiry index</param> /// <param name="assetCode">Swap Tenor index</param> /// <param name="strike">The strike to calculate Volatility for, as percent</param> /// <returns></returns> public static decimal SabrImpliedVolatility(string engineHandle, string exerciseTime, string assetCode, double strike) { decimal pStrike = Convert.ToDecimal(strike / 100); decimal result = Swaption.Instance().SABRInterpolateVolatility(engineHandle, exerciseTime, assetCode, pStrike); return(result); }
/// <summary> /// Generate a new set of full calibration engines for the supplied data. /// Add or overwrite the engine store for the new engine. /// Each engineId will point to a set of engines indexed by swap tenor and option expiry /// </summary> /// <param name="engineHandle">Calibration Engine handle</param> /// <param name="settingsHandle">Calibartion settings handle</param> /// <param name="rawVols">A grid of volatilities (with row/column labels)</param> /// <param name="rawAssets">A grid of asset values</param> /// <param name="optionEx">The ption expiry to index against</param> /// <returns></returns> public static string CalibrateSabrModel(string engineHandle, string settingsHandle, object[,] rawVols, object[,] rawAssets, string optionEx) { // Create the asset and volatility arrays for the Interface object[,] volsRawTable = RedimensionVolatilityGrid(rawVols, true); // Create the asset and volatility arrays for the Interface object[,] assetRawTable = RedimensionAssetGrid(rawAssets); return (Swaption.Instance().SABRCalibrateModel(engineHandle, settingsHandle, volsRawTable, assetRawTable, optionEx)); }
/// <summary> /// Generate an Interpolated Swaption Calibration Engine using the supplied parameters. /// The calibrationArray has the handles of the Calibrated Engines to use in the interpolation processs. /// The interpolation can only be used in the ExpiryTime dimension to generate a new engine. /// If the engine array refers to unknown engines the process will fail (TBD) /// </summary> /// <param name="engineHandle">The name of the new interpolated calibration engine</param> /// <param name="settingsHandle">The settings to use in calibrating the engine</param> /// <param name="calibrationRange">The calibration range. </param> /// <param name="atmVolatility">The At The Money volatility to use in engine calibration</param> /// <param name="assetPrice">The Asset price to use</param> /// <param name="exerciseTime">The exercise time to create the new engine for</param> /// <param name="tenor">The tenor to create the new engine for. This must be a valid tenor</param> /// <returns></returns> public static string CalibrateSabrInterpolatedModel(string engineHandle, string settingsHandle, object[,] calibrationRange, double atmVolatility, double assetPrice, string exerciseTime, string tenor) { string[] handles = ConvertRangeToStringArray(calibrationRange); decimal atm = Convert.ToDecimal(atmVolatility) / 100.0m; decimal asset = Convert.ToDecimal(assetPrice) / 100.0m; return(Swaption.Instance().SABRCalibrateInterpolatedModel(engineHandle, settingsHandle, handles, atm, asset, exerciseTime, tenor)); }
/// <summary> /// Generate an ATM (At-The-Money) Swaption Calibration engine using the supplied parameters /// This form of engine creates a single cell engine that does not support asset/volatility grid data. /// </summary> /// <param name="engineHandle">The engine identifier</param> /// <param name="settingsHandle">The settings identifier</param> /// <param name="nu">Nu value</param> /// <param name="rho">Rho value</param> /// <param name="atmVolatility">The ATM volatility</param> /// <param name="assetPrice">Asset Price to use</param> /// <param name="exerciseTime">Exercise time for the option</param> /// <returns></returns> public static string CalibrateSabrAtmModel(string engineHandle, string settingsHandle, double nu, double rho, double atmVolatility, double assetPrice, string exerciseTime) { // Create the parameters used in this engine decimal pNu = Convert.ToDecimal(nu); decimal pRho = Convert.ToDecimal(rho); decimal pAtmVolatility = Convert.ToDecimal(atmVolatility) / 100.0m; decimal pAssetPrice = Convert.ToDecimal(assetPrice) / 100.0m; return (Swaption.Instance().SABRCalibrateATMModel(engineHandle, settingsHandle, pNu, pRho, pAtmVolatility, pAssetPrice, exerciseTime)); }
/// <summary> /// /// </summary> /// <param name="engine"></param> /// <param name="expiry"></param> /// <param name="tenor"></param> /// <returns></returns> public static decimal CalibrationError(string engine, string expiry, string tenor) { return(Swaption.Instance().CalibrationError(engine, expiry, tenor)); }
/// <summary> /// Get the Calibration status for the calibration engine using /// the expiry/tenor pair /// </summary> /// <param name="engine">The calibration engine handle</param> /// <param name="expiry">The exercise time of the option</param> /// <param name="tenor">The asset Code of the swap (tenor)</param> /// <returns></returns> public static bool IsModelCalibrated(string engine, string expiry, string tenor) { return(Swaption.Instance().IsModelCalibrated(engine, expiry, tenor)); }
/// <summary> /// Get the Rho value for the calibration engine using /// the expiry/tenor pair /// </summary> /// <param name="engine">The calibration engine handle</param> /// <param name="expiry">The exercise time of the option</param> /// <param name="tenor">The asset Code of the swap (tenor)</param> /// <returns></returns> public static decimal GetSabrParameterRho(string engine, string expiry, string tenor) { return(Swaption.Instance().GetSABRParameter(Swaption.CalibrationParameter.Rho, engine, expiry, tenor)); }
/// <summary> /// Create a new Calibration Settings object. Each new object holds the instrument, currency and beta /// to use for this settings object. Each new object is stored internally using the supplied handle /// as an identifying key. /// The Settings object is used by a Calibration Engine to define base parameters on which to calibrate. /// </summary> /// <param name="calibrationHandle">A handle</param> /// <param name="calibrationInstrument">The instrument type to use</param> /// <param name="calibrationCurrency">The currency setting</param> /// <param name="beta">The Beta parameter to use</param> /// <returns></returns> public static string[] AddSabrCalibrationSettingArray(string[] calibrationHandle, string calibrationInstrument, string calibrationCurrency, decimal[] beta) { return(Swaption.Instance().SabrAddCalibrationSettings(calibrationHandle, calibrationInstrument, calibrationCurrency, beta)); }
/// <summary> /// Create a new Calibration Settings object. Each new object holds the instrument, currency and beta /// to use for this settings object. Each new object is stored internally using the supplied handle /// as an identifying key. /// The Settings object is used by a Calibration Engine to define base parameters on which to calibrate. /// </summary> /// <param name="calibrationHandle">A handle</param> /// <param name="calibrationInstrument">The instrument type to use</param> /// <param name="calibrationCurrency">The currency setting</param> /// <param name="beta">The Beta parameter to use</param> /// <returns></returns> public static string AddSabrCalibrationSettings(string calibrationHandle, string calibrationInstrument, string calibrationCurrency, double beta) { return(Swaption.Instance().SabrAddCalibrationSetting(calibrationHandle, calibrationInstrument, calibrationCurrency, (decimal)beta)); }