// --------------------------------------------------------------------- // Business logic methods. // --------------------------------------------------------------------- /// <summary> /// Computes the BGS convexity correction. The magnitude of the /// correction, as described in the document "Pricing Analytics for a /// Balance Guaranteed Swap", prepared by George Scoufis, /// Reference Number GS-02042007/1 is: /// F0*{1 - Phi(d1) - (L/B0)^(1 + 2*alpha/sigma^2)*phi(d2)}. /// Periods in the formula for F0, d1 and d2 are computed with /// ACT/365 day count.</summary> /// <param name="lastAmortisationDate">The date of the most recent /// realised amortisation.</param> /// <param name="amortisationDate">The date to which the convexity /// correction is required.</param> /// <param name="currentBondFactor">The current Bond Factor.</param> /// <param name="alpha">The parameter alpha in the Bond Factor curve /// model.</param> /// <param name="sigma">The parameter sigma in the Bond Factor curve /// model.</param> /// <param name="cleanUp">The clean up condition. If the current /// Bond Factor is less than or equal to the clean up, then the /// convexity correction is 0.0.</param> /// <returns>Convexity correction. Logic has been added to cater for /// the limiting cases: 1) sigma->0; 2) clean up ->0.</returns> public double ComputeBGSConvexityCorrection(DateTime lastAmortisationDate, DateTime amortisationDate, double currentBondFactor, double alpha, double sigma, double cleanUp) { IDayCounter dayCountObj = Actual365.Instance; double tenor = dayCountObj.YearFraction(lastAmortisationDate, amortisationDate); var bgs = new BGSConvexityCorrection(); return(bgs.ComputeBGSConvexityCorrection(tenor, currentBondFactor, alpha, sigma, cleanUp)); }
public void TestComputeBGSConvexityCorrection() { // Instantiate the object that will provide access to the BGS // convexity correction functionality. var convexityObj = new BGSConvexityCorrection(); Assert.AreNotEqual(convexityObj, null); IDayCounter dayCountObj = Actual365.Instance; // Test the case: B0 < L. _amortisationDate = DateTime.Parse("2011-01-18"); _currentBondFactor = 19 / 100; _alpha = -0.4532; _sigma = 2.17 / 100; _cleanUp = 20 / 100; _expected = 0.0; double tenor = dayCountObj.YearFraction(_lastAmortisationDate, _amortisationDate); _actual = convexityObj.ComputeBGSConvexityCorrection(tenor, _currentBondFactor, _alpha, _sigma, _cleanUp); Assert.AreEqual(_expected, _actual); // Test the limiting case: L = 0. _amortisationDate = DateTime.Parse("2007-04-16"); _currentBondFactor = 68.29 / 100; _alpha = -0.3051; _sigma = 3.12 / 100; _cleanUp = 0.0; _expected = 0.6334102389; tenor = dayCountObj.YearFraction(_lastAmortisationDate, _amortisationDate); _actual = convexityObj.ComputeBGSConvexityCorrection(tenor, _currentBondFactor, _alpha, _sigma, _cleanUp); const double tolerance2 = 1.0E-6; Assert.AreEqual(_expected, _actual, tolerance2); // Test the linmiting case: sigma = 0. _amortisationDate = DateTime.Parse("2007-07-16"); _currentBondFactor = 61.82 / 100; _alpha = -0.3051; _sigma = 0.0; _cleanUp = 10.0 / 100; _expected = 0.5314066262; tenor = dayCountObj.YearFraction(_lastAmortisationDate, _amortisationDate); _actual = convexityObj.ComputeBGSConvexityCorrection(tenor, _currentBondFactor, _alpha, _sigma, _cleanUp); const double tolerance3 = 1.0E-5; Assert.AreEqual(_expected, _actual, tolerance3); // Test the generic case. // Full convexity correction. _amortisationDate = DateTime.Parse("2008-10-15"); _currentBondFactor = 91.73 / 100; _alpha = -0.3000; _sigma = 45.0 / 100; _cleanUp = 10.0 / 100; _expected = 0.5421666386; tenor = dayCountObj.YearFraction(_lastAmortisationDate, _amortisationDate); _actual = convexityObj.ComputeBGSConvexityCorrection(tenor, _currentBondFactor, _alpha, _sigma, _cleanUp); const double tolerance4 = 1.0E-7; Assert.AreEqual(_expected, _actual, tolerance4); // Truncated convexity correction. _amortisationDate = DateTime.Parse("2010-01-15"); _currentBondFactor = 28.34 / 100; _alpha = -0.2567; _sigma = 2.71 / 100; _cleanUp = 10.0 / 100; _expected = 0.1312047820; tenor = dayCountObj.YearFraction(_lastAmortisationDate, _amortisationDate); _actual = convexityObj.ComputeBGSConvexityCorrection(tenor, _currentBondFactor, _alpha, _sigma, _cleanUp); const double tolerance5 = 1.0E-7; Assert.AreEqual(_expected, _actual, tolerance5); }