Logo

SQL Server NELSONSIEGEL Function

Updated 2024-02-23 21:51:30.770000

Description

Use the scalar function NELSONSIEGEL to calculate the zero coupon rate for a date from the supplied parameters. Nelson and Siegel suggested calculating the yield curve at a point using this formula:

y_{\tau}=\beta_1+\beta_2\left(\frac{1-e^{-\lambda\tau}}{\lambda\tau}\right)+\beta_3\left(\frac{1-e^{-\lambda\tau}}{\lambda\tau}-e^{-\lambda\tau}\right)

Syntax

SELECT [wctFinancial].[wct].[NELSONSIEGEL](
  <@Maturity, float,>
 ,<@B0, float,>
 ,<@B1, float,>
 ,<@B2, float,>
 ,<@Tau, float,>)

Arguments

@Maturity

The amount of time, in years, to the maturity date. @Maturity is an expression of type float or of a type that can be implicitly converted to float.

@B0

The first factor passed to the function. @B0 is an expression of type float or of a type that can be implicitly converted to float.

@B1

The second factor passed to the function. @B1 is an expression of type float or of a type that can be implicitly converted to float.

@B2

The third factor passed to the function. @B2 is an expression of type float or of a type that can be implicitly converted to float.

@Tau

The fourth factor passed to the function. @Tau is an expression of type float or of a type that can be implicitly converted to float.

Return Type

float

Remarks

Use the YEARFRAC function to calculate @Maturity.

Use he NSCOEF function to calculate the @B0, @B1, @B2, and @Tau coefficients to pass into the function.

Examples

In this example, we calculate the interpolated values for maturities 1 through 30. We use the SERIESINT function to generate the interpolation points and the NSCOEF function to calculate the coefficients.

SELECT l.SeriesValue as Maturity,
       wct.NELSONSIEGEL(l.seriesvalue, --@Maturity
                        k.B0, --@B0
                        k.B1, --@B1
                        k.B2, --@B2
                        k.Tau --@Tau
       ) as Rate
  FROM wct.NSCOEF(
           'SELECT 1,0.0028 UNION ALL
SELECT 2,0.0056 UNION ALL
SELECT 3,0.0085 UNION ALL
SELECT 5,0.0164 UNION ALL
SELECT 7,0.0235 UNION ALL
SELECT 10,0.0299 UNION ALL
SELECT 20,0.0382 UNION ALL
SELECT 30,0.0406') k
 CROSS APPLY wctMath.wct.SERIESINT(1, 30, NULL, NULL, NULL) l;

This produces the following result.

MaturityRate
10.00298376016908077
20.00502183409700056
30.00882352652310086
40.0129791854798192
50.01688451200725
60.0203250711182928
70.0232655280620921
80.0257452146778906
90.0278282144583457
100.0295809000334999
110.0310629320906263
120.0323245911890544
130.0334068839430623
140.0343427004330867
150.0351582280427677
160.0358742856167667
170.0365074605874693
180.0370710301382507
190.0375756871537565
200.038030103897961
210.0384413665717732
220.0388153095955544
230.0391567730501985
240.0394698016184686
250.0397577990823069
260.0400236490213598
270.0402698097283141
280.0404983893656884
290.0407112058966696
300.0409098352100148