Logo

SQL Server OFLFACTORS Function

Updated 2023-10-06 20:56:56.480000

Description

Use the table-valued function OFLFACTORS to return the components used in the calculation of price and yield for a bond with an odd first and odd last coupon. OFLFACTORS supports odd first and odd last coupon bonds with up to 2 quasi-coupon periods each.

Syntax

SELECT * FROM [westclintech].[wct].[OFLFACTORS](
  <@Settlement, datetime,>
 ,<@Maturity, datetime,>
 ,<@Issue, datetime,>
 ,<@FirstCoupon, datetime,>
 ,<@LastCoupon, datetime,>
 ,<@Rate, float,>
 ,<@Price, float,>
 ,<@Yield, float,>
 ,<@Redemption, float,>
 ,<@Frequency, float,>
 ,<@Basis, nvarchar(4000),>)

Arguments

@Settlement

the settlement date of the bond. @Settlement is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@Maturity

the maturity date of the bond. @Maturity is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@Issue

the issue date of the bond; the date from which the bond starts accruing interest. @Issue is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@FirstCoupon

the first coupon date of the bond. The period from the issue date until the first coupon date defines the odd interest period. All subsequent coupon dates are assumed to occur at regular periodic intervals as defined by @Frequency. @FirstCoupon is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@LastCoupon

the last coupon date of the bond prior to the maturity. The period from the last interest date until the maturity date defines the odd interest period. All coupon dates from @FirstCoupon to @LastCoupon are assumed to occur at regular periodic intervals as defined by @Frequency. @LastCoupon is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@Rate

the bond's annual coupon rate. @Rate is an expression of type float or of a type that can be implicitly converted to float.

@Price

the price of the bond. @Price is an expression of type float or of a type that can be implicitly converted to float.

@Yield

the bond's annual yield. @Yld is an expression of type float or of a type that can be implicitly converted to float.

@Redemption

the bond's redemption value per 100 face value. @Redemption is an expression of type float or of a type that can be implicitly converted to float.

@Frequency

the number of coupon payments per year. For annual payments, @Frequency = 1; for semi-annual, @Frequency = 2; for quarterly, @Frequency = 4; for bimonthly @Frequency = 6; for monthly @Frequency = 12. For bonds with @Basis = 'A/364' or 9, you can enter 364 for payments made every 52 weeks, 182 for payments made every 26 weeks, 91 for payments made every 13 weeks, 28 for payments made every 4 weeks, 14 for payments made every 2 weeks, and 7 for weekly payments. @Frequency is an expression of type float or of a type that can be implicitly converted to float.

@Basis

is the type of day count to use. @Basis is an expression of the character string data type category.

@BasisDay count basis
0 , 'BOND'US (NASD) 30/360
1 , 'ACTUAL'Actual/Actual
2 , 'A360'Actual/360
3 , 'A365'Actual/365
4 , '30E/360 (ISDA)' , '30E/360' , 'ISDA' , '30E/360 ISDA' , 'EBOND'European 30/360
5 , '30/360' , '30/360 ISDA' , 'GERMAN'30/360 ISDA
6 , 'NL/ACT'No Leap Year/ACT
7 , 'NL/365'No Leap Year /365
8 , 'NL/360'No Leap Year /360
9 , 'A/364'Actual/364
10 , 'BOND NON-EOM'US (NASD) 30/360 non-end-of-month
11 , 'ACTUAL NON-EOM'Actual/Actual non-end-of-month
12 , 'A360 NON-EOM'Actual/360 non-end-of-month
13 , 'A365 NON-EOM'Actual/365 non-end-of-month
14 , '30E/360 NON-EOM' , '30E/360 ICMA NON-EOM' , 'EBOND NON-EOM'European 30/360 non-end-of-month
15 , '30/360 NON-EOM' , '30/360 ISDA NON-EOM' , 'GERMAN NON-EOM'30/360 ISDA non-end-of-month
16 , 'NL/ACT NON-EOM'No Leap Year/ACT non-end-of-month
17 , 'NL/365 NON-EOM'No Leap Year/365 non-end-of-month
18 , 'NL/360 NON-EOM'No Leap Year/360 non-end-of-month
19 , 'A/364 NON-EOM'Actual/364 non-end-of-month

Return Type

table

colNamecolDatatypecolDesc
A1floatIf NCF = 1, the number of days from @Issue to the @Settlement. If NCF = 2 and @Settlement >= quasicoupfirst then DFC1 else the number of days from quasicoupfirst to @Settlement.
A2floatIf NCF = 1 then NULL. If NCF = 2 and @Settlement >= quasicoupfirst then the number of days from quasicoupfirst to @Settlement else 0.
DSCfloatNumber of days from the @Settlement to the next quasi-coupon date.
EfloatNumber of coupon days in the quasi-coupon period in which the settlement date falls.
NintNumber of coupons between @FirstCoupon and @LastCoupon.
NCLint Number of quasi-coupon periods in the odd last period (1 or 2).
NCFint Number of quasi-coupon periods in the odd first period (1 or 2).
DLC1float If NCL = 1, the number of days from @LastCoupon to @Maturity else NLL1
DLC2float If NCL =2 then NULL else the number of days from quasicouplast to @Maturity.
NLL1floatThe normal length of the first quasi-coupon period in the last coupon period. If NCL = 1 the length of the period from @LastCoupon to quasimaturity else the length of the period from @LastCoupon to quasimaturity.
NLL2float If NCL = 1 then NULL else the normal length of the period from quasicouplast to quasimaturity.
DFC1floatThe normal length of the first quasi-coupon period minus the number of days from quasistart to @Issue.
DFC2floatIf NCF = 2 then NULL else NLF2
NLF1float The normal length of the first quasi-coupon period in the odd first period. If NCF = 1 then number of days from quasistart to @FirstCoupon else the number of days from quasistart to quasicoupfirst.
NLF2floatThe normal length for the second quasi-coupon period in the odd first period. If NCF = 1 then NULL else the number of days from quasicoupfirst to @FirstCoupon.
NqffloatNumber of whole coupons between @Settlement and @FirstCoupon.
quasistartdatetimeImplied previous coupon date with respect to @Issue.
quasicoupfirstdatetimeIf NCF = 1 then NULL else the implied next coupon date with respect to @Issue.
quasicouplastdatetimeIf NCL = 1 then NULL else the implied next coupon date with respect to @LastCoupon.
quasimaturitydatetimeThe implied next coupon date with respect to @Maturity.
CfloatCoupon amount
LCfloatLast coupon amount
FCfloatFirst coupon amount
PfloatPrice. If @Yield is NOT NULL then P is calculated from the inputs otherwise P is the value entered in @Price.
AIfloat Accrued interest as of the settlement date.
YfloatYield. If @Yield is NOT NULL then Y is the value entered in @Yield otherwise Y is calculated from the inputs.

Remarks

If @Settlement is NULL then @Settlement = GETDATE().

If @Rate is NULL then @Rate = 0.

If @Redemption is NULL then @Redemption = 100.

If @Frequency is NULL then @Frequency = 2.

If @Basis is NULL then @Basis = 0.

If @Frequency is any number other than 1, 2, 4, 6 or 12, or for @Basis = 'A/364' any number other than 1, 2, 4, 6 or 12 as well as 7, 14, 28, 91, 182 or 364 OFLFACTORS returns an error.

If @Basis is invalid (see above list), OFLFACTORS returns an error.

If @Maturity is NULL then an error is returned.

If @Issue is NULL then an error is returned.

If @FirstCoupon is NULL then an error is returned.

If @LastCoupon is NULL then an error is returned.

If @Settlement >= @FirstCoupon then nothing is returned.

The first quasi-coupon period in the odd first period is always the quasi-coupon period in which @Issue occurs.

The first quasi-coupon in the odd last period is always the quasi-coupon period in which @LastCoupon occurs.

The previous coupon date for the first quasi-coupon period is calculated using @Frequency, @Basis, and @LastCoupon. This is the value returned in quasistart.

If there is only one quasi-coupon in the odd first period then quasicoupfirst is NULL. Otherwise the previous coupon date for the second quasi-coupon period is calculated using @Frequency, @Basis, and @LastCoupon.

If there is only on quasi-coupon period in the odd last period the quasicouplast is NULL.

Examples

This is a bond with an odd short first coupon and an odd short last coupon.

SELECT *
FROM wct.OFLFACTORS(   '2013-03-04', --@Settlement
                       '2022-04-28', --@Maturity
                       '2012-12-07', --@Issue
                       '2013-03-15', --@FirstCoupon
                       '2022-03-15', --@LastCoupon
                       .03125,       --@Rate
                       NULL,         --@Price
                       .02875,       --@Yield
                       100,          --@Redemption
                       2,            --@Frequency
                       1             --@Basis
                   );

This produces the following result.

A1A2DSCENNCLNCFDLC1DLC2NLL1NLL2DFC1DFC2NLF1NLF2NqfquasistartquasicoupfirstquasicouplastquasimaturityCLCFCPAIY
87NULL11181181144NULL184NULL98NULLNULLNULL02012-09-15 00:00:00.000NULLNULL2022-09-15 00:00:00.0001.56250.3736413043478260.845994475138122102.000362245980.751035911602210.02875

This is a bond with an odd long first coupon and an odd long last coupon.

SELECT *
FROM wct.OFLFACTORS(   '2013-03-04', --@Settlement
                       '2022-11-28', --@Maturity
                       '2012-06-07', --@Issue
                       '2013-03-15', --@FirstCoupon
                       '2022-03-15', --@LastCoupon
                       .03125,       --@Rate
                       NULL,         --@Price
                       .02875,       --@Yield
                       100,          --@Redemption
                       2,            --@Frequency
                       1             --@Basis
                   );

This produces the following result.

A1A2DSCENNCLNCFDLC1DLC2NLL1NLL2DFC1DFC2NLF1NLF2NqfquasistartquasicoupfirstquasicouplastquasimaturityCLCFCPAIY
1001701118118221847418418110018118418102012-03-15 00:00:00.0002012-09-15 00:00:00.0002022-09-15 00:00:00.0002023-03-15 00:00:00.0001.56252.201312154696132.4116847826087102.1034334257672.316726219072780.02875

This is a bond with an odd long first coupon and an odd short last coupon.

SELECT *
FROM wct.OFLFACTORS(   '2013-03-04',     --@Settlement
                       '2022-04-28',     --@Maturity
                       '2012-06-07',     --@Issue
                       '2013-03-15',     --@FirstCoupon
                       '2022-03-15',     --@LastCoupon
                       .03125,           --@Rate
                       101.999004756314, --@Price
                       NULL,             --@Yield
                       100,              --@Redemption
                       2,                --@Frequency
                       1                 --@Basis
                   );

This produces the following result.

A1A2DSCENNCLNCFDLC1DLC2NLL1NLL2DFC1DFC2NLF1NLF2NqfquasistartquasicoupfirstquasicouplastquasimaturityCLCFCPAIY
10017011181181244NULL184NULL10018118418102012-03-15 00:00:00.0002012-09-15 00:00:00.000NULL2022-09-15 00:00:00.0001.56250.3736413043478262.4116847826087101.9990047563142.316726219072780.0287500000072949

This is a bond with an odd short first coupon and an odd long last coupon.

SELECT *
FROM wct.OFLFACTORS(   '2013-03-04',     --@Settlement
                       '2022-11-28',     --@Maturity
                       '2012-12-07',     --@Issue
                       '2013-03-15',     --@FirstCoupon
                       '2022-03-15',     --@LastCoupon
                       .03125,           --@Rate
                       102.104790915433, --@Price
                       NULL,             --@Yield
                       100,              --@Redemption
                       2,                --@Frequency
                       1                 --@Basis
                   );

This produces the following result.

A1A2DSCENNCLNCFDLC1DLC2NLL1NLL2DFC1DFC2NLF1NLF2NqfquasistartquasicoupfirstquasicouplastquasimaturityCLCFCPAIY
87NULL1118118211847418418198NULLNULLNULL02012-09-15 00:00:00.000NULL2022-09-15 00:00:00.0002023-03-15 00:00:00.0001.56252.201312154696130.845994475138122102.1047909154330.751035911602210.0287500000109004

This is an example of a bond paying interest every 26 weeks.

SELECT *
FROM wct.OFLFACTORS(   '2014-10-04', --@Settlement
                       '2029-12-12', --@Maturity
                       '2014-07-30', --@Issue
                       '2015-03-18', --@First_coupon
                       '2029-02-28', --@Last_coupon
                       .1250,        --@Rate
                       NULL,         --@Price
                       .1100,        --@Yld
                       100,          --@Redemption
                       182,          --@Frequency
                       9             --@Basis
                   );

This produces the following result.

A1A2DSCENNCLNCFDLC1DLC2NLL1NLL2DFC1DFC2NLF1NLF2NqfquasistartquasicoupfirstquasicouplastquasimaturityCLCFCPAIY
491716518228221821051821824918218218202014-03-19 00:00:00.0002014-09-17 00:00:00.0002029-08-29 00:00:00.0002030-02-27 00:00:00.0006.259.855769230769237.93269230769231110.8460988282632.266483516483520.11

See Also

ODDFINT - Accrued interest for a bond with an odd first coupon

OFCFACTORS - Returns the components of the ODDFPRICE equation

OFL - Calculate the price and/or yield of a bond with an odd first and an odd last coupon using the OFLPRICE equation

OFLCONVEXITY - Convexity of a bond with an odd first and odd last coupon

OFLDURATION - Duration of a bond with an odd first and odd last coupon

OFCMDURATION - Modified duration of a bond with an odd first coupon

OFLPRICE - Price of a security with an odd last coupon.

OFLYIELD - Yield of a bond with an odd first and an odd last coupon

OLCFACTORS - Returns the components of the ODDLPRICE equation

RPIFACTORS - Factors for the calculation of the price of a bond that pays regular periodic interest