From 93306509813783dcb17716f68813d6f1c2811ac0 Mon Sep 17 00:00:00 2001 From: twan3617 Date: Fri, 16 Aug 2024 10:45:25 +1000 Subject: [PATCH 1/4] Correct documentation error in Svensson zero rate formula --- ql/termstructures/yield/nonlinearfittingmethods.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/termstructures/yield/nonlinearfittingmethods.hpp b/ql/termstructures/yield/nonlinearfittingmethods.hpp index 17732fe5236..4bd372b741e 100644 --- a/ql/termstructures/yield/nonlinearfittingmethods.hpp +++ b/ql/termstructures/yield/nonlinearfittingmethods.hpp @@ -114,7 +114,7 @@ namespace QuantLib { /*! Fits a discount function to the form \f$ d(t) = \exp^{-r t}, \f$ where the zero rate \f$r\f$ is defined as \f[ - r \equiv c_0 + (c_0 + c_1)(\frac {1 - exp^{-\kappa t}}{\kappa t}) + r \equiv c_0 + (c_1 + c_2)(\frac {1 - exp^{-\kappa t}}{\kappa t}) - c_2exp^{ - \kappa t} + c_3{(\frac{1 - exp^{-\kappa_1 t}}{\kappa_1 t} -exp^{-\kappa_1 t})}. \f] From 59c6359bf36efdcfd5ea197eea74f2eace729700 Mon Sep 17 00:00:00 2001 From: Eugene Toder Date: Sat, 17 Aug 2024 09:11:42 -0400 Subject: [PATCH 2/4] Fix defaulting of localOptimizer in HybridSimulatedAnnealing The current code changes the local variable `localOptimizer` which was already used to initialize the member variable `localOptimizer_` and is no longer used. Also, `localOptimizer` was already used to initialize `optimizeScheme_`. --- ql/experimental/math/hybridsimulatedannealing.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ql/experimental/math/hybridsimulatedannealing.hpp b/ql/experimental/math/hybridsimulatedannealing.hpp index d6a6b989603..91b14663142 100644 --- a/ql/experimental/math/hybridsimulatedannealing.hpp +++ b/ql/experimental/math/hybridsimulatedannealing.hpp @@ -87,7 +87,7 @@ namespace QuantLib { ResetScheme resetScheme = ResetToBestPoint, Size resetSteps = 150, ext::shared_ptr localOptimizer = - ext::shared_ptr(), + ext::shared_ptr(new LevenbergMarquardt), LocalOptimizeScheme optimizeScheme = EveryBestPoint) : sampler_(sampler), probability_(probability), temperature_(std::move(temperature)), reannealing_(reannealing), startTemperature_(startTemperature), @@ -96,8 +96,6 @@ namespace QuantLib { resetScheme_(resetScheme), resetSteps_(resetSteps == 0 ? QL_MAX_INTEGER : resetSteps), localOptimizer_(localOptimizer), optimizeScheme_(localOptimizer != nullptr ? optimizeScheme : NoLocalOptimize) { - if (!localOptimizer) - localOptimizer.reset(new LevenbergMarquardt); } EndCriteria::Type minimize(Problem& P, const EndCriteria& endCriteria) override; From 903dda43386fe860b1b5788fb4aab84a35ad706a Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 19 Aug 2024 09:43:41 +0200 Subject: [PATCH 3/4] Fix LaTeX syntax in formulas --- .../yield/nonlinearfittingmethods.hpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ql/termstructures/yield/nonlinearfittingmethods.hpp b/ql/termstructures/yield/nonlinearfittingmethods.hpp index 4bd372b741e..e03a765ed93 100644 --- a/ql/termstructures/yield/nonlinearfittingmethods.hpp +++ b/ql/termstructures/yield/nonlinearfittingmethods.hpp @@ -34,7 +34,7 @@ namespace QuantLib { //! Exponential-splines fitting method /*! Fits a discount function to the exponential form \f[ - d(t) = \sum_{i=1}^9 c_i \exp^{-kappa i t} + d(t) = \sum_{i=1}^9 c_i e^{-\kappa_i t} \f] where the constants \f$ c_i \f$ and \f$ \kappa \f$ are to be determined. See:Li, B., E. DeWetering, G. Lucas, R. Brenner @@ -82,10 +82,10 @@ namespace QuantLib { //! Nelson-Siegel fitting method /*! Fits a discount function to the form - \f$ d(t) = \exp^{-r t}, \f$ where the zero rate \f$r\f$ is defined as + \f$ d(t) = e^{-r t}, \f$ where the zero rate \f$r\f$ is defined as \f[ - r \equiv c_0 + (c_1 + c_2)*(1 - exp^{-\kappa*t})/(\kappa t) - - c_2 exp^{ - \kappa t}. + r \equiv c_0 + (c_1 + c_2) \left( \frac{1 - e^{-\kappa t}}{\kappa t} \right) - + c_2 e^{ - \kappa t}. \f] See: Nelson, C. and A. Siegel (1985): "Parsimonious modeling of yield curves for US Treasury bills." NBER Working Paper Series, no 1594. @@ -112,11 +112,11 @@ namespace QuantLib { //! Svensson Fitting method /*! Fits a discount function to the form - \f$ d(t) = \exp^{-r t}, \f$ where the zero rate \f$r\f$ is defined as + \f$ d(t) = e^{-r t}, \f$ where the zero rate \f$r\f$ is defined as \f[ - r \equiv c_0 + (c_1 + c_2)(\frac {1 - exp^{-\kappa t}}{\kappa t}) - - c_2exp^{ - \kappa t} - + c_3{(\frac{1 - exp^{-\kappa_1 t}}{\kappa_1 t} -exp^{-\kappa_1 t})}. + r \equiv c_0 + (c_1 + c_2) \left( \frac {1 - e^{-\kappa t}}{\kappa t} \right) + - c_2 e^{ - \kappa t} + + c_3 \left( \frac{1 - e^{-\kappa_1 t}}{\kappa_1 t} -e^{-\kappa_1 t} \right). \f] See: Svensson, L. (1994). Estimating and interpreting forward interest rates: Sweden 1992-4. @@ -146,7 +146,7 @@ namespace QuantLib { /*! Fits a discount function to a set of cubic B-splines \f$ N_{i,3}(t) \f$, i.e., \f[ - d(t) = \sum_{i=0}^{n} c_i * N_{i,3}(t) + d(t) = \sum_{i=0}^{n} c_i \times N_{i,3}(t) \f] See: McCulloch, J. 1971, "Measuring the Term Structure of @@ -192,9 +192,9 @@ namespace QuantLib { //! Simple polynomial fitting method - /* Fits a discount function to the simple polynomial form: + /*! Fits a discount function to the simple polynomial form: \f[ - d(t) = \sum_{i=0}^{degree} c_i * t^{i} + d(t) = \sum_{i=0}^{degree} c_i t^{i} \f] where the constants \f$ c_i \f$ are to be determined. @@ -227,7 +227,8 @@ namespace QuantLib { //! Spread fitting method helper - /* Fits a spread curve on top of a discount function according to given parametric method + /*! Fits a spread curve on top of a discount function according + to the given parametric method */ class SpreadFittingMethod : public FittedBondDiscountCurve::FittingMethod { From 4e3d3399c1d026474e1c7510aa6b63cb26ab283f Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 19 Aug 2024 15:07:25 +0200 Subject: [PATCH 4/4] Modernize initialization --- ql/experimental/math/hybridsimulatedannealing.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/experimental/math/hybridsimulatedannealing.hpp b/ql/experimental/math/hybridsimulatedannealing.hpp index 91b14663142..234d9ed0847 100644 --- a/ql/experimental/math/hybridsimulatedannealing.hpp +++ b/ql/experimental/math/hybridsimulatedannealing.hpp @@ -87,7 +87,7 @@ namespace QuantLib { ResetScheme resetScheme = ResetToBestPoint, Size resetSteps = 150, ext::shared_ptr localOptimizer = - ext::shared_ptr(new LevenbergMarquardt), + ext::make_shared(), LocalOptimizeScheme optimizeScheme = EveryBestPoint) : sampler_(sampler), probability_(probability), temperature_(std::move(temperature)), reannealing_(reannealing), startTemperature_(startTemperature),