Logo

BjerksundStensland

Updated 2023-11-16 16:17:05.757000

Syntax

SELECT [westclintech].[wct].[BjerksundStensland] (
  <@CallPut, nvarchar(4000),>
 ,<@AssetPrice, float,>
 ,<@StrikePrice, float,>
 ,<@TimeToMaturity, float,>
 ,<@RiskFreeRate, float,>
 ,<@DividendRate, float,>
 ,<@Volatility, float,>
 ,<@ReturnValue, nvarchar(4000),>)

Description

Use BjerksundStensland to calculate the price or Greeks of an American-style option using the Bjerksund and Stensland 2002 option pricing formula.

Arguments

@DividendRate

the continuously compounded dividend rate over the life of the option. For currency options, @DividendRate should be the foreign risk-free interest rate. @DividendRate is an expression of type float or of a type that can be implicitly converted to float.

@ReturnValue

identifies the calculation to be performed. @ReturnValue is an expression of type nvarchar or of a type that can be implicitly converted to nvarchar. For a full description of the return values, see BjerksundStenslandPriceNGreeks. @ReturnValue is not case-sensitive. The following values are acceptable for @ReturnValue:

{"columns":[{"field":"@ReturnValue"},{"field":"Returns"}],"rows":[{"@ReturnValue":"'P' , 'PRICE'","Returns":"Price"},{"@ReturnValue":"'D' , 'DELTA'","Returns":"Delta"},{"@ReturnValue":"'G' , 'GAMMA'","Returns":"Gamma"},{"@ReturnValue":"'T' , 'THETA'","Returns":"Theta"},{"@ReturnValue":"'V' , 'VEGA'","Returns":"Vega"},{"@ReturnValue":"'R' , 'RHO'","Returns":"Rho"},{"@ReturnValue":"'L' , 'LAMBDA'","Returns":"Lambda"},{"@ReturnValue":"'DDDV' , 'VANNA' , 'DVEGADSPOT' , 'DDELTADVOL'","Returns":"DdeltaDvol"},{"@ReturnValue":"'DVV' , 'DDELTADVOLDVOL'","Returns":"DdeltaDvolDvol"},{"@ReturnValue":"'DT' , 'CHARM' , 'DDELTADTIME'","Returns":"DdeltaDtime"},{"@ReturnValue":"'GV' , 'ZOMMA' , 'DGAMMADVOL'","Returns":"DgammaDvol"},{"@ReturnValue":"'GP' , 'GAMMAP'","Returns":"GammaP"},{"@ReturnValue":"'DVDV' , 'VOMMA' , 'VOLGA' , 'DVEGADVOL'","Returns":"DvegaDvol"},{"@ReturnValue":"'VP' , 'VEGAP'","Returns":"VegaP"},{"@ReturnValue":"'PR2' , 'PHIRHO2'","Returns":"PhiRho2"},{"@ReturnValue":"'S' , 'SPEED' , 'DGAMMADSPOT'","Returns":"DgammaDspot"},{"@ReturnValue":"'DX' , 'DELTAX'","Returns":"Delta X"},{"@ReturnValue":"'RND' , 'RISKNEUTRALDENSITY'","Returns":"Risk Neutral Density"},{"@ReturnValue":"'VVV' , 'ULTIMA' , 'DVOMMADVOL'","Returns":"DvommaDvol"},{"@ReturnValue":"'VT' , 'VETA' , 'DVEGADTIME'","Returns":"DvegaDtime"},{"@ReturnValue":"'GT' , 'COLOR' , 'DGAMMADTIME'","Returns":"DgammaDtime"}]}

@RiskFreeRate

the continuously compounded risk-free rate of return over the life of the option. @RiskFreeRate 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.

@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.

@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.

@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.

@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.

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).

If @ReturnValue is NULL, then @ReturnValue is set to 'P'.

If @DividendRate is NULL then @DividendRate = 0.

If @RiskFreeRate is NULL then @RiskFreeRate = 0.

For pricing European options, use BLACKSCHOLESMERTON or BINOMIALEURO.

To use the binomial method for American options, use BINOMIALAMERICAN.

To get the implied volatility (given price), use BJERKSUNDSTENSLANDIV.

To calculate the price and all the Greeks, use BJERKSUNDSTENSLANDPRICENGREEKS.

Examples

Calculate the price for a put option on 2012-09-04, expiring on 2012-12-15, with a current asset price of 99.5, a strike price of 100 and a volatility of 20%. The risk free rate is 2% and the dividend rate is 0.5%.

SELECT ROUND(wct.BjerksundStensland('P', --PutCall
                                    99.5, --Asset Price
                                    100, --Strike Price
                                    datediff(d, '2012-09-04', '2012-12-15') / 365.0000, --Time-to-expiry
                                    .02, --Risk Free Rate
                                    .005, --Dividend Rate
                                    .20, --Volatility
                                    NULL --Return Value
             ),
             4) as Price;

This produces the following result.

{"columns":[{"field":"Price","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Price":"4.2531"}]}

To calculate the delta for the same option:

SELECT ROUND(wct.BjerksundStensland('P', --PutCall
                                    99.5, --Asset Price
                                    100, --Strike Price
                                    datediff(d, '2012-09-04', '2012-12-15') / 365.0000, --Time-to-expiry
                                    .02, --Risk Free Rate
                                    .005, --Dividend Rate
                                    .20, --Volatility
                                    'D' --Return Value
             ),
             4) as Delta;

This produces the following result.

{"columns":[{"field":"Delta","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Delta":"-0.4856"}]}

In this example we calculate the Call and Put prices for the same option with a series of different asset prices.

SELECT cast(n.S as money) as [Underlying],
       cast(wct.BjerksundStensland('C', --PutCall
                                   n.s, --Asset Price
                                   100, --Strike Price
                                   datediff(d, '2012-09-04', '2012-12-15') / 365.0000, --Time-to-expiry
                                   .02, --Risk Free Rate
                                   .005, --Dividend Rate
                                   .20, --Volatility
                                   'P' --Return Value
            ) as money) as [Call Price],
       cast(wct.BjerksundStensland('P', --PutCall
                                   n.s, --Asset Price
                                   100, --Strike Price
                                   datediff(d, '2012-09-04', '2012-12-15') / 365.0000, --Time-to-expiry
                                   .02, --Risk Free Rate
                                   .005, --Dividend Rate
                                   .20, --Volatility
                                   'P' --Return Value
            ) as money) as [Put Price]
  FROM (   SELECT 98.5
           UNION ALL
           SELECT 99.0
           UNION ALL
           SELECT 99.5
           UNION ALL
           SELECT 100
           UNION ALL
           SELECT 100.5
           UNION ALL
           SELECT 101) n(S);

This produces the following result.

{"columns":[{"field":"Underlying","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"Call Price","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"Put Price","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Underlying":"98.50","Call Price":"3.6518","Put Price":"4.7581"},{"Underlying":"99.00","Call Price":"3.8961","Put Price":"4.5007"},{"Underlying":"99.50","Call Price":"4.15","Put Price":"4.2531"},{"Underlying":"100.00","Call Price":"4.4134","Put Price":"4.0151"},{"Underlying":"100.50","Call Price":"4.6861","Put Price":"3.7866"},{"Underlying":"101.00","Call Price":"4.9681","Put Price":"3.5676"}]}

In this example we show all of the return values for an option (which can be more easily done using BjerksundStenslandPriceNGreeks.

SELECT n.rv as [Description],
       wct.BjerksundStensland('P', --PutCall
                              99.5, --Asset Price
                              100, --Strike Price
                              datediff(d, '2012-09-04', '2012-12-15') / 365.0000, --Time-to-expiry
                              .02, --Risk Free Rate
                              .005, --Dividend Rate
                              .20, --Volatility
                              n.rv --Return Value
       ) as [Value]
  FROM (   SELECT 'Price'
           UNION ALL
           SELECT 'Delta'
           UNION ALL
           SELECT 'Gamma'
           UNION ALL
           SELECT 'Theta'
           UNION ALL
           SELECT 'Vega'
           UNION ALL
           SELECT 'Rho'
           UNION ALL
           SELECT 'Lambda'
           UNION ALL
           SELECT 'DdeltaDvol'
           UNION ALL
           SELECT 'DdeltaDvolDvol'
           UNION ALL
           SELECT 'DdeltaDtime'
           UNION ALL
           SELECT 'DgammaDvol'
           UNION ALL
           SELECT 'GammaP'
           UNION ALL
           SELECT 'DvegaDvol'
           UNION ALL
           SELECT 'VegaP'
           UNION ALL
           SELECT 'PhiRho2'
           UNION ALL
           SELECT 'DgammaDspot'
           UNION ALL
           SELECT 'DeltaX'
           UNION ALL
           SELECT 'RiskNeutralDensity'
           UNION ALL
           SELECT 'DvommaDvol'
           UNION ALL
           SELECT 'DvegaDtime'
           UNION ALL
           SELECT 'DgammaDtime') n(rv);

This produces the following result.

{"columns":[{"field":"Description"},{"field":"Value","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Description":"Price","Value":"4.253097294231"},{"Description":"Delta","Value":"-0.485618954151334"},{"Description":"Gamma","Value":"0.0385703913252655"},{"Description":"Theta","Value":"-0.0186272357466564"},{"Description":"Vega","Value":"0.209275569007161"},{"Description":"Rho","Value":"-0.129024971220559"},{"Description":"Lambda","Value":"-11.3609171376349"},{"Description":"DdeltaDvol","Value":"0.00144318512695918"},{"Description":"DdeltaDvolDvol","Value":"-4.27457528928699E-05"},{"Description":"DdeltaDtime","Value":"-0.000250644436712482"},{"Description":"DgammaDvol","Value":"-0.00198143290219832"},{"Description":"GammaP","Value":"0.0383775393686392"},{"Description":"DvegaDvol","Value":"-8.10871370049426E-06"},{"Description":"VegaP","Value":"0.418551138014323"},{"Description":"PhiRho2","Value":"0.120224721192841"},{"Description":"DgammaDspot","Value":"-0.000643179731696364"},{"Description":"DeltaX","Value":"0.525721831898807"},{"Description":"RiskNeutralDensity","Value":"0.0381909615043696"},{"Description":"DvommaDvol","Value":"-6.06312403661491E-06"},{"Description":"DvegaDtime","Value":"-0.101735880237712"},{"Description":"DgammaDtime","Value":"0.000185778630226844"}]}