 # SQL Server non-recombining tree price and greeks

NonRecombiningTreePriceNGreeks

Updated: 31 Mar 2014

Use the table-valued function NonRecombiningTreePriceNGreeks to calculate the price, delta, gamma, theta, vega, rho, and lambda of American and European options paying discrete dividends using a non-recombining tree as described in Options, Futures, and Other Derivatives, 8th Edition, by John C. Hull. The NonRecombiningTree calculation creates a new binomial tree at every node where there is a dividend payment, potentially creating millions of nodes and should be used sparingly. Primarily, the NonRecombiningTree function should only be used for American Call options where the dividend is very large in relation to the price of the asset, as the recombining tree calculation for dividend-paying stocks tends to underestimate the theoretical value.
Price, delta, gamma, and theta are not calculated directly from the binomial tree. Delta, theta, vega, rho, and lambda are calculated using a first-order forward finite difference. Gamma is calculated using a second order central finite difference.
Syntax
SELECT * FROM [wctOptions].[wct].[NonRecombiningTreePriceNGreeks](
<@CallPut, nvarchar(4000),>
,<@AmEur, nvarchar(4000),>
,<@AssetPrice, float,>
,<@StrikePrice, float,>
,<@TimeToMaturity, float,>
,<@RiskFreeRate, float,>
,<@DividendRate, float,>
,<@Dividend_RangeQuery, nvarchar(max),>
,<@Volatility, float,>
,<@NumberOfSteps, int,>)
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.
@DividendRate
the annualized, continuously compounded zero-coupon dividend rate over the life of the option, used in addition to the discrete dividends. @DividendRate 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 amounts 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 dividend amount 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.
Return Type
RETURNS TABLE (
[Price] [float] NULL,
[Delta] [float] NULL,
[Gamma] [float] NULL,
[Theta] [float] NULL,
[Vega] [float] NULL,
[Rho] [float] NULL,
[Lambda] [float] NULL
)
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)
·         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.
·         If @DividendRate is NULL then @DividendRate is set to zero.
·         To improve performance, the vega calculation in NonRecombiningTreePriceNGreeks is different than the vega calculation in NonRecombiningTree.
·         To improve performance, the rho calculation in NonRecombiningTreePriceNGreeks is different than the rho calculation in NonRecombiningTree.
·         To get the implied volatility (given price), use NonRecombiningTreeIV.
·         Use the scalar function NonRecombiningTree to calculate other values, like vanna and volga.
·         To calculate the price and Greeks using proportional dividends (where the dividend is specified with a date and a percentage) use ProportionalDividends.
Example
Calculate the price and Greeks for an American call option expiring in one year with asset price of 100, a strike price of 100 and a volatility of 30%. The risk-free rate is 2.75%. A single dividend of 50 will be paid in 10 months' time. The number of steps is 100.
SELECT
*
FROM wct.NonRecombiningTreePriceNGreeks(
'C'        --Put/Call
,'A'        --American/European
,100        --Asset Price
,100        --Strike Price
,1          --Time-to-maturity
,.0275      --Risk-free rate
,NULL       --Dividend rate
,'SELECT 0.83333333333, 50'   --Discrete Dividends
,0.30       --Volatility
,100        --Number of Steps
)
This produces the following result.

 Price Delta Gamma Theta Vega Rho Lambda 11.94435 0.587388 -0.0000018 -0.01756 0.355796 0.388068 4.917707

### Support  Copyright 2008-2023 Westclintech LLC         Privacy Policy        Terms of Service