Login     Register

        Contact Us     Search

XLeratorDB/financial-options Documentation

SQL Server function for price and Greeks for binary barrier options


BinaryBarrierAndStrikePriceNGreeks

Updated: 31 Oct 2013


Use the table-valued function BinaryBarrierAndStrikePriceNGreeks to calculate the price and other derivatives for binary barrier options having payoffs that are received only at expiration. Unlike options handled by the BinaryBarrierOnly and the BinaryBarrierPayoutAtHit functions, these options also include a designation as a put or a call in addition to the characteristics of the barrier.
BinaryBarrierAndStrike valuations are based on the formulae published by Mark Rubinstein and Eric Reiner in 1991. In their July 31, 1991 paper Binary Options, they enumerated 28 different types of binary barrier options. This function deals with options numbers 13–28.
The first group of options have positive payoffs requiring not only that the barrier be breached, but also that the underlying asset finish above the strike price.
(13)                         down-and-in cash-or-nothing call;
(14)                         up-and-in cash-or-nothing call;
(15)                         down-and-in asset-or-nothing call; and
(16)                         up-and-in asset-or-nothing call.
The next group have positive payoffs requiring not only that the barrier be breached, but also that the underlying asset finish below the strike price.
(17)                         down-and-in cash-or-nothing put;
(18)                         up-and-in cash-or-nothing put;
(19)                         down-and-in asset-or-nothing put; and
(20)                         up-and-in asset-or-nothing put.
The third group of options have positive payoffs requiring that not only that the barrier not be breached, but also that the underlying asset finish above the strike price.
(21)                         down-and-out cash-or-nothing call;
(22)                         up-and-out cash-or-nothing call;
(23)                         down-and-out asset-or-nothing call; and
(24)                         up-and-out asset-or-nothing call.
The final group of options have positive payoffs requiring not only that the barrier not be breached, but also that the underlying asset finish below the strike price.
(25)                         down-and-out cash-or-nothing put;
(26)                         up-and-out cash-or-nothing put;
(27)                         down-and-out asset-or-nothing put; and
(28)                         up-and-out asset-or-nothing put.
Syntax
SELECT * FROM [wctOptions].[wct].[BinaryBarrierAndStrikePriceNGreeks](
  <@CallPut, nvarchar(4000),>
 ,<@BarrierType, nvarchar(4000),>
 ,<@CashOrNothing, bit,>
 ,<@AssetPrice, float,>
 ,<@StrikePrice, float,>
 ,<@BarrierPrice, float,>
 ,<@Rebate, float,>
 ,<@TimeToMaturity, float,>
 ,<@RiskFreeRate, float,>
 ,<@DividendRate, float,>
 ,<@Volatility, float,>)
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.
@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.
@CashOrNothing
identifies the option as either a cash-or-nothing ('True') or asset-or-nothing ('False') binary barrier. @CashOrNothing is an expression of type bit or of a type that can be implicitly converted to bit.
@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.
@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.
@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.
@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 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 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.
@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.
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,
      [GammaP] [float] NULL,
      [DdeltaDtime] [float] NULL,
      [DdeltaDvol] [float] NULL,
      [DdeltaDvolDvol] [float] NULL,
      [DgammaDvol] [float] NULL,
      [DvegaDvol] [float] NULL,
      [VegaP] [float] NULL,
      [PhiRho2] [float] NULL,
      [DgammaDspot] [float] NULL,
      [DeltaX] [float] NULL,
      [RiskNeutralDensity] [float] NULL,
      [DvommaDvol] [float] NULL,
      [DgammaDtime] [float] NULL,
      [DvegaDtime] [float] NULL,
      [FuturesOptionsRho] [float] NULL,
      [CarrySensitivity] [float] NULL,
      [ForwardPrice] [float] NULL,
      [ForwardPoints] [float] NULL
The columns returned by BinaryBarrierAndStrikePriceNGreeks are measuring the sensitivity of the theoretical value of the option.

Column
Description
Price
The theoretical value of the option.
Delta
The sensitivity to small changes in the asset price; the first derivative of the option with respect to price.
Gamma
The rate of change in Delta with respect to small changes in the asset price; the second derivative of the option with respect to price.
Theta
The sensitivity to small changes in time; the first derivative of the option with respect to time.
Vega
The sensitivity to small changes in volatility; the first derivative of the option with respect to volatility.
Rho
The sensitivity to small changes in the risk-free rate; the first derivative of the option with respect to the risk-free rate.
Lambda
Delta multiplied by the asset price divided by the theoretical value. If the theoretical value is zero, then lambda is set to zero.
GammaP
Gamma multiplied by asset price divided by strike price.
DdeltaDtime
The instantaneous change in delta over the passage of time; the second derivative, once to asset price and once to time.
DdeltaDvol
The sensitivity of delta with respect to volatility; the second derivative, once to asset price and once to volatility.
DdeltaDvolDvol
The second derivative of delta with respect to volatility; the third derivative, once to asset price and twice to volatility.
DgammaDvol
The rate of change in gamma with respect to changes in volatility; the third derivative, twice to asset price and once to volatility.
DvegaDvol
The rate of change to Vega as the volatility changes; the second derivative with respect to volatility.
VegaP
The percentage change in theoretical value for a 10 per cent change in volatility.
PhiRho2
The sensitivity to a change in the dividend yield (foreign interest rate for a currency option); the first derivative with respect to dividend yield.
DgammaDspot
The rate of change in gamma with respect to change in the asset price; the third derivative with respect to price.
DeltaX
The sensitivity to a change in the strike price; the first derivative with respect to strike price.
RiskNeutralDensity
The sensitivity of DeltaX; the second derivative with respect to strike price.
DvommaDvol
The sensitivity of DvegaDvol to changes in volatility; the third derivative, twice to asset price and once to volatility.
DgammaDtime
The sensitivity of Gamma to the passage of time; the third derivative, twice to asset price and once to time.
DvegaDtime
The sensitivity of Vega to the passage of time; the second derivative, once to volatility and once to time.
FuturesOptionsRho
The sensitivity to change in risk-free rate assuming a cost-of-carry of zero.
CarrySensitivity
-PhiRho2
ForwardPrice
The value of the underlying asset at the expiration date of the option.
ForwardPoints
The difference between the ForwardPrice and the asset price.

 
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.
Example
In this example we calculate the price and Greeks of a down-and-in cash-or-nothing call option.
SELECT *
FROM wct.BinaryBarrierAndStrikePriceNGreeks(
 'C'           --CallPut
,'DI'          --BarrierType
,'True'        --CashOrNothing
,100           --AssetPrice
,100           --StrikePrice
,92            --BarrierPrice
,2             --Rebate
,.50           --TimeToMaturity
,.10           --RiskFreeRate
,.05           --DividendRate
,.20           --Volatility
)

Here are the first few columns of the resultant table.


 
In this SELECT we un-pivot the columns returned by the function for ease of viewing the results.
SELECT n.*
FROM wct.BinaryBarrierAndStrikePriceNGreeks(
 'C'           --CallPut
,'DI'          --BarrierType
,'True'        --CashOrNothing
,100           --AssetPrice
,100           --StrikePrice
,92            --BarrierPrice
,2             --Rebate
,.50           --TimeToMaturity
,.10           --RiskFreeRate
,.05           --DividendRate
,.20           --Volatility
)
CROSS APPLY(VALUES
('Price',Price)
,('Delta',Delta)
,('Gamma',Gamma)
,('Theta',Theta)
,('Vega',Vega)
,('Rho',Rho)
,('Lambda',Lambda)
,('GammaP',GammaP)
,('DdeltaDtime',DdeltaDtime)
,('DdeltaDvol',DdeltaDvol)
,('DdeltaDvolDvol',DdeltaDvolDvol)
,('DgammaDvol',DgammaDvol)
,('DvegaDvol',DvegaDvol)
,('VegaP',VegaP)
,('PhiRho2',PhiRho2)
,('DgammaDspot',DgammaDspot)
,('DeltaX',DeltaX)
,('RiskNeutralDensity',RiskNeutralDensity)
,('DvommaDvol',DvommaDvol)
,('DgammaDtime',DgammaDtime)
,('DvegaDtime',DvegaDtime)
,('FuturesOptionsRho',FuturesOptionsRho)
,('CarrySensitivity',CarrySensitivity)
,('ForwardPrice',ForwardPrice)
,('ForwardPoints',ForwardPoints)
)n([Return Value], Value)

This produces the following result.
Return Value                        Value
------------------ ----------------------
Price                    0.23772850292138
Delta                 -0.0301930668993033
Gamma                 0.00317471327004881
Theta                -0.00126385444988403
Vega                    0.022497932508421
Rho                   0.00221383454113433
Lambda                                  0
GammaP                0.00317471327004881
DdeltaDtime          3.92842493694796E-05
DdeltaDvol          -0.000297989639908014
DdeltaDvolDvol        0.00024383030556574
DgammaDvol          -0.000272046290494821
DvegaDvol           -0.000919069889360191
VegaP                  0.0449958650168419
PhiRho2              -0.00340247700403862
DgammaDspot         -0.000222105278613327
DeltaX                -0.0266271393552231
RiskNeutralDensity    0.00228675689495361
DvommaDvol          -9.85342348596985E-05
DgammaDtime          0.000287089396129649
DvegaDtime          -0.00141711661051171
FuturesOptionsRho    -0.00118864251510142
CarrySensitivity      0.00340247700403862
ForwardPrice             102.531512052443
ForwardPoints            2.53151205244289


Use CROSS APPLY when there are many input rows.
SELECT n.bt,n.K,k.Price,K.Delta,K.Gamma,K.Theta,K.Vega,K.Rho
FROM (VALUES
     (1,'C','DI','True',100,100,92,2,.50,.10,.05,.20)
    ,(2,'C','DI','True',100,100,96,2,.50,.10,.05,.20)
    ,(3,'C','DI','True',100,100,100,2,.50,.10,.05,.20)
    ,(4,'C','UI','True',100,100,104,2,.50,.10,.05,.20)
    ,(5,'C','UI','True',100,100,108,2,.50,.10,.05,.20)
    ,(6,'C','DO','True',100,100,92,2,.50,.10,.05,.20)
    ,(7,'C','DO','True',100,100,96,2,.50,.10,.05,.20)
    ,(8,'C','DO','True',100,100,100,2,.50,.10,.05,.20)
    ,(9,'C','UO','True',100,100,104,2,.50,.10,.05,.20)
    ,(10,'C','UO','True',100,100,108,2,.50,.10,.05,.20)
      )n(rn,z,bt,cash,S,X,K,H,T,Rf,Rd,Vol)
CROSS APPLY wct.BinaryBarrierAndStrikePriceNGreeks(z,bt,cash,S,X,K,H,T,Rf,Rd,Vol)k

This produces the following (reformatted) results.

bt
K
Price
Delta
Gamma
Theta
Vega
Rho
DI
92
0.23773
-0.03019
0.00317
-0.00126
0.02250
0.00221
DI
96
0.57036
-0.05373
0.00353
-0.00104
0.01636
0.00809
DI
100
1.03158
-0.06884
0.00212
0.00006
-0.00934
0.02153
UI
104
1.01622
0.05710
-0.00080
-0.00006
-0.00712
0.02161
UI
108
0.93142
0.06346
0.00012
-0.00068
0.00383
0.02174
DO
92
0.79385
0.08356
-0.00411
0.00133
-0.03184
0.01931
DO
96
0.46122
0.10710
-0.00446
0.00111
-0.02570
0.01343
DO
100
0.00000
0.12221
-0.00306
0.00000
0.00000
0.00000
UO
104
0.01536
-0.00373
-0.00013
0.00013
-0.00222
-0.00008
UO
108
0.10016
-0.01010
-0.00105
0.00075
-0.01316
-0.00021

 


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service