/// <summary> /// Calculate an ATM volatility given a Price Per Day (PPD) value and a swap curve /// The curve provides forward rates for the calculation /// </summary> /// <returns></returns> private static decimal CalculateCAPATMVolatility(SwapRate rates, DateTime spotDate, double tenorYearFraction, decimal ppd) { // Extract the forward rate var swapRate = rates.ComputeSwapRate(spotDate, tenorYearFraction); ppd /= 100.0m; // Calculate the volatility from the parameters var atmVolatility = ppd * (decimal)System.Math.Sqrt(250.0) / swapRate; return(atmVolatility); }
/// <summary> /// Calculate an ATM volatility given a Price Per Day (PPD) value and a swap curve /// The curve provides forward rates for the calculation /// </summary> private static decimal CalculateAtmVolatility(SwapRate rate, DateTime baseDate, SwaptionPPDGrid grid, double expiryYearFraction, double tenorYearFraction) { // Extract the forward rate var swapRate = rate.ComputeSwapRate(baseDate, tenorYearFraction); swapRate = swapRate * 100; // Extract the correct ppd from the grid (compensate for the swap rate being * 100) var ppd = grid.GetPPD(expiryYearFraction, tenorYearFraction) * 0.01m; // Calculate the volatility from the parameters var atmVolatility = (ppd * (decimal)System.Math.Sqrt(250.0)) / swapRate; return(atmVolatility); }