Logo

BinaryBarrierPayoutAtHit

Updated 2023-11-14 21:14:06.350000

Syntax

SELECT [westclintech].[wct].[BinaryBarrierPayoutAtHit](
  <@BarrierType, nvarchar(4000),>
 ,<@CashOrNothing, bit,>
 ,<@AssetPrice, float,>
 ,<@StrikePrice, float,>
 ,<@BarrierPrice, float,>
 ,<@Rebate, float,>
 ,<@TimeToMaturity, float,>
 ,<@RiskFreeRate, float,>
 ,<@DividendRate, float,>
 ,<@Volatility, float,>
 ,<@ReturnValue, nvarchar(4000),>)

Description

Use BinaryBarrierPayoutAtHit to calculate the price or Greeks for binary barrier options having payoffs that are received the moment that the barrier is breached. BinaryBarrierPayoutAtHit 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 1–4:

    (1) down-and-in cash-(at-hit)-or-nothing;

    (2) up-and-in cash-(at-hit)-or-nothing;

    (3) down-and-in asset-(at-hit)-or-nothing; and

    (4) up-and-in asset-(at-hit)-or-nothing.

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.

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

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

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

Examples

In this example we calculate the theoretical value (price) of a down-and-in cash-(at-hit)-or-nothing option.

SELECT wct.BinaryBarrierPayoutAtHit(   'DI',   --BarrierType
                                       'True', --CashOrNothing
                                       100,    --AssetPrice
                                       100,    --StrikePrice
                                       92,     --BarrierPrice
                                       2,      --Rebate
                                       .05,    --TimeToMaturity
                                       .10,    --RiskFreeRate
                                       .05,    --DividendRate
                                       .20,    --Volatility
                                       'P'     --ReturnValue
                                   ) as Price;

This produces the following result.

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

This SQL returns delta for the same option.

SELECT wct.BinaryBarrierPayoutAtHit(   'DI',   --BarrierType
                                       'True', --CashOrNothing
                                       100,    --AssetPrice
                                       100,    --StrikePrice
                                       92,     --BarrierPrice
                                       2,      --Rebate
                                       .05,    --TimeToMaturity
                                       .10,    --RiskFreeRate
                                       .05,    --DividendRate
                                       .20,    --Volatility
                                       'D'     --ReturnValue
                                   ) as Delta;

This produces the following result.

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

This SELECT statement reproduces the table for cash-(at-hit)-or-nothing options from the Binary Options paper by Mark Rubenstein and Eric Reiner, July 31, 1991.

SELECT *
FROM
(
    SELECT n.T,
           n2.H,
           Cast(wct.BinaryBarrierPayoutAtHit(   CASE
                                                    WHEN n2.H <= 100 THEN
                                                        'DI'
                                                    ELSE
                                                        'UI'
                                                END,    --BarrierType
                                                'True', --CashOrNothing
                                                100,    --AssetPrice
                                                100,    --StrikePrice
                                                n2.H,   --BarrierPrice
                                                2,      --Rebate
                                                n.T,    --TimeToMaturity
                                                .10,    --RiskFreeRate
                                                .05,    --DividendRate
                                                .20,    --Volatility
                                                'P'     --ReturnValue
                                            ) as money) as Price
    FROM
    (
        VALUES
            (.05),
            (.16),
            (.28),
            (.39),
            (.50),
            (.61),
            (.72),
            (.84),
            (.95)
    ) n (T)
        CROSS APPLY
    (
        VALUES
            (92),
            (96),
            (100),
            (104),
            (108)
    ) n2 (H)
) D
PIVOT
(
    SUM(Price)
    for T in ([.05], [.16], [.28], [.39], [.50], [.61], [.72], [.84], [.95])
) as P
ORDER BY 1;

Here are the results of this query.

{"columns":[{"field":"H","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".05","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".16","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".28","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".39","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".50","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".61","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".72","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".84","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".95","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"H":"92",".05":"0.1165",".16":"0.5532",".28":"0.7981",".39":"0.9314",".50":"1.0227",".61":"1.0899",".72":"1.1418",".84":"1.1866",".95":"1.22"},{"H":"96",".05":"0.699",".16":"1.1761",".28":"1.3463",".39":"1.4287",".50":"1.4824",".61":"1.5207",".72":"1.5496",".84":"1.5743",".95":"1.5925"},{"H":"100",".05":"2.00",".16":"2.00",".28":"2.00",".39":"2.00",".50":"2.00",".61":"2.00",".72":"2.00",".84":"2.00",".95":"2.00"},{"H":"104",".05":"0.7816",".16":"1.278",".28":"1.453",".39":"1.5375",".50":"1.5924",".61":"1.6316",".72":"1.6612",".84":"1.6864",".95":"1.705"},{"H":"108",".05":"0.18",".16":"0.7056",".28":"0.9767",".39":"1.1211",".50":"1.219",".61":"1.2905",".72":"1.3456",".84":"1.393",".95":"1.4283"}]}

This SELECT statement reproduces the table for asset-(at-hit)-or-nothing options from the Binary Options paper by Mark Rubenstein and Eric Reiner, July 31, 1991.

SELECT *
FROM
(
    SELECT n.T,
           n2.H,
           Cast(wct.BinaryBarrierPayoutAtHit(   CASE
                                                    WHEN n2.H <= 100 THEN
                                                        'DI'
                                                    ELSE
                                                        'UI'
                                                END,     --BarrierType
                                                'False', --CashOrNothing
                                                100,     --AssetPrice
                                                100,     --StrikePrice
                                                n2.H,    --BarrierPrice
                                                n2.H,    --Rebate
                                                n.T,     --TimeToMaturity
                                                .10,     --RiskFreeRate
                                                .05,     --DividendRate
                                                .20,     --Volatility
                                                'P'      --ReturnValue
                                            ) as money) as Price
    FROM
    (
        VALUES
            (.05),
            (.16),
            (.28),
            (.39),
            (.50),
            (.61),
            (.72),
            (.84),
            (.95)
    ) n (T)
        CROSS APPLY
    (
        VALUES
            (92),
            (96),
            (100),
            (104),
            (108)
    ) n2 (H)
) D
PIVOT
(
    SUM(Price)
    for T in ([.05], [.16], [.28], [.39], [.50], [.61], [.72], [.84], [.95])
) as P
ORDER BY 1;

Here are the results of this query,

{"columns":[{"field":"H","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".05","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".16","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".28","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".39","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".50","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".61","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".72","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".84","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":".95","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"H":"92",".05":"5.3587",".16":"25.4474",".28":"36.7118",".39":"42.8451",".50":"47.0464",".61":"50.1365",".72":"52.5215",".84":"54.5823",".95":"56.1197"},{"H":"96",".05":"33.5505",".16":"56.4534",".28":"64.6226",".39":"68.5798",".50":"71.1553",".61":"72.9929",".72":"74.3831",".84":"75.5666",".95":"76.4399"},{"H":"100",".05":"100.00",".16":"100.00",".28":"100.00",".39":"100.00",".50":"100.00",".61":"100.00",".72":"100.00",".84":"100.00",".95":"100.00"},{"H":"104",".05":"40.6425",".16":"66.4543",".28":"75.5535",".39":"79.9486",".50":"82.8055",".61":"84.8424",".72":"86.3826",".84":"87.6934",".95":"88.6603"},{"H":"108",".05":"9.7182",".16":"38.1003",".28":"52.7429",".39":"60.5374",".50":"65.8239",".61":"69.6891",".72":"72.6609",".84":"75.2212",".95":"77.1272"}]}