Updated: 27 Nov 2017
Use CDRRate to calculate a CDR Rate given a default amount, to be used in the CDRCASHFLOW table-valued function.
Syntax
SELECT [wct].[CDRRate] (
<@PrinAmt, float,>
,<@InterestRate, float,>
,<@NumPmts, int,>
,<@LastPmtNum, int,>
,<@PmtPerYr, int,>
,<@CPRRatesQuery, nvarchar(max),>
,<@DefAmt, float,>
,<@InterestOnly, bit,>
,<@PrinPaymentMultiple, int,>
,<@FirstPrinPayNo, int,>
,<@PmtPayPct, float,>)
Arguments
Input Name | Description |
@PrinAmt | the principal amount to be amortized. @PrinAmt is an expression of type float or of a type that can be implicitly converted to float. |
@InterestRate | the annual rate of interest used to calculate the periodic payment. @InterestRate is an expression of type float or of a type that can be implicitly converted to float. |
@NumPmts | the number of periods to be used in the calculation of the periodic payment. @NumPmts is an expression of type int or of a type that can be implicitly converted to int. |
@LastPmtNum | the number of the last payment. Use @LastPmtNum for case where the number of payments for the annuity calculation is different than the actual number of payments, For example, an annuity based on 300 monthly payment which will be paid off at the end of 120 months. @LastPmtNum is an expression of type int or of a type that can be implicitly converted to int. |
@PmtPerYr | the number of payments per year. @PmtPerYr is an expression of type int or of a type that can be implicitly converted to int. |
@CPRRatesQuery | a SELECT statement, as a string, which returns the month and prepayment rates to be used in the calculation of the principal prepayments. @CPRratesQuery should return 2 columns, month and rate, where 1% = .01. |
@DefAmt | The anticipated default amount for the cash flows. @DefAmt must be of a type float or of a type that can be implicitly converted to float. |
@InterestOnly | a bit value, which when true, identifies that the principal amount is scheduled to be repaid at the end of the loan. |
@PrinPaymentMultiple | the ratio of the frequency of the interest payments to the frequency of the interest payments. For example, a loan with monthly payments of interest and quarterly payments of principal would have a @PrinPaymentMultiple of 3. @PrinPaymentMultiple is an expression of type int or of a type that can be implicitly converted to int. |
@FirstPrinPayNo | the payment number of the first principal payment. @FirstPrinPayNo is an expression of type int or of a type that can be implicitly converted to int. |
@PmtPayPct | a fixed percentage which is applied to the projected principal balance to calculate the projected principal payment. @PmtPayPct is of a type float or of a type that can be implicitly converted to float. |
Return Type
Remarks
- If @FirstPrinPayNo is NULL then @FirstPrinPayNo = 1.
- If @PrinAmt is NULL then @PrinAmt = 0.
- If @InterestRate is NULL then @InterestRate = 0.
- If @NumPmts is NULL then @NumPmts = 0.
- If @LastPmtNum is NULL then @LastPmtNum = @NumPmts.
- If @InterestOnly is NULL then @InterestOnly = FALSE.
- If @PrinPaymentMultiple is NULL then @PrinPaymentMultiple = 1.
- If @FirstPrinPayNo is NULL then @FirstPrinPayNo = @PrinPaymentMultiple.
- If @NumPmts < 1 then no rows are returned.
- If @PrinPaymentMultiple < 1 then no rows are returned.
- If @FirstPrinPayNo < 1 then no rows are returned.
- @PmtPerYr must be 1, 2, 3, 4, 6, or 12.
- If @CPRRatesQuery returns NULL or no rows then CPR is set to zero.
- If SIGN(@PrinAmt) <> SIGN(@DefAmt) then NULL is returned
- Available in XLeratorDB / financial 2008 only
Examples
Use the following CPR rates, which have been inserted into the #cpr table, for all of the examples.
SELECT * INTO #cpr FROM (VALUES
(1,0.002),(25,0.012),(61,0.02),(181,0.06))n(mth,rate)
Example #1
In this example we calculate the CDR rate for a 1,000,000 loan with a 5% interest rate over 120 months using the data from the #cpr table with an a default amount of 5,500.00.
SELECT wct.CDRRate(
1000000
,0.05
,120
,NULL
,12
,'SELECT * FROM #cpr'
,5500.00
,NULL
,NULL
,NULL
,NULL
) as [CDR Rate]
This produces the following result.
Using this rate in the CDRCashFlow function will calculate periodic default amounts which sum to the default amount, as demonstrated in the following SQL.
SELECT
SUM(amt_default) as [Default Amount]
FROM wct.CDRCashFlow(
1000000
,0.05
,120
,NULL
,12
,NULL
,'SELECT * FROM #cpr'
,'SELECT 1, 0.00104013790645852'
,NULL
,NULL
,NULL
,NULL
)
This produces the following amount.
Example #2
In this example, we have a 10-year, 2,000,000 loan, with monthly payments calculated as though it were a 25-year loan. The default amount is 16,000.00.
SELECT wct.CDRRate(
2000000
,0.05
,300
,120
,12
,'SELECT * FROM #cpr'
,16000
,NULL
,NULL
,NULL
,NULL
) as [CDR Rate]
This produces the following result.
Example #3
In this example we have a 10-year, 2,500,000 interest-only loan with quarterly payments. The default amount is 25,000.
SELECT wct.CDRRate(
250000
,0.04
,40
,NULL
,4
,'SELECT * FROM #cpr'
,25000
,'True'
,NULL
,NULL
,NULL
) as [CDR Rate]
This produces the following result.
Example #4
In this example we have a 1,000,000 loan with monthly payments of interest and quarterly payments of principal. The loan matures in 120 months. The default amount is 17,000.
SELECT wct.CDRRate(
1000000
,0.06
,120
,NULL
,12
,'SELECT * FROM #cpr'
,17000
,NULL
,3
,NULL
,NULL
) as [CDR Rate]
This produces the following result.
Example #5
This example uses the same loan as the previous loan, 1 month later.
SELECT wct.CDRRate(
1000000
,0.06
,119
,NULL
,12
,'SELECT * FROM #cpr'
,16721.69
,NULL
,3
,NULL
,NULL
) as [CDR Rate]
This produces the following result.
Example #6
This is an interest-only loan.
SELECT wct.CDRRate(
50000
,.05
,36
,NULL
,12
,'SELECT * FROM #cpr'
,1100
,'TRUE'
,NULL
,NULL
,NULL
) as [CDR Rate]
This produces the following result.
Example #7
In this loan the principal payment is a fixed percentage of the outstanding principal.
SELECT wct.CDRRate(
1000000
,.18
,24
,NULL
,12
,'SELECT * FROM #cpr'
,13000
,NULL
,NULL
,NULL
,0.0100
) as [CDR Rate]
This produces the following result.
Example #8
In this example we have a 30-year loan with interest-only payments for the first 7 years and fully-amortizing payments thereafter.
SELECT wct.CDRRate(
500000
,.05
,360
,NULL
,12
,'SELECT * FROM #cpr'
,16000
,'False'
,NULL
,85
,NULL
) as [CDR Rate]
This produces the following result.
See Also