Logo

SQL Server PRICEACTTV Function

Updated 2023-10-05 13:19:05.863000

Description

Use the table-valued function PRICEACTTV to return the cash flows of a bond where coupon payments are calculated using the actual number of days in the coupon period and vary from period to period. PRICEACTTV also supports bonds with forced redemptions.

The first row in the resultant table is dated with settlement date passed into the function and is for the amount of the accrued interest. All the remaining rows are dated for the subsequent coupon dates and the amounts are the coupon amount plus any forced redemptions occurring on the coupon date. The row for the maturity date includes the coupon amount and the final redemption amount.

The resultant table also includes the discount factor for each period as will as the discounted cash flow value for each period. The sum of the discounted cash flow values across all the periods is equal to the clean price of the bond.

Syntax

Syntax
SELECT * FROM [westclintech].[wct].[PRICEACTTV](
  <@Settlement, datetime,>
 ,<@Maturity, datetime,>
 ,<@Rate, float,>
 ,<@Par, float,>
 ,<@Yield, float,>
 ,<@Frequency, float,>
 ,<@Basis, nvarchar(4000),>
 ,<@Repayments, nvarchar(max),>)

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 settlement date of the security. @Maturity 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.

@Par

the par value of the security. Any forced redemptions are subtracted from the par value on the redemption date and the adjusted balance is used in calculating the subsequent coupon interest. @Par 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.

@Frequency

the number of coupon payments per year. For annual payments, @Frequency = 1; for semi-annual, @Frequency = 2; for quarterly, @Frequency = 4; for bi-monthly, @Frequency = 6, for monthly, @Frequency = 12. @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
1 , 'ACTUAL'Actual/Actual
2 , 'A360'Actual/360
3 , 'A365'Actual/365
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

@Repayments

a SELECT statement, as a string, which identifies the coupon dates and the forced redemption amounts to be used in the price calculation.

Return Type

table

colNamecolDatatypecolDesc
date_pmtdatetimeDate of the cash flow.
amt_prinfloatPrincipal amount used in the calculation of amt_coupon.
amt_couponfloatamt_prin * @Rate * DIP / DIY.
amt_prinpayfloatPrincipal payment amount.
amt_cashflowfloatamt_coup + amt_prinpay.
DIPfloatNumber of days in the coupon period.
DIYfloatNumber of days in the year.
tfloatDIP/DIY
DFfloatDiscount factor for the period; POWER(1+@Yield/@Frequency, -t)
PVFfloatProduct of DF for current and all preceding rows.
PVCFfloatPVF * amt_cashflow.
cumPVCFfloatSum of the PVCF.
PVPfloatPVCF * @Par/amt_prin(@Settlement).
cumPVPfloatSum of the PVP.

Remarks

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

If @Rate is NULL then @Rate = 0.

If @Redemption is NULL then @Par = 100.

If @Yield is NULL then @Yield = 0.

If @Frequency is NULL then @Frequency = 2.

If @Basis is NULL then @Basis = 1.

If @Maturity <= @Settlement then no rows are returned.

If @Frequency invalid PRICEACTTV returns an error.

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

If @Maturity is NULL then no rows are returned.

Examples

In this example we generate the cash flow for a bond with a maturity on 2034-11-01 and with a coupon interest rate of 11.0% paying interest semi-annually. The bond is priced at a yield of 12.5% and is settling on 2014-10-29. The bond uses the actual/actual day-count convention.

SELECT *
FROM wct.PRICEACTTV(   '2014-10-29', --@Settlement
                       '2034-11-01', --@Maturity
                       0.1100,       --@Rate
                       100,          --@Par
                       0.1250,       --@Yield
                       2,            --@Frequency
                       1,            --@Basis
                       NULL          --@Repayments
                   );

This produces the following result .

date_pmtamt_prinamt_couponamt_prinpayamt_cashflowDIPDIYtDFPVFPVCFcumPVCFPVPcumPVP
2014-10-29 00:00:00.000100-5.454794520547940-5.45479452054794181365011-5.45479452054794-5.45479452054794-5.45479452054794-5.45479452054794
2014-11-01 00:00:00.0001005.5452054794520605.5452054794520633650.01643835616438360.9990039272843460.9990039272843465.539682051571280.08488753102333125.539682051571280.0848875310233312
2015-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.9407076137037755.131366736669095.216254267692425.131366736669095.21625426769242
2015-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.8849308144802514.9071232013918610.12337746908434.9071232013918610.1233774690843
2016-05-01 00:00:00.0001005.4699453551912605.469945355191261823660.9945355191256830.9414883171448460.8331520233146294.5572960400980514.68067350918234.5572960400980514.6806735091823
2016-11-01 00:00:00.0001005.5300546448087405.530054644808741843661.005464480874320.9408647273236920.7838833512351014.3349177674859119.01559127666824.3349177674859119.0155912766682
2017-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.7381402781538854.0264035446695523.04199482133784.0264035446695523.0419948213378
2017-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.6943741796407813.8504475057340926.89244232707193.8504475057340926.8924423270719
2018-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.6538543640394273.5666412021986330.45908352927053.5666412021986330.4590835292705
2018-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.6150857785053293.4107770293007833.86986055857133.4107770293007833.8698605585713
2019-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.5791927930591463.1593776739198937.02923823249123.1593776739198937.0292382324912
2019-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.5448510702330943.0213111401418740.0505493726333.0213111401418740.050549372633
2020-05-01 00:00:00.0001005.4699453551912605.469945355191261823660.9945355191256830.9414883171448460.5129709172083242.8059228859318742.85647225856492.8059228859318742.8564722585649
2020-11-01 00:00:00.0001005.5300546448087405.530054644808741843661.005464480874320.9408647273236920.4826362421441942.6690047926225445.52547705118742.6690047926225445.5254770511874
2021-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.4544722750676382.4790528757799148.00452992696742.4790528757799148.0045299269674
2021-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.4275255293734032.3707169080870450.37524683505442.3707169080870450.3752468350544
2022-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.4025775170149322.1959776339088552.57122446896322.1959776339088552.5712244689632
2022-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.3787077353619072.1000122092397354.6712366782032.1000122092397354.671236678203
2023-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.3566084579786251.9452258625628556.61646254076581.9452258625628556.6164625407658
2023-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.3354642915316551.8602184275618358.47668096832771.8602184275618358.4766809683277
2024-05-01 00:00:00.0001005.4699453551912605.469945355191261823660.9945355191256830.9414883171448460.3158357112963261.7276040820088660.20428505033651.7276040820088660.2042850503365
2024-11-01 00:00:00.0001005.5300546448087405.530054644808741843661.005464480874320.9408647273236920.2971586803879021.6433037407243561.84758879106091.6433037407243561.8475887910609
2025-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.2798181523459631.5263505241666163.37393931522751.5263505241666163.3739393152275
2025-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.263227066364371.4596481707437964.83358748597131.4596481707437964.8335874859713
2026-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.2478665986178771.3520613639676566.18564884993891.3520613639676566.1856488499389
2026-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.2331699965026941.2929755422505667.47862439218951.2929755422505667.4786243921895
2027-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.2195634922013031.1976737341720468.67629812636151.1976737341720468.6762981263615
2027-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.2065450488051551.1453347363880469.82163286274961.1453347363880469.8216328627496
2028-05-01 00:00:00.0001005.4699453551912605.469945355191261823660.9945355191256830.9414883171448460.1944597504141651.0636842085496170.88531707129921.0636842085496170.8853170712992
2028-11-01 00:00:00.0001005.5300546448087405.530054644808741843661.005464480874320.9408647273236920.1829603200488571.0117805677018871.89709763900111.0117805677018871.8970976390011
2029-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.1722837732415150.93977258225714172.83687022125820.93977258225714172.8368702212582
2029-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.1620686572059080.89870400598563773.73557422724380.89870400598563773.7355742272438
2030-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.1526112316603040.83246291023469974.56803713747850.83246291023469974.5680371374785
2030-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.1435625475595580.7960838253713675.36412096284990.7960838253713675.3641209628499
2031-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.135185035657570.73740659176499376.10152755461490.73740659176499376.1015275546149
2031-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.1271695923018930.70518152005213976.8067090746670.70518152005213976.806709074667
2032-05-01 00:00:00.0001005.4699453551912605.469945355191261823660.9945355191256830.9414883171448460.1197286854483050.65490936685111177.46161844151810.65490936685111177.4616184415181
2032-11-01 00:00:00.0001005.5300546448087405.530054644808741843661.005464480874320.9408647273236920.1126484969871440.62295234399447778.08457078551260.62295234399447778.0845707855126
2033-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.1060749571587330.57861709507681478.66318788058940.57861709507681478.6631878805894
2033-11-01 00:00:00.0001005.5452054794520605.545205479452061843651.008219178082190.9407076137037750.09978551982252170.55333121128981979.21651909187920.55333121128981979.2165190918792
2034-05-01 00:00:00.0001005.4547945205479505.454794520547951813650.9917808219178080.9416455611550590.09396259180842760.51254663093309479.72906572281230.51254663093309479.7290657228123
2034-11-01 00:00:00.0001005.54520547945206100105.5452054794521843651.008219178082190.9407076137037750.08839132551752789.3292806143486189.05834633716099.3292806143486189.0583463371609

In this example we have a bond maturing on 2019-10-31 with a 12.5% coupon paid semi-annually. The bond has 16 equal forced redemptions starting with the 2012-04-30 coupon. The bond is priced at a yield of 12.5% settling on 2014-10-29.

SELECT *
FROM wct.PRICEACTTV(
                       '2014-10-29', --@Settlement
                       '2019-10-31', --@Maturity
                       0.125,        --@Rate
                       100,          --@Par
                       0.125,        --@Yield
                       2,            --@Frequency
                       1,            --@Basis
                       'SELECT
          *
       FROM (VALUES
           (''2012-04-30'',6.25)
          ,(''2012-10-31'',6.25)
          ,(''2013-04-30'',6.25)
          ,(''2013-10-31'',6.25)
          ,(''2014-04-30'',6.25)
          ,(''2014-10-31'',6.25)
          ,(''2015-04-30'',6.25)
          ,(''2015-10-31'',6.25)
          ,(''2016-04-30'',6.25)
          ,(''2016-10-31'',6.25)
          ,(''2017-04-30'',6.25)
          ,(''2017-10-31'',6.25)
          ,(''2018-04-30'',6.25)
          ,(''2018-10-31'',6.25)
          ,(''2019-04-30'',6.25)
          ,(''2019-10-31'',6.25)
          )n(dt_ppay, amt_ppay)'     --@Repayments
                   );

This produces the following result.

date_pmtamt_prinamt_couponamt_prinpayamt_cashflowDIPDIYtDFPVFPVCFcumPVCFPVPcumPVP
2014-10-29 00:00:00.00068.75-4.285102739726030-4.28510273972603182365011-4.28510273972603-4.28510273972603-6.23287671232877-6.23287671232877
2014-10-31 00:00:00.00068.754.332191780821926.2510.582191780821923650.0109589041095890.999335841233970.9993358412339710.57516352538696.2900607856608515.38205603692649.14917932459761
2015-04-30 00:00:00.00062.53.874143835616446.2510.12414383561641813650.9917808219178080.9416455611550590.9410201590011259.5270234419420415.817084227602913.857488642824823.0066679674224
2015-10-31 00:00:00.00056.253.544520547945216.259.794520547945211843651.008219178082190.9407076137037750.8852248282210958.6703527695627824.487436997165712.611422210273135.6180901776955
2016-04-30 00:00:00.000503.107923497267766.259.357923497267761823660.9945355191256830.9414883171448460.8334288338167147.799163267273932.286600264439611.344237479671146.9623276573666
2016-10-31 00:00:00.00043.752.749316939890716.258.999316939890711843661.005464480874320.9408647273236920.7841437924726657.056758514909439.34335877934910.264376021686457.226703679053
2017-04-30 00:00:00.00037.52.324486301369866.258.574486301369861813650.9917808219178080.9416455611550590.7383855214891796.331276539138845.67463531848789.2091295114746366.4358331905277
2017-10-31 00:00:00.00031.251.969178082191786.258.219178082191781843651.008219178082190.9407076137037750.6946048819135035.7090812212068751.38371653969468.3041181399372774.7399513304649
2018-04-30 00:00:00.000251.549657534246586.257.799657534246581813650.9917808219178080.9416455611550590.6540716038104835.1015345125971856.48525105229187.4204138365049982.1603651669699
2018-10-31 00:00:00.00018.751.181506849315076.257.431506849315071843651.008219178082190.9407076137037750.6152901376119614.572532871979361.05778392427116.6509569046971688.8113220716671
2019-04-30 00:00:00.00012.50.7748287671232886.257.024828767123291813650.9917808219178080.9416455611550590.5793852269047884.0700820092070165.12786593347815.9201192861192994.7314413577864
2019-10-31 00:00:00.0006.250.3938356164383566.256.643835616438361843651.008219178082190.9407076137037750.5450320942168233.6211036396597268.74896957313795.2670598395050499.9985011972914

See Also

BONDCF - Cash flows for a bond paying regular periodic interest

PRICEACT - Price of a bond where the coupon amounts are calculated as the actual number of days in the coupon period divided by the number of days in the year.

YIELDACT - Yield on a bond where the coupon amounts are calculated as the actual number of days in the coupon period divided by the number of days in the year

ACCINTACT - Accrued interest on a bond where the coupon amounts are calculated as the actual number of days in the coupon period divided by the number of days in the year.