ProportionalDividends
Updated: 15 Dec 2013
Use ProportionalDividends to calculate the price and Greeks of an American or European option paying proportional dividends using a Cox Ross Rubinstein Binomial as described in The Complete Guide to Option Pricing Formulas, Second Edition, by Espen Gaarder Haug, PhD.
Syntax
SELECT [wctOptions].[wct].[ProportionalDividends](
<@CallPut, nvarchar(4000),>
,<@AmEur, nvarchar(4000),>
,<@AssetPrice, float,>
,<@StrikePrice, float,>
,<@TimeToMaturity, float,>
,<@RiskFreeRate, float,>
,<@Dividend_RangeQuery, nvarchar(max),>
,<@Volatility, float,>
,<@NumberOfSteps, int,>
,<@RV, nvarchar(4000),>)
Arguments
@CallPut
identifies the option as being a call ('C') or a put ('P'). @CallPut is an expression of type nvarchar or of a type that can be implicitly converted to nvarchar.
@AmEur
identifies the option as being American ('A') or European ('E'). @AmEur is an expression of type nvarchar or of a type that can be implicitly converted to nvarchar.
@AssetPrice
the price of the underlying asset. @AssetPrice is an expression of type float or of a type that can be implicitly converted to float.
@StrikePrice
the exercise price of the option. @StrikePrice is an expression of type float or of a type that can be implicitly converted to float.
@TimeToMaturity
the time to expiration of the option, expressed in years. @TimeToMaturity is an expression of type float or of a type that can be implicitly converted to float.
@RiskFreeRate
the annualized, continuously compounded zero-coupon risk-free rate over the life of the option. @RiskFreeRate is an expression of type float or of a type that can be implicitly converted to float.
@Dividend_RangeQuery
a string containing an SQL statement which, when executed, provides the function with the times and proportions of the dividends to be used in the calculation. The results of the SQL must contain exactly two columns, the first being the time value, as a float or as a value that implicitly converts to float, and the second being the proportion as float, or as a value that implicitly converts to float. @Dividend_RangeQuery is an expression of type nvarchar or of a type that can be implicitly converted to nvarchar.
@Volatility
the volatility of the relative price change of the underlying asset. @Volatility is an expression of type float or of a type that can be implicitly converted to float.
@NumberOfSteps
the number of steps in the binomial tree. @NumberOfSteps is an expression of type int or of a type that can be implicitly converted to int.
@RV
identifies the calculation to be performed. @RV is an expression of type nvarchar or of a type that can be implicitly converted to nvarchar. @RV is not case-sensitive. The following values are acceptable for @RV.
@RV
|
Returns
|
'P','PRICE'
|
Price
|
'D','DELTA'
|
Delta
|
'G','GAMMA'
|
Gamma
|
'T','THETA'
|
Theta
|
'V','VEGA'
|
Vega
|
'R','RHO'
|
Rho
|
'L','LAMBDA'
|
Lambda
|
'DDDV','VANNA','DVEGADSPOT','DDELTADVOL'
|
DdeltaDvol
|
'DVV','DDELTADVOLDVOL'
|
DdeltaDvolDvol
|
'DT','CHARM','DDELTADTIME'
|
DdeltaDtime
|
'GV','ZOMMA','DGAMMADVOL'
|
DgammaDvol
|
'GP','GAMMAP'
|
GammaP
|
'DVDV','VOMMA','VOLGA','DVEGADVOL'
|
DvegaDvol
|
'VP','VEGAP'
|
VegaP
|
'S','SPEED','DGAMMADSPOT'
|
DgammaDspot
|
'DX','DELTAX'
|
Delta X
|
'RND','RISKNEUTRALDENSITY'
|
Risk Neutral Density
|
'VVV','ULTIMA','DVOMMADVOL'
|
DvommaDvol
|
'VT','VETA','DVEGADTIME'
|
DvegaDtime
|
'GT','COLOR','DGAMMADTIME'
|
DgammaDtime
|
Return Type
float
Remarks
· @Volatility must be greater than zero (@Volatility > 0).
· @TimeToMaturity must be greater than zero (@TimeToMaturity > 0).
· @AssetPrice must be greater than zero (@AssetPrice > 0).
· @StrikePrice must be greater than zero (@StrikePrice > 0).
· @NumberOfSteps must be greater than 1 (@NumberOfSteps > 1)
· If @RV is NULL, then @RV is set to 'P'.
· Negative time values returned by @Dividend_RangeQuery are ignored.
· Time values returned by @Dividend_RangeQuery that are greater than @TimeToMaturity are ignored.
· If @RiskFreeRate is NULL then @RiskFreeRate is set to zero.
· Use the table-valued function ProportionalDividendsTree to see the underlying price, intrinsic value, and option value for each node on the binomial tree.
· Use the table-valued function ProportionalDividendsPriceNGreeks to calculate the price, delta, gamma, theta, vega, rho, and lambda in a single SELECT statement faster than calculating them individually in ProportionalDividends.
· To calculate the price and Greeks using discrete dividends (where the dividend is specified with a date and a percentage) use BinomialDiscreteDividends.
Example
Calculate the price for an American call option expiring in one year with asset price of 478, a strike price of 500 and a volatility of 30%. The risk-free rate is 2.75%. Dividends will be paid quarterly in the following proportions.
T
|
Div
|
0.25
|
.010
|
0.50
|
.011
|
0.75
|
.012
|
1.00
|
.013
|
The number of steps is 100.
SELECT wct.ProportionalDividends(
'C' --Put/Call
,'A' --American/European
,478 --Asset Price
,500 --Strike Price
,1 --Time-to-maturity
,.0275 --Risk-free rate
,'SELECT *
FROM (VALUES
(0.25,0.010),
(0.50,0.011),
(0.75,0.012),
(1.00,0.013)
)n(T,D)' --Proportional Dividends
,0.30 --Volatility
,100 --Number of Steps
,'P' --Return Value
) as [Price]
This produces the following result.
Price
----------------------
43.17175949561
To calculate the delta for the same option:
SELECT wct.ProportionalDividends(
'C' --Put/Call
,'A' --American/European
,478 --Asset Price
,500 --Strike Price
,1 --Time-to-maturity
,.0275 --Risk-free rate
,'SELECT *
FROM (VALUES
(0.25,0.010),
(0.50,0.011),
(0.75,0.012),
(1.00,0.013)
)n(T,D)' --Proportional Dividends
,0.30 --Volatility
,100 --Number of Steps
,'D' --Return Value
) as [Delta]
This produces the following result.
Delta
----------------------
0.46362277506691
In this example, using the same data, we calculate the price for all the combinations of @AmEur and @CallPut.
SELECT n.z
,m.AE
,wct.ProportionalDividends(
n.z --Put/Call
,m.AE --American/European
,478 --Asset Price
,500 --Strike Price
,1 --Time-to-maturity
,.0275 --Risk-free rate
,'SELECT *
FROM (VALUES
(0.25,0.010),
(0.50,0.011),
(0.75,0.012),
(1.00,0.013)
)n(T,D)' --Proportional Dividends
,0.30 --Volatility
,100 --Number of Steps
,'P' --Return Value
) as [Price]
FROM (VALUES ('P'),('C'))n(z)
CROSS APPLY(VALUES ('A'),('E'))m(AE)
This produces the following result.
z AE Price
---- ---- ----------------------
P A 73.830901064052
P E 72.6163355317298
C A 43.17175949561
C E 42.566220029483
In this example we look at how to use dates in the function, using the YEARFRAC and CALCDATE functions from XLeratorDB/financial. We will use the GETDATE() function as the start date for the calculations. The option expires on November 27th, 2014 with dividends payable on February 6th, May 6th, August 6th, and November 6th, 2014.
SELECT wct.ProportionalDividends(
'C'
,'A'
,478
,500
,wct.YEARFRAC(GETDATE(),'2014-11-27',NULL)
,.0275
,'SELECT *
FROM (VALUES
(wct.YEARFRAC(GETDATE(),wct.CALCDATE(2014,2,6),NULL),0.010),
(wct.YEARFRAC(GETDATE(),wct.CALCDATE(2014,5,6),NULL),0.011),
(wct.YEARFRAC(GETDATE(),wct.CALCDATE(2014,8,6),NULL),0.012),
(wct.YEARFRAC(GETDATE(),wct.CALCDATE(2014,11,6),NULL),0.013)
)n(T,D)'
,0.30
,100
,'P'
) as [Price]
This produces the following result on 2013-12-11. You results will be different.
Price
----------------------
43.5863644912707
In this example, we use @date_start as a datetime variable to establish the starting point for calculating the time-to-expiry and @date_start_string as a string variable to be used in @Dividend_RangeQuery.
DECLARE @date_start as datetime = cast('2013-12-11' as datetime)
DECLARE @date_start_string as varchar(max) = '''' + convert(varchar,@date_start,112) + ''''
SELECT wct.ProportionalDividends(
'C'
,'A'
,478
,500
,wct.YEARFRAC(@date_start,'2014-11-27',NULL)
,.0275
,'SELECT *
FROM (VALUES
(wct.YEARFRAC(' + @date_start_string + ',wct.CALCDATE(2014,2,6),NULL),0.010),
(wct.YEARFRAC(' + @date_start_string + ',wct.CALCDATE(2014,5,6),NULL),0.011),
(wct.YEARFRAC(' + @date_start_string + ',wct.CALCDATE(2014,8,6),NULL),0.012),
(wct.YEARFRAC(' + @date_start_string + ',wct.CALCDATE(2014,11,6),NULL),0.013)
)n(T,D)'
,0.30
,100
,'P'
) as [Price]
This produces the follwing result.
Price
----------------------
43.5863644912707
In this example we put some equity options trades into a table, with a separate table containing the closing price and volatilities for each ticker and a third table containing the dividend information. This example shows one way to combine the information from multiples tables to calculate the theoretical value of the option. This example holds the risk-free rate constant, which you wouldn't want to do in practice and we will add a discount factor table and calculate the interpolated risk-free rate in another example.
/*Put dividend information into a table*/
SELECT *
INTO #div
FROM (VALUES
('ABC','2013-12-15',0.010)
,('ABC','2014-03-15',0.0105)
,('ABC','2014-06-15',0.0110)
,('ABC','2014-09-15',0.0115)
,('ABC','2014-12-15',0.0120)
,('DEF','2014-01-17',.005)
,('DEF','2014-04-17',.005)
,('DEF','2014-07-17',.005)
,('DEF','2014-10-17',.005)
,('DEF','2015-01-17',.005)
,('GHI','2014-02-17',.020)
,('GHI','2014-05-17',.021)
,('GHI','2014-08-17',.022)
,('GHI','2014-11-17',.023)
,('GHI','2015-02-17',.030)
)d(ticker,date_div,amt_div)
/*Put price information into a table*/
SELECT *
INTO #prices
FROM (VALUES
('ABC',495,0.35)
,('DEF',125,0.3)
,('GHI',62.5,0.25)
)p(ticker,price,vol)
/*put the options into a table*/
SELECT *
INTO #options
FROM (VALUES
(1,'ABC','2014-08-09',470,'C')
,(2,'ABC','2014-08-20',480,'P')
,(3,'ABC','2014-11-10',490,'P')
,(4,'ABC','2014-09-14',500,'C')
,(5,'DEF','2014-11-14',100,'C')
,(6,'DEF','2014-12-12',110,'C')
,(7,'DEF','2014-08-11',120,'P')
,(8,'DEF','2014-08-26',130,'C')
,(9,'GHI','2014-08-04',50,'C')
,(10,'GHI','2014-12-28',55,'C')
,(11,'GHI','2014-10-09',60,'P')
,(12,'GHI','2014-11-14',65,'C')
)o(rn,ticker,expiry,strike,z)
/*Establish the start date for calculation purposes*/
DECLARE @date_start as datetime = cast('2013-12-11' as datetime)
DECLARE @date_start_string as varchar(max) = '''' + convert(varchar,@date_start,112) + ''''
SELECT A.rn
,A.ticker
,A.z
,B.price
,A.strike
,A.expiry
,B.vol
,wct.ProportionalDividends(
A.z
,'A'
,B.price
,A.strike
,wct.YEARFRAC(@date_start,A.expiry,NULL)
,.0275
,'SELECT wct.YEARFRAC(' + @date_start_string + ',date_div,NULL),amt_div FROM #div WHERE ticker = ' + '''' + CAST(A.ticker as varchar(max)) + ''''
,B.vol
,100
,'P'
) as [Price]
FROM #options A
INNER JOIN #prices B
ON A.ticker = B.ticker
DROP TABLE #div
DROP TABLE #prices
DROP TABLE #options
This produces the following result, which has been reformatted for presentation purposes.
rn
|
ticker
|
z
|
price
|
strike
|
expiry
|
vol
|
Price
|
1
|
ABC
|
C
|
495
|
470
|
2014-08-09
|
0.35
|
64.089663
|
2
|
ABC
|
P
|
495
|
480
|
2014-08-20
|
0.35
|
51.288938
|
3
|
ABC
|
P
|
495
|
490
|
2014-11-10
|
0.35
|
65.975565
|
4
|
ABC
|
C
|
495
|
500
|
2014-09-14
|
0.35
|
54.292303
|
5
|
DEF
|
C
|
125
|
100
|
2014-11-14
|
0.30
|
29.187223
|
6
|
DEF
|
C
|
125
|
110
|
2014-12-12
|
0.30
|
22.939473
|
7
|
DEF
|
P
|
125
|
120
|
2014-08-11
|
0.30
|
9.380680
|
8
|
DEF
|
C
|
125
|
130
|
2014-08-26
|
0.30
|
10.579891
|
9
|
GHI
|
C
|
62.5
|
50
|
2014-08-04
|
0.25
|
12.996435
|
10
|
GHI
|
C
|
62.5
|
55
|
2014-12-28
|
0.25
|
9.283642
|
11
|
GHI
|
P
|
62.5
|
60
|
2014-10-09
|
0.25
|
5.399335
|
12
|
GHI
|
C
|
62.5
|
65
|
2014-11-14
|
0.25
|
4.018742
|
For large volumes of data having many options for a single ticker, it will be more efficient to calculate the time values of the dividends outside of the ProportionalDividends function and simply use the pre-calculated values in @Dividend_RangeQuery.
/*Put dividend information into a table*/
SELECT *
INTO #div
FROM (VALUES
('ABC','2013-12-15',0.010)
,('ABC','2014-03-15',0.0105)
,('ABC','2014-06-15',0.0110)
,('ABC','2014-09-15',0.0115)
,('ABC','2014-12-15',0.0120)
,('DEF','2014-01-17',.005)
,('DEF','2014-04-17',.005)
,('DEF','2014-07-17',.005)
,('DEF','2014-10-17',.005)
,('DEF','2015-01-17',.005)
,('GHI','2014-02-17',.020)
,('GHI','2014-05-17',.021)
,('GHI','2014-08-17',.022)
,('GHI','2014-11-17',.023)
,('GHI','2015-02-17',.030)
)d(ticker,date_div,amt_div)
/*Put price information into a table*/
SELECT *
INTO #prices
FROM (VALUES
('ABC',495,0.35)
,('DEF',125,0.3)
,('GHI',62.5,0.25)
)p(ticker,price,vol)
/*put the options into a table*/
SELECT *
INTO #options
FROM (VALUES
(1,'ABC','2014-08-09',470,'C')
,(2,'ABC','2014-08-20',480,'P')
,(3,'ABC','2014-11-10',490,'P')
,(4,'ABC','2014-09-14',500,'C')
,(5,'DEF','2014-11-14',100,'C')
,(6,'DEF','2014-12-12',110,'C')
,(7,'DEF','2014-08-11',120,'P')
,(8,'DEF','2014-08-26',130,'C')
,(9,'GHI','2014-08-04',50,'C')
,(10,'GHI','2014-12-28',55,'C')
,(11,'GHI','2014-10-09',60,'P')
,(12,'GHI','2014-11-14',65,'C')
)o(rn,ticker,expiry,strike,z)
/*Establish the start date for calculation purposes*/
DECLARE @date_start as datetime = cast('2013-12-11' as datetime)
/*Put the #div values into another table with date converted to a
fraction of a year*/
SELECT ticker
,wct.YEARFRAC(@date_start,date_div,NULL) as T
,amt_div as D
INTO #tdiv
FROM #div
SELECT A.rn
,A.ticker
,A.z
,B.price
,A.strike
,A.expiry
,B.vol
,wct.ProportionalDividends(
A.z
,'A'
,B.price
,A.strike
,wct.YEARFRAC(@date_start,A.expiry,NULL)
,.0275
,'SELECT T,D FROM #tdiv WHERE ticker = ' + '''' + CAST(A.ticker as varchar(max)) + ''''
,B.vol
,100
,'P'
) as [Price]
FROM #options A
INNER JOIN #prices B
ON A.ticker = B.ticker
DROP TABLE #div
DROP TABLE #prices
DROP TABLE #options
DROP TABLE #tdiv
This produces the following result, which has been reformatted for presentation purposes.
rn
|
ticker
|
z
|
price
|
strike
|
expiry
|
vol
|
Price
|
1
|
ABC
|
C
|
495
|
470
|
2014-08-09
|
0.35
|
64.089663
|
2
|
ABC
|
P
|
495
|
480
|
2014-08-20
|
0.35
|
51.288938
|
3
|
ABC
|
P
|
495
|
490
|
2014-11-10
|
0.35
|
65.975565
|
4
|
ABC
|
C
|
495
|
500
|
2014-09-14
|
0.35
|
54.292303
|
5
|
DEF
|
C
|
125
|
100
|
2014-11-14
|
0.30
|
29.187223
|
6
|
DEF
|
C
|
125
|
110
|
2014-12-12
|
0.30
|
22.939473
|
7
|
DEF
|
P
|
125
|
120
|
2014-08-11
|
0.30
|
9.380680
|
8
|
DEF
|
C
|
125
|
130
|
2014-08-26
|
0.30
|
10.579891
|
9
|
GHI
|
C
|
62.5
|
50
|
2014-08-04
|
0.25
|
12.996435
|
10
|
GHI
|
C
|
62.5
|
55
|
2014-12-28
|
0.25
|
9.283642
|
11
|
GHI
|
P
|
62.5
|
60
|
2014-10-09
|
0.25
|
5.399335
|
12
|
GHI
|
C
|
62.5
|
65
|
2014-11-14
|
0.25
|
4.018742
|
In this example, we will use the same inputs as above, with the exception that we will have a table of discount factors and use the DFINTERP function to convert the discount factors into risk-free rates to be used in the function.
/*Put dividend information into a table*/
SELECT *
INTO #div
FROM (VALUES
('ABC','2013-12-15',0.010)
,('ABC','2014-03-15',0.0105)
,('ABC','2014-06-15',0.0110)
,('ABC','2014-09-15',0.0115)
,('ABC','2014-12-15',0.0120)
,('DEF','2014-01-17',.005)
,('DEF','2014-04-17',.005)
,('DEF','2014-07-17',.005)
,('DEF','2014-10-17',.005)
,('DEF','2015-01-17',.005)
,('GHI','2014-02-17',.020)
,('GHI','2014-05-17',.021)
,('GHI','2014-08-17',.022)
,('GHI','2014-11-17',.023)
,('GHI','2015-02-17',.030)
)d(ticker,date_div,amt_div)
/*Put price information into a table*/
SELECT *
INTO #prices
FROM (VALUES
('ABC',495,0.35)
,('DEF',125,0.3)
,('GHI',62.5,0.25)
)p(ticker,price,vol)
/*put the options into a table*/
SELECT *
INTO #options
FROM (VALUES
(1,'ABC','2014-08-09',470,'C')
,(2,'ABC','2014-08-20',480,'P')
,(3,'ABC','2014-11-10',490,'P')
,(4,'ABC','2014-09-14',500,'C')
,(5,'DEF','2014-11-14',100,'C')
,(6,'DEF','2014-12-12',110,'C')
,(7,'DEF','2014-08-11',120,'P')
,(8,'DEF','2014-08-26',130,'C')
,(9,'GHI','2014-08-04',50,'C')
,(10,'GHI','2014-12-28',55,'C')
,(11,'GHI','2014-10-09',60,'P')
,(12,'GHI','2014-11-14',65,'C')
)o(rn,ticker,expiry,strike,z)
/*Establish the start date for calculation purposes*/
DECLARE @date_start as datetime = cast('2013-12-11' as datetime)
/*Put the #div values into another table with date converted to a
fraction of a year*/
SELECT ticker
,wct.YEARFRAC(@date_start,date_div,NULL) as T
,amt_div as D
INTO #tdiv
FROM #div
/*Put the discount factors into a table*/
SELECT wct.TENOR2DATE(tenor,@date_start,NULL,'') as date_df
,df
INTO #df
FROM (
SELECT 'ON',0.999995555575309 UNION ALL
SELECT 'TN',0.999991111170370 UNION ALL
SELECT '1W',0.999956112706425 UNION ALL
SELECT '2W',0.999916450742048 UNION ALL
SELECT '1M',0.999804481000583 UNION ALL
SELECT '2M',0.999574621744643 UNION ALL
SELECT '3M',0.999241679910437 UNION ALL
SELECT '6M',0.998800609148515 UNION ALL
SELECT '9M',0.998022836090921 UNION ALL
SELECT '1Y',0.997197057207847 UNION ALL
SELECT '2Y',0.996311568695976
)n(tenor, df)
/*Calculate the risk-free rate for each expiry date in the portfolio*/
SELECT expiry
,wct.DFINTERP(date_df,df,expiry,@date_start,'CC') as Rf
INTO #rates
FROM #df, #options
GROUP BY expiry
SELECT A.rn
,A.ticker
,A.z
,B.price
,A.strike
,A.expiry
,C.rf
,B.vol
,wct.ProportionalDividends(
A.z
,'A'
,B.price
,A.strike
,wct.YEARFRAC(@date_start,A.expiry,NULL)
,C.rf
,'SELECT T,D FROM #tdiv WHERE ticker = ' + '''' + CAST(A.ticker as varchar(max)) + ''''
,B.vol
,100
,'P'
) as [Price]
FROM #options A
INNER JOIN #prices B
ON A.ticker = B.ticker
INNER JOIN #rates C
ON A.expiry = C.expiry
DROP TABLE #div
DROP TABLE #prices
DROP TABLE #options
DROP TABLE #tdiv
DROP TABLE #df
DROP TABLE #rates
This produces the following result, which has been reformatted for presentation purposes.
rn
|
ticker
|
z
|
price
|
strike
|
expiry
|
rf
|
vol
|
Price
|
1
|
ABC
|
C
|
495
|
470
|
2014-08-09
|
0.00251483
|
0.35
|
60.98402331
|
2
|
ABC
|
P
|
495
|
480
|
2014-08-20
|
0.00254046
|
0.35
|
55.19047621
|
3
|
ABC
|
P
|
495
|
490
|
2014-11-10
|
0.00271136
|
0.35
|
71.81097616
|
4
|
ABC
|
C
|
495
|
500
|
2014-09-14
|
0.00259873
|
0.35
|
50.98568722
|
5
|
DEF
|
C
|
125
|
100
|
2014-11-14
|
0.00271924
|
0.3
|
27.94437144
|
6
|
DEF
|
C
|
125
|
110
|
2014-12-12
|
0.00277444
|
0.3
|
21.59635974
|
7
|
DEF
|
P
|
125
|
120
|
2014-08-11
|
0.00251949
|
0.3
|
10.28083839
|
8
|
DEF
|
C
|
125
|
130
|
2014-08-26
|
0.00255444
|
0.3
|
9.787481585
|
9
|
GHI
|
C
|
62.5
|
50
|
2014-08-04
|
0.00250318
|
0.25
|
12.73820961
|
10
|
GHI
|
C
|
62.5
|
55
|
2014-12-28
|
0.00274695
|
0.25
|
8.859717569
|
11
|
GHI
|
P
|
62.5
|
60
|
2014-10-09
|
0.00264832
|
0.25
|
6.019310343
|
12
|
GHI
|
C
|
62.5
|
65
|
2014-11-14
|
0.00271924
|
0.25
|
3.639135053
|