Logo

SQL Server IAMFACTORS Function

Updated 2023-10-06 14:18:11.283000

Description

Use the table-valued function IAMFACTORS to return the components used in the calculation of price and yield for a security that pays interest at maturity.

Syntax

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

Arguments

@Settlement

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

@Maturity

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

@Issue

the issue date of the security. @Issue is an expression that returns a datetime or smalldatetime value, or a character string in date format.

@Rate

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

@Price

the security's price per 100 face value. @Price is an expression of type float or of a type that can be implicitly converted to float.

@Yield

the security's annual yield. @Yield 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
7 , 'NL/365'No Leap Year /365
8 , 'NL/360'No Leap Year /360
9 , 'A/364'Actual/364

Return Type

table

colNamecolDatatypecolDesc
AfloatNumber of accrued days from the previous coupon date to the settlement date.
Bfloat`Number of days in a year.
DIMfloatNumber of days from issue to maturity
DSMfloatNumber of days from settlement to maturity
PfloatPrice
AIfloatAccrued Interest
YfloatYield
TIfloatTotal interest
DPfloatDirty Price: P + TI

Remarks

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

If @Rate is NULL then @Rate = 0.

If @Basis is NULL then @Basis = 0.

If @Frequency is invalid then IAMFACTORS returns an error.

If @Basis invalid then IAMFACTORS returns an error.

If @Maturity is NULL then an error is returned.

If @Yield is NULL then Y is calculated from @Price and P = @Price otherwise P is calculated from @Yield and Y = @Yield.

Examples

In this example we calculate the factors for a security issued on 2014-07-31 maturing on 2014-12-15 with an interest rate of 0.5% and a yield of 0.2%. Interest is calculated using the Actual/365 day-count convention.

SELECT *
FROM wct.IAMFACTORS(   '2014-10-07', --@Settlement
                       '2014-12-15', --@Maturity
                       '2014-07-31', --@Issue   
                       0.005,        --@Rate
                       NULL,         --@Price
                       0.002,        --@Yield
                       3             --@Basis
                   );

This produces the following result.

ABDIMDSMPAIYTIDP
6836513769100.0566556896450.09315068493150690.0020.187671232876712100.149806374576

In this example, we calculate the factors for a security issued on 2014-08-15 maturing on 2014-12-01 with an interest rate of -0.05% and a price of 99.977088. Interest is calculated using the Actual/360 day-count convention.

SELECT *
FROM wct.IAMFACTORS(   '2014-10-07', --@Settlement
                       '2014-12-01', --@Maturity
                       '2014-08-15', --@Issue   
                       -0.0005,      --@Rate
                       99.977088,    --@Price
                       NULL,         --@Yield
                       2             --@Basis
                   );

This produces the following result.

ABDIMDSMPAIYTIDP
533601085599.977088-0.007361111111111110.000999997275740647-0.01599.9697268888889

In this example we calculate the factors for a security issued on 2014-08-10 maturing on 2014-11-15 with a yield of -0.05% and an interest rate of 0.2%. Interest is calculated using the 30/E 360 (ISDA) day-count convention.

SELECT *
FROM wct.IAMFACTORS(   '2014-10-07', --@Settlement
                       '2014-11-15', --@Maturity
                       '2014-08-10', --@Issue   
                       0.002,        --@Rate
                       NULL,         --@Price
                       -0.0005,      --@Yield
                       4             --@Basis
                   );

This produces the following result.

ABDIMDSMPAIYTIDP
573609538100.0263919530940.0316666666666667-0.00050.0527777777777778100.05805861976

Here we calculate the factors for a security issued on 2014-07-01 matures on 2014-12-29 with an interest rate of 7.0% and a price of 99.628637. Interest is calculated using the Actual/364 day-count convention.

SELECT *
FROM wct.IAMFACTORS(   '2014-10-07', --@Settlement
                       '2014-12-29', --@Maturity
                       '2014-07-01', --@Issue   
                       0.07,         --@Rate
                       99.628637,    --@Price
                       NULL,         --@Yield
                       9             --@Basis
                   );

This produces the following result.

ABDIMDSMPAIYTIDP
983641818399.6286371.884615384615380.08500001619190743.48076923076923101.513252384615

See Also

IAM - Price and/or yield of a security paying interest at maturity

PRICEMAT - Price of an interest-at-maturity security

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

OFCFACTORS - Returns the components of the ODDFPRICE equation

OLCFACTORS - Returns the components of the ODDLPRICE equation

OFLFACTORS - Returns the components of the OFLPRICE equation

DISFACTORS - Factors for the price calculation of a discount security

YIELDMAT - Calculate the YIELD of an Interest-at-Maturity Security