StandardBarrier
Updated 2023-11-14 21:22:16.187000
Syntax
SELECT [westclintech].[wct].[StandardBarrier](
<@CallPut, nvarchar(4000),>
,<@BarrierType, nvarchar(4000),>
,<@AssetPrice, float,>
,<@StrikePrice, float,>
,<@BarrierPrice, float,>
,<@Rebate, float,>
,<@TimeToMaturity, float,>
,<@RiskFreeRate, float,>
,<@DividendRate, float,>
,<@Volatility, float,>
,<@ReturnValue, nvarchar(4000),>)
Description
Use StandardBarrier to calculate the price or Greeks of a European-style Knock-In or Knock-Out option. StandardBarrier valuations are based on the formulae published by Mark Rubinstein and Eric Reiner in 1991.
Arguments
@BarrierType
identifies the type of barrier as 'UI' (Up-and-In), 'UO' (Up-and-Out), 'DI' (Down-and-In), or 'DO' (Down-and-out). @BarrierType must be of a type nvarchar or of a type that implicitly converts to nvarchar.
@DividendRate
the continuously compounded zero coupon dividend rate over the life of the option. For currency options @DividendRate should be the foreign risk-free zero coupon 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 STANDARDBARRIERPRICENGREEKS STANDARDBARRIERPRICENGREEKS. @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": "'GX','GAMMAX','DX','RND','RISKNEUTRALDENSITY'",
"Returns": "Risk Neutral Density"
},
{
"@ReturnValue": "'VVV','ULTIMA','DVOMMADVOL'",
"Returns": "DvommaDvol"
},
{
"@ReturnValue": "'VT','VETA','DVEGADTIME'",
"Returns": "DvegaDtime"
},
{
"@ReturnValue": "'GT','COLOR','DGAMMADTIME'",
"Returns": "DgammaDtime"
},
{
"@ReturnValue": "'FR','RHOFUTURESOPTIONS','FUTURESOPTIONSRHO'",
"Returns": "Futures Options Rho"
},
{
"@ReturnValue": "'B','CARRYSENSITIVITY'",
"Returns": "Carry Sensitivity"
}
]
}
@RiskFreeRate
the 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.
@BarrierPrice
For a knock-in option, @BarrierPrice is the value at which the option comes into existence if the @AssetPrice crosses the barrier. For a knock-out option, @BarrierPrice is the value at which the option is extinguished if the @AssetPrice crosses the barrier. @BarrierPrice must be of a type float or of a type that implicitly converts 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.
@Rebate
An amount paid to the buyer of the option in the event that the barrier is never breached. @Rebate must be of a type float or of a type that implicitly converts 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 @RiskFreeRate = 0.
@BarrierPrice must be greater than zero (@BarrierPrice > 0).
@Rebate must be greater than or equal to zero (@Rebate >= 0).
If @Rebate is NULL, then @Rebate = 0.
@BarrierPrice assumes continuous monitoring.
To convert a non-continuous @BarrierPrice use the ADJUSTEDBARRIER function.
To calculate the price and all the Greeks use STANDARDBARRIERPRICENGREEKS.
Examples
A down-and-in call.
SELECT cast(wct.StandardBarrier( 'C', --PutCall
'DI', --BarrierType
100, --Asset Price
90, --Strike Price
97, --Barrier
2, --Rebate
0.5, --Time-to-expiry
.10, --Risk Free Rate
.05, --Dividend Rate
.20, --Volatility
'P' --Return Value
) as money) as Price;
This produces the following result.
{"columns":[{"field":"Price","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Price":"8.5951"}]}
This SELECT statement reproduces the table for a down-and-in call included in the original paper on Barrier Options by Rubinstein and Reiner, though the numerical values are different.
SELECT *
FROM
(
SELECT n.t,
n3.Barrier,
n2.Strike,
cast(wct.StandardBarrier( 'C', --PutCall
'DI', --BarrierType
100, --Asset Price
n2.Strike, --Strike Price
n3.Barrier, --Barrier
2, --Rebate
n.t, --Time-to-expiry
.10, --Risk Free Rate
.05, --Dividend Rate
.20, --Volatility
'P' --Return Value
) as money) as Price
FROM
(
VALUES
(0.5),
(0.75),
(1.00),
(1.25),
(1.50)
) n (t)
CROSS APPLY
(
VALUES
(90),
(100),
(110)
) n2 (Strike)
CROSS APPLY
(
VALUES
(97),
(100),
(103)
) n3 (Barrier)
) D
PIVOT
(
SUM(Price)
for t in ([0.5], [0.75], [1.00], [1.25], [1.50])
) as P
ORDER BY 1,
2;
This produces the following result.
{"columns":[{"field":"Barrier","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"Strike","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.5","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.75","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"1.00","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"1.25","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"1.50","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Barrier":"97","Strike":"90","0.5":"8.5951","0.75":"10.0461","1.00":"11.3066","1.25":"12.4324","1.50":"13.4536"},{"Barrier":"97","Strike":"100","0.5":"3.9519","0.75":"5.3719","1.00":"6.646","1.25":"7.807","1.50":"8.8761"},{"Barrier":"97","Strike":"110","0.5":"1.6224","0.75":"2.622","1.00":"3.6449","1.25":"4.6461","1.50":"5.6113"},{"Barrier":"100","Strike":"90","0.5":"13.1652","0.75":"14.6055","1.00":"15.885","1.25":"17.0379","1.50":"18.0873"},{"Barrier":"100","Strike":"100","0.5":"6.7186","0.75":"8.4494","1.00":"9.9409","1.25":"11.2685","1.50":"12.4716"},{"Barrier":"100","Strike":"110","0.5":"2.8347","0.75":"4.3556","1.00":"5.7455","1.25":"7.0265","1.50":"8.2156"},{"Barrier":"103","Strike":"90","0.5":"13.1652","0.75":"14.6055","1.00":"15.885","1.25":"17.0379","1.50":"18.0873"},{"Barrier":"103","Strike":"100","0.5":"6.7186","0.75":"8.4494","1.00":"9.9409","1.25":"11.2685","1.50":"12.4716"},{"Barrier":"103","Strike":"110","0.5":"2.8347","0.75":"4.3556","1.00":"5.7455","1.25":"7.0265","1.50":"8.2156"}]}
We can reproduce the table in its entirety with the following SQL.
SELECT *
FROM
(
SELECT n.t,
n5.Z,
n4.BarrierType,
n3.Barrier,
n2.Strike,
cast(wct.StandardBarrier(n5.Z, n4.BarrierType, 100, n2.Strike, n3.Barrier,
2, n.t, .10, .05, .20, 'P') as money) as Price
FROM
(
VALUES
(0.5),
(0.75),
(1.00),
(1.25),
(1.50)
) n (t)
CROSS APPLY
(
VALUES
(90),
(100),
(110)
) n2 (Strike)
CROSS APPLY
(
VALUES
(97),
(100),
(103)
) n3 (Barrier)
CROSS APPLY
(
VALUES
('UI'),
('DI'),
('UO'),
('DO')
) n4 (BarrierType)
CROSS APPLY
(
VALUES
('C'),
('P')
) n5 (Z)
) D
PIVOT
(
SUM(Price)
for t in ([0.5], [0.75], [1.00], [1.25], [1.50])
) as P
ORDER BY 1,
2;
Here are the results of this query.
{"columns":[{"field":"Z"},{"field":"BarrierType"},{"field":"Barrier","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"Strike","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.5","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.75","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"1.00","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"1.25","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"1.50","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Z":"C","BarrierType":"DI","Barrier":"97","Strike":"90","0.5":"8.5951","0.75":"10.0461","1.00":"11.3066","1.25":"12.4324","1.50":"13.4536"},{"Z":"C","BarrierType":"DI","Barrier":"97","Strike":"100","0.5":"3.9519","0.75":"5.3719","1.00":"6.646","1.25":"7.807","1.50":"8.8761"},{"Z":"C","BarrierType":"DI","Barrier":"97","Strike":"110","0.5":"1.6224","0.75":"2.622","1.00":"3.6449","1.25":"4.6461","1.50":"5.6113"},{"Z":"C","BarrierType":"DI","Barrier":"100","Strike":"90","0.5":"13.1652","0.75":"14.6055","1.00":"15.885","1.25":"17.0379","1.50":"18.0873"},{"Z":"C","BarrierType":"DI","Barrier":"100","Strike":"100","0.5":"6.7186","0.75":"8.4494","1.00":"9.9409","1.25":"11.2685","1.50":"12.4716"},{"Z":"C","BarrierType":"DI","Barrier":"100","Strike":"110","0.5":"2.8347","0.75":"4.3556","1.00":"5.7455","1.25":"7.0265","1.50":"8.2156"},{"Z":"C","BarrierType":"DI","Barrier":"103","Strike":"90","0.5":"13.1652","0.75":"14.6055","1.00":"15.885","1.25":"17.0379","1.50":"18.0873"},{"Z":"C","BarrierType":"DI","Barrier":"103","Strike":"100","0.5":"6.7186","0.75":"8.4494","1.00":"9.9409","1.25":"11.2685","1.50":"12.4716"},{"Z":"C","BarrierType":"DI","Barrier":"103","Strike":"110","0.5":"2.8347","0.75":"4.3556","1.00":"5.7455","1.25":"7.0265","1.50":"8.2156"},{"Z":"C","BarrierType":"DO","Barrier":"97","Strike":"90","0.5":"6.5391","0.75":"6.5202","1.00":"6.5324","1.25":"6.5534","1.50":"6.5761"},{"Z":"C","BarrierType":"DO","Barrier":"97","Strike":"100","0.5":"4.7357","0.75":"5.0383","1.00":"5.2488","1.25":"5.4093","1.50":"5.5379"},{"Z":"C","BarrierType":"DO","Barrier":"97","Strike":"110","0.5":"3.1813","0.75":"3.6944","1.00":"4.0545","1.25":"4.3283","1.50":"4.5467"},{"Z":"C","BarrierType":"DO","Barrier":"100","Strike":"90","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"DO","Barrier":"100","Strike":"100","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"DO","Barrier":"100","Strike":"110","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"DO","Barrier":"103","Strike":"90","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"DO","Barrier":"103","Strike":"100","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"DO","Barrier":"103","Strike":"110","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"UI","Barrier":"97","Strike":"90","0.5":"13.1652","0.75":"14.6055","1.00":"15.885","1.25":"17.0379","1.50":"18.0873"},{"Z":"C","BarrierType":"UI","Barrier":"97","Strike":"100","0.5":"6.7186","0.75":"8.4494","1.00":"9.9409","1.25":"11.2685","1.50":"12.4716"},{"Z":"C","BarrierType":"UI","Barrier":"97","Strike":"110","0.5":"2.8347","0.75":"4.3556","1.00":"5.7455","1.25":"7.0265","1.50":"8.2156"},{"Z":"C","BarrierType":"UI","Barrier":"100","Strike":"90","0.5":"13.1652","0.75":"14.6055","1.00":"15.885","1.25":"17.0379","1.50":"18.0873"},{"Z":"C","BarrierType":"UI","Barrier":"100","Strike":"100","0.5":"6.7186","0.75":"8.4494","1.00":"9.9409","1.25":"11.2685","1.50":"12.4716"},{"Z":"C","BarrierType":"UI","Barrier":"100","Strike":"110","0.5":"2.8347","0.75":"4.3556","1.00":"5.7455","1.25":"7.0265","1.50":"8.2156"},{"Z":"C","BarrierType":"UI","Barrier":"103","Strike":"90","0.5":"13.1937","0.75":"14.6826","1.00":"15.9732","1.25":"17.1263","1.50":"18.1724"},{"Z":"C","BarrierType":"UI","Barrier":"103","Strike":"100","0.5":"6.9961","0.75":"8.6648","1.00":"10.1186","1.25":"11.4202","1.50":"12.6039"},{"Z":"C","BarrierType":"UI","Barrier":"103","Strike":"110","0.5":"3.1155","0.75":"4.5728","1.00":"5.9244","1.25":"7.1789","1.50":"8.3485"},{"Z":"C","BarrierType":"UO","Barrier":"97","Strike":"90","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"UO","Barrier":"97","Strike":"100","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"UO","Barrier":"97","Strike":"110","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"UO","Barrier":"100","Strike":"90","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"UO","Barrier":"100","Strike":"100","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"UO","Barrier":"100","Strike":"110","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"C","BarrierType":"UO","Barrier":"103","Strike":"90","0.5":"1.9443","0.75":"1.8895","1.00":"1.8736","1.25":"1.8692","1.50":"1.869"},{"Z":"C","BarrierType":"UO","Barrier":"103","Strike":"100","0.5":"1.6954","0.75":"1.7512","1.00":"1.784","1.25":"1.806","1.50":"1.8218"},{"Z":"C","BarrierType":"UO","Barrier":"103","Strike":"110","0.5":"1.692","0.75":"1.7494","1.00":"1.7829","1.25":"1.8052","1.50":"1.8212"},{"Z":"P","BarrierType":"DI","Barrier":"97","Strike":"90","0.5":"1.6063","0.75":"2.0797","1.00":"2.4544","1.25":"2.7503","1.50":"2.9845"},{"Z":"P","BarrierType":"DI","Barrier":"97","Strike":"100","0.5":"4.6684","0.75":"5.1991","1.00":"5.5574","1.25":"5.805","1.50":"5.9752"},{"Z":"P","BarrierType":"DI","Barrier":"97","Strike":"110","0.5":"10.0441","0.75":"10.2427","1.00":"10.3199","1.25":"10.3241","1.50":"10.2785"},{"Z":"P","BarrierType":"DI","Barrier":"100","Strike":"90","0.5":"1.2449","0.75":"1.7829","1.00":"2.1974","1.25":"2.5213","1.50":"2.7767"},{"Z":"P","BarrierType":"DI","Barrier":"100","Strike":"100","0.5":"4.3106","0.75":"4.9043","1.00":"5.3017","1.25":"5.5769","1.50":"5.768"},{"Z":"P","BarrierType":"DI","Barrier":"100","Strike":"110","0.5":"9.939","0.75":"10.0879","1.00":"10.1547","1.25":"10.1598","1.50":"10.1191"},{"Z":"P","BarrierType":"DI","Barrier":"103","Strike":"90","0.5":"1.2449","0.75":"1.7829","1.00":"2.1974","1.25":"2.5213","1.50":"2.7767"},{"Z":"P","BarrierType":"DI","Barrier":"103","Strike":"100","0.5":"4.3106","0.75":"4.9043","1.00":"5.3017","1.25":"5.5769","1.50":"5.768"},{"Z":"P","BarrierType":"DI","Barrier":"103","Strike":"110","0.5":"9.939","0.75":"10.0879","1.00":"10.1547","1.25":"10.1598","1.50":"10.1191"},{"Z":"P","BarrierType":"DO","Barrier":"97","Strike":"90","0.5":"1.6076","0.75":"1.6641","1.00":"1.697","1.25":"1.7189","1.50":"1.7347"},{"Z":"P","BarrierType":"DO","Barrier":"97","Strike":"100","0.5":"1.6112","0.75":"1.666","1.00":"1.6982","1.25":"1.7198","1.50":"1.7353"},{"Z":"P","BarrierType":"DO","Barrier":"97","Strike":"110","0.5":"1.8639","0.75":"1.806","1.00":"1.7887","1.25":"1.7837","1.50":"1.783"},{"Z":"P","BarrierType":"DO","Barrier":"100","Strike":"90","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"DO","Barrier":"100","Strike":"100","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"DO","Barrier":"100","Strike":"110","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"DO","Barrier":"103","Strike":"90","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"DO","Barrier":"103","Strike":"100","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"DO","Barrier":"103","Strike":"110","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"UI","Barrier":"97","Strike":"90","0.5":"1.2449","0.75":"1.7829","1.00":"2.1974","1.25":"2.5213","1.50":"2.7767"},{"Z":"P","BarrierType":"UI","Barrier":"97","Strike":"100","0.5":"4.3106","0.75":"4.9043","1.00":"5.3017","1.25":"5.5769","1.50":"5.768"},{"Z":"P","BarrierType":"UI","Barrier":"97","Strike":"110","0.5":"9.939","0.75":"10.0879","1.00":"10.1547","1.25":"10.1598","1.50":"10.1191"},{"Z":"P","BarrierType":"UI","Barrier":"100","Strike":"90","0.5":"1.2449","0.75":"1.7829","1.00":"2.1974","1.25":"2.5213","1.50":"2.7767"},{"Z":"P","BarrierType":"UI","Barrier":"100","Strike":"100","0.5":"4.3106","0.75":"4.9043","1.00":"5.3017","1.25":"5.5769","1.50":"5.768"},{"Z":"P","BarrierType":"UI","Barrier":"100","Strike":"110","0.5":"9.939","0.75":"10.0879","1.00":"10.1547","1.25":"10.1598","1.50":"10.1191"},{"Z":"P","BarrierType":"UI","Barrier":"103","Strike":"90","0.5":"0.8615","0.75":"1.2201","1.00":"1.5475","1.25":"1.8292","1.50":"2.0671"},{"Z":"P","BarrierType":"UI","Barrier":"103","Strike":"100","0.5":"2.7722","0.75":"3.3936","1.00":"3.8471","1.25":"4.1857","1.50":"4.4412"},{"Z":"P","BarrierType":"UI","Barrier":"103","Strike":"110","0.5":"7.0001","0.75":"7.493","1.00":"7.8069","1.25":"8.0072","1.50":"8.1283"},{"Z":"P","BarrierType":"UO","Barrier":"97","Strike":"90","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"UO","Barrier":"97","Strike":"100","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"UO","Barrier":"97","Strike":"110","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"UO","Barrier":"100","Strike":"90","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"UO","Barrier":"100","Strike":"100","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"UO","Barrier":"100","Strike":"110","0.5":"2.00","0.75":"2.00","1.00":"2.00","1.25":"2.00","1.50":"2.00"},{"Z":"P","BarrierType":"UO","Barrier":"103","Strike":"90","0.5":"2.3562","0.75":"2.5295","1.00":"2.6117","1.25":"2.6497","1.50":"2.6637"},{"Z":"P","BarrierType":"UO","Barrier":"103","Strike":"100","0.5":"3.5112","0.75":"3.4773","1.00":"3.4164","1.25":"3.3488","1.50":"3.2809"},{"Z":"P","BarrierType":"UO","Barrier":"103","Strike":"110","0.5":"4.9117","0.75":"4.5616","1.00":"4.3095","1.25":"4.1103","1.50":"3.9448"}]}
To calculate the delta for the first option:
SELECT wct.StandardBarrier( 'C', --PutCall
'DI', --BarrierType
100, --Asset Price
90, --Strike Price
97, --Barrier
2, --Rebate
0.5, --Time-to-expiry
.10, --Risk Free Rate
.05, --Dividend Rate
.20, --Volatility
'D' --Return Value
) as Delta;
This produces the following result.
{"columns":[{"field":"Delta","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"Delta":"-0.649025843078022"}]}
In this example we show all of the return values for an option (which can be more easily done using STANDARDBARRIERPRICENGREEKS).
SELECT n.rv as Description,
wct.StandardBarrier('C', 'DI', 100, 90, 97, 2, 0.5, .10, .05, .20, n.rv)
as Value
FROM
(
SELECT 'Price'
UNION ALL
SELECT 'Delta'
UNION ALL
SELECT 'Gamma'
UNION ALL
SELECT 'GammaX'
UNION ALL
SELECT 'Theta'
UNION ALL
SELECT 'Vega'
UNION ALL
SELECT 'Rho'
UNION ALL
SELECT 'RhoFuturesOption'
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 'CarrySensitivity'
UNION ALL
SELECT 'DgammaDspot'
UNION ALL
SELECT 'DeltaX'
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":"8.59507043337689"},{"Description":"Delta","Value":"-0.649025843078022"},{"Description":"Gamma","Value":"0.052092730129516"},{"Description":"GammaX","Value":"0.0207577954824956"},{"Description":"Theta","Value":"-0.0173153378580135"},{"Description":"Vega","Value":"0.258665904443234"},{"Description":"Rho","Value":"0.156984606562283"},{"Description":"RhoFuturesOption","Value":"-0.0379626818828527"},{"Description":"Lambda","Value":"-7.55114048347627"},{"Description":"DdeltaDvol","Value":"0.0135552546964846"},{"Description":"DdeltaDvolDvol","Value":"-0.650285444002208"},{"Description":"DdeltaDtime","Value":"0.000306086723699144"},{"Description":"DgammaDvol","Value":"-0.00416152983184759"},{"Description":"GammaP","Value":"0.052092730129516"},{"Description":"DvegaDvol","Value":"-0.00199687541169169"},{"Description":"VegaP","Value":"0.517331808886468"},{"Description":"PhiRho2","Value":"-0.199959958365525"},{"Description":"CarrySensitivity","Value":"0.199959958365525"},{"Description":"DgammaDspot","Value":"12980.5178819264"},{"Description":"DeltaX","Value":"-0.582783834275347"},{"Description":"DvommaDvol","Value":"0.000564868690799969"},{"Description":"DvegaDtime","Value":"-0.0699760427380625"},{"Description":"DgammaDtime","Value":"-5.04370755206702E-05"}]}