Provided: Spot, Strike, Shares, Valuation Day, Exercise Day, Volatility, Interest Rate
Outputs: Model Value, Share Delta, Share Gamma, Volatility Sensitivity, Model Status, Scenario Share Price, Scenario Position Value

# European call risk with Black–Scholes

How much does a call on 200 shares gain if the share price rises by £1? This example uses the Black–Scholes price of a European call to demonstrate algorithmic differentiation. Literally takes derivatives of the pricing formula to calculate delta, gamma and vega. In the editor, choose **View → Show symbolic algebra** to see the formulas behind those numbers.

The opening values come from the fictional FELL ticket. Prices and position value are in pounds.

```tiles
param Spot: number = 43
param Strike: number = 45
function In Pounds(Amount) = money("GBP", string(Amount as "2dp"))
```

Shares = 200
Valuation Day = 30 November 2026
Exercise Day = 18 December 2026
Volatility = 35%
Interest Rate = 4%

field "Share price (£)" sets Spot
field "Strike per share (£)" sets Strike
field "Underlying shares" sets Shares
field "Valuation date" sets Valuation Day
field "Exercise date" sets Exercise Day
field "Annual volatility (0.35 means 35%)" sets Volatility
field "Annual interest rate (0.04 means 4%)" sets Interest Rate

Days Left = Exercise Day - Valuation Day if type_name(Exercise Day) = "date" and type_name(Valuation Day) = "date"
Valid Terms = is_number(Spot) and Spot > 0 and is_number(Strike) and Strike > 0 and is_number(Shares) and Shares > 0 and not is_null(Days Left)
Live Model = Valid Terms and Days Left > 0 and is_number(Volatility) and Volatility > 0 and is_number(Interest Rate)
At Expiry = if_error(Valid Terms and Days Left = 0, false)
Years Left = Days Left / 365 if Live Model

Spread = Volatility * sqrt(Years Left) if Live Model
Discounted Strike = Strike * exp(-Interest Rate * Years Left) if Live Model
z1 = (ln(Spot / Strike) + (Interest Rate + Volatility ^ 2 / 2) * Years Left) / Spread if Live Model
z2 = z1 - Spread if Live Model
Call Per Share = Spot * normal_cdf(z1) - Discounted Strike * normal_cdf(z2) if Live Model
Live Value = Shares * Call Per Share if Live Model
Exercise Value = Shares * (Spot - Strike) if Valid Terms and Spot > Strike else 0 if Valid Terms
Model Value = Live Value if Live Model else Exercise Value if At Expiry
Share Delta = Live Value'(Spot) if Live Model else Exercise Value'(Spot) if At Expiry and Spot != Strike
Share Gamma = Live Value''(Spot) if Live Model else Exercise Value''(Spot) if At Expiry and Spot != Strike
Volatility Sensitivity = Live Value'(Volatility) / 100 if Live Model else 0 if At Expiry
Model Status = "Enter positive spot, strike and share count and valid dates." if not Valid Terms else "The exercise date has passed." if Days Left < 0 else "At expiry the spot sensitivities are undefined exactly at the strike." if At Expiry and Spot = Strike else "Expiry payoff." if At Expiry else "Enter positive volatility and a numeric interest rate." if not Live Model else "Before expiry."

## How the position moves

=Model Status

## A £1 rise in the share price

Delta is the instantaneous slope of the position value at the starting share price. Gamma is the slope of delta, or equivalently the curvature of the position value. As the share price moves, delta changes along the way.

Spot Move = 1
Scenario Share Price = Spot + Spot Move if Live Model
Delta Estimate = Share Delta * Spot Move if Live Model
Gamma Adjustment = Share Gamma * Spot Move ^ 2 / 2 if Live Model
Delta Gamma Estimate = Delta Estimate + Gamma Adjustment if Live Model
Scenario Position Value = (Live Value | Spot = Scenario Share Price) if Live Model
Repriced Change = Scenario Position Value - Model Value if Live Model

For a move of **h** pounds, the second-order estimate is **delta × h + ½ × gamma × h²**, using both derivatives at the starting price. The half appears because the change in delta builds up over the move. Here only the share price changes. The final row prices the same option again at the new share price.

='''The **scenario share price** is **=(In Pounds(Scenario Share Price))**, up from **=(In Pounds(Spot))**. The position starts at **=(In Pounds(Model Value))**. The calculation adds each gain to the unrounded starting value and rounds the displayed figures to the nearest penny.''' if Live Model

| Method | Gain on the position (£) | Position at the scenario share price (£) |
| --- | ---: | ---: |
| Starting delta alone | =(Delta Estimate as "2dp" if Live Model else "—") | =((Model Value + Delta Estimate) as "2dp" if Live Model else "—") |
| Starting delta plus the gamma adjustment | =(Delta Gamma Estimate as "2dp" if Live Model else "—") | =((Model Value + Delta Gamma Estimate) as "2dp" if Live Model else "—") |
| Full Black–Scholes repricing | =(Repriced Change as "2dp" if Live Model else "—") | =(Scenario Position Value as "2dp" if Live Model else "—") |

='''Subtracting the delta-plus-gamma estimate from the repriced position leaves a difference of **=(In Pounds(Repriced Change - Delta Gamma Estimate))**.''' if Live Model

Move Comparison = table(["Method", "Gain (£)"], [["Delta", Delta Estimate], ["Delta + gamma", Delta Gamma Estimate], ["Full repricing", Repriced Change]]) if Live Model

='''
```chart
bar
table: Move Comparison
labels: Method
values: Gain (£)
title: Gain on a £1 rise in the share price
```
''' if Live Model

## Compare the scenarios

Scenario Slopes = (Live Value'(Spot, Volatility) | Spot = Scenario Share Price) if Live Model
Scenario Gamma = (Live Value''(Spot) | Spot = Scenario Share Price) if Live Model
Scenario Volatility = Volatility + 1% if Live Model
Combined Position Value = (Live Value | Spot = Scenario Share Price, Volatility = Scenario Volatility) if Live Model
Combined Slopes = (Live Value'(Spot, Volatility) | Spot = Scenario Share Price, Volatility = Scenario Volatility) if Live Model
Combined Gamma = (Live Value''(Spot) | Spot = Scenario Share Price, Volatility = Scenario Volatility) if Live Model

='''Both scenarios use **=(In Pounds(Scenario Share Price))** per share. The price-only column uses the full repricing above. In the final column, volatility also rises by one percentage point.''' if Live Model else '''The scenarios are available before exercise when the model inputs are valid.'''

| Measure | Current position | Price only | Price + volatility |
| --- | ---: | ---: | ---: |
| Share price (£) | =(Spot as "2dp" if is_number(Spot) else "—") | =(Scenario Share Price as "2dp" if Live Model else "—") | =(Scenario Share Price as "2dp" if Live Model else "—") |
| Annual volatility (%) | =((Volatility * 100) as "2dp" if is_number(Volatility) else "—") | =((Volatility * 100) as "2dp" if Live Model else "—") | =((Scenario Volatility * 100) as "2dp" if Live Model else "—") |
| Model value (£) | =(Model Value as "2dp" if not is_null(Model Value) else "—") | =(Scenario Position Value as "2dp" if Live Model else "—") | =(Combined Position Value as "2dp" if Live Model else "—") |
| Delta (£ of value per £1 of share price) | =(Share Delta as "3dp" if not is_null(Share Delta) else "—") | =(Scenario Slopes.Spot as "3dp" if Live Model else "—") | =(Combined Slopes.Spot as "3dp" if Live Model else "—") |
| Gamma (change in delta per £1 of share price) | =(Share Gamma as "3dp" if not is_null(Share Gamma) else "—") | =(Scenario Gamma as "3dp" if Live Model else "—") | =(Combined Gamma as "3dp" if Live Model else "—") |
| Vega (£ per percentage point of volatility) | =(Volatility Sensitivity as "2dp" if not is_null(Volatility Sensitivity) else "—") | =(Scenario Slopes.Volatility / 100 as "2dp" if Live Model else "—") | =(Combined Slopes.Volatility / 100 as "2dp" if Live Model else "—") |

Each column gives instantaneous sensitivities at its own price and volatility. At the strike on the exercise date the payoff has a corner, so it has no single delta or gamma.

## Delta and gamma across share prices

Plot Step = Spot Move / 2
Steps Below Spot = integer(min(20, Spot / Spot Move)) if Live Model
Plot From = Spot - Steps Below Spot * Plot Step if Live Model
Plot To = Plot From + 40 * Plot Step if Live Model
Delta Curve = plot_series(Share Delta, Spot, Plot From, Plot To, 41) if Live Model
Gamma Curve = plot_series(Share Gamma, Spot, Plot From, Plot To, 41) if Live Model

='''
Each point uses the same valuation date, strike, interest rate and volatility. The graphs sample share prices every 50p, from **=(In Pounds(Plot From))** to **=(In Pounds(Plot To))**. The points at **=(In Pounds(Spot))** and **=(In Pounds(Scenario Share Price))** show the sensitivities in the **Current position** and **Price only** columns above. Where delta climbs fastest, the second graph shows the largest gamma.

```chart
line
table: Delta Curve
labels: X
values: Y
x-axis: Share price (£)
y-axis: Position delta (£ per £)
title: Delta across share prices
```

```chart
line
table: Gamma Curve
labels: X
values: Y
x-axis: Share price (£)
y-axis: Position gamma (change in delta per £)
title: Gamma across share prices
```

The horizontal axis is the share price in pounds. Open **Chart data** beneath either graph for the individual values.
''' if Live Model else '''The curves are available before expiry with valid model inputs.'''

## Read the risk formulas

Delta is '=Live Value'(Spot)' and gamma is '=Live Value''(Spot)'. One prime takes the slope with respect to the share price. Two primes take the slope of delta. Vega is '=Live Value'(Volatility) / 100'. Dividing by 100 converts a full unit of volatility to one percentage point.

The Black–Scholes price per share is '=Spot * normal_cdf(z1) - Discounted Strike * normal_cdf(z2)'. Differentiating that expression takes several steps. Before expiry, the resulting formulas for this position simplify to the textbook forms below. You can use them to check the algebra Literally generates.

| Measure | Equivalent Black–Scholes formula |
| --- | --- |
| Delta | '=Shares * normal_cdf(z1)' |
| Gamma | '=Shares * normal_pdf(z1) / (Spot * Spread)' |
| Vega per percentage point | '=Shares * Spot * normal_pdf(z1) * sqrt(Years Left) / 100' |

Here '=normal_cdf(z1)' is the cumulative probability under the standard normal curve up to z1. Its derivative, '=normal_pdf(z1)', is the height of the curve there. **Spread** is the annual volatility scaled to the time left to exercise.

The combined scenario uses '=Live Value'(Spot, Volatility) | Spot = Scenario Share Price, Volatility = Scenario Volatility'. The names in parentheses select two first derivatives. The values after the bar set the point where both are measured. The table reads '=Combined Slopes.Spot' for delta and '=Combined Slopes.Volatility / 100' for vega.

Share Holding = Shares * Spot
Holding Delta = Share Holding'(Spot)

Owning the underlying shares outright gives a delta of **=Holding Delta**. With **Show symbolic algebra** on, '=Share Holding'(Spot)' expands to **Shares**. Each share gains £1 for a £1 rise in its price. Compare that with the option’s delta, which changes with the share price and the time left to exercise.

This Black–Scholes example assumes European exercise, no dividends, constant annual volatility and a continuously compounded interest rate. Time to exercise is the actual number of calendar days divided by 365. The inputs are illustrative. [Option pricing formula, NYU Stern](https://pages.stern.nyu.edu/~adamodar/pdfiles/eqnotes/optionbasics.pdf)
