bisection_alpha#
Functions
|
Bisection root finding algorithm for finding the root of a function. |
|
Calculates the gap at the convergence point |
- Galfa(M_Obs: ndarray, r_Obs: ndarray, ufr, alpha, Tau)[source]#
Calculates the gap at the convergence point
Calculates the gap at the convergence point between the alowable tolerance Tau and the curve extrapolated using the Smith-Wilson algorithm. interpolation and extrapolation of rates.
- Parameters:
M_Obs – n x 1 ndarray of maturities of bonds, that have rates provided in input (r). Ex. u=[[1], [3]]
r_Obs – n x 1 ndarray of rates, for which you wish to calibrate the algorithm. Each rate belongs to an observable zero coupon bond with a known maturity. Ex. r = [[0.0024], [0.0034]]
ufr – 1 x 1 floating number, representing the ultimate forward rate. Ex. ufr = 0.042
alpha – 1 x 1 floating number representing the convergence speed parameter alpha. Ex. alpha = 0.05
Tau – 1 x 1 floating number representing the allowed difference between ufr and actual curve. Ex. Tau = 0.00001
- Returns:
1 x 1 floating number representing the distance between ufr input and the maximum allowed discrepancy Tau
Example
>>> import numpy as np >>> M_Obs = np.transpose(np.array([1, 2, 4, 5, 6, 7])) >>> r_Obs = np.transpose(np.array([0.01, 0.02, 0.03, 0.032, 0.035, 0.04])) >>> alfa = 0.15 >>> ufr = 0.04 >>> Precision = 0.0000000001 >>> Tau = 0.0001 >>> Galfa(M_Obs, r_Obs, ufr, alfa, Tau) -8.544212205612438e-05
For more information see https://www.eiopa.europa.eu/sites/default/files/risk_free_interest_rate/12092019-technical_documentation.pdf
Implemented by Gregor Fabjan from Qnity Consultants on 17/12/2021.
- BisectionAlpha(xStart, xEnd, M_Obs, r_Obs, ufr, Tau, Precision, maxIter)[source]#
Bisection root finding algorithm for finding the root of a function.
The function here is the allowed difference between the ultimate forward rate and the extrapolated curve using Smith & Wilson.
- Parameters:
xStart – 1 x 1 floating number representing the minimum allowed value of the convergence speed parameter alpha. Ex. alpha = 0.05
xEnd – 1 x 1 floating number representing the maximum allowed value of the convergence speed parameter alpha. Ex. alpha = 0.8
M_Obs – n x 1 ndarray of maturities of bonds, that have rates provided in input (r). Ex. u=[[1], [3]]
r_Obs – n x 1 ndarray of rates, for which you wish to calibrate the algorithm. Each rate belongs to an observable zero coupon bond with a known maturity. Ex. r = [[0.0024], [0.0034]]
ufr – 1 x 1 floating number, representing the ultimate forward rate. Ex. ufr = 0.042
Tau – 1 x 1 floating number representing the allowed difference between ufr and actual curve. Ex. Tau = 0.00001
Precision – 1 x 1 floating number representing the precision of the calculation. Higher the precision, more aqurate the estimation of the root
maxIter – 1 x 1 positive integer representing the maximum number of iterations allowed. This is to prevent an infinite loop in case the method does not converge to a solution
- Returns:
1 x 1 floating number representing the optimal value of the parameter alpha
Example
>>> import numpy as np >>> M_Obs = np.transpose(np.array([1, 2, 4, 5, 6, 7])) >>> r_Obs = np.transpose(np.array([0.01, 0.02, 0.03, 0.032, 0.035, 0.04])) >>> xStart = 0.05 >>> xEnd = 0.5 >>> maxIter = 1000 >>> alfa = 0.15 >>> ufr = 0.042 >>> Precision = 0.0000000001 >>> Tau = 0.0001 >>> BisectionAlpha(xStart, xEnd, M_Obs, r_Obs, ufr, Tau, Precision, maxIter) 0.11549789285636511
For more information see https://www.eiopa.europa.eu/sites/default/files/risk_free_interest_rate/12092019-technical_documentation.pdf and https://en.wikipedia.org/wiki/Bisection_method
Implemented by Gregor Fabjan from Qnity Consultants on 17/12/2021.