Skip to content

with_carry

module jetblack_options.numeric_greeks.with_carry

Summary

Class for calculating numeric greeks for options using finite difference

Description

methods for the generalised style using cost of carry.

class NumericGreeks


jetblack_options.numeric_greeks.with_carry.NumericGreeks(
price: Callable[[float, float, float, float, float, float], float]
) -> None

Parameters

price: Callable[[float, float, float, float, float, float], float]

method NumericGreeks.carry

Summary

Calculate the carry on an option using the finite difference.

Description

The carry is calculated according to one of the three difference methods.

Central difference method.

Vb=BSprice(S,K,T,r,b+Δb,σ)BSprice(S,K,T,r,bΔb,σ)2Δb

Forward difference method.

Vb=BSprice(S,K,T,r,b+Δb,σ)BSprice(S,K,T,r,b,σ)Δb

Backward difference method.

Vr=BSprice(S,K,T,r,b,σ)BSprice(S,K,T,r,bΔb,σ)Δb
NumericGreeks.carry(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
db: float,
method: DifferenceMethod
) -> float

Parameters

S: float

The asset price.

K: float

The strike.

T: float

Time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The volatility.

db: float (optional)

The absolute amount to change the carry rate by. Defaults to 0.001.

method: DifferenceMethod (optional)

The method to use. Defaults to 'central'.

Returns

float: The numeric carry.

method NumericGreeks.charm

Summary

Measures the instantaneous rate of change of delta over the passage of

Description

time.

Also known as DdeltaDtime.

NumericGreeks.charm(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float,
dT: float
) -> float

Parameters

S: float

The asset price.

K: float

The strike price.

T: float

The time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The asset volatility.

dS: float (optional)

Change in asset price. Defaults to 0.01.

dT: float (optional)

Change in time. Defaults to 1/365.

Returns

float: The charm.

method NumericGreeks.delta

Summary

Calculate the delta on an option using the finite difference.

Description

The delta is calculated according to one of the three difference methods.

Central difference method.

VS=BSprice(S+ΔS,K,T,r,b,σ)BSprice(SΔS,K,T,r,b,σ)2ΔS

Forward difference method.

VS=BSprice(S+ΔS,K,T,r,b,σ)BSprice(S,K,T,r,b,σ)ΔS

Backward difference method.

VS=BSprice(S,K,T,r,b,σ)BSprice(SΔS,K,T,r,b,σ)ΔS
NumericGreeks.delta(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float,
method: DifferenceMethod
) -> float

Parameters

S: float

The asset price.

K: float

The strike.

T: float

Time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The volatility.

dS: float (optional)

The absolute amount to change the asset price by. Defaults to 0.01.

method: DifferenceMethod (optional)

The method to use. Defaults to 'central'.

Returns

float: The numeric delta.

method NumericGreeks.deltap


NumericGreeks.deltap(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dS: float (optional)

Returns

float:

method NumericGreeks.dgamma_dvol


NumericGreeks.dgamma_dvol(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float,
dv: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dS: float (optional)
dv: float (optional)

Returns

float:

method NumericGreeks.elasticity


NumericGreeks.elasticity(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dS: float (optional)

Returns

float:

method NumericGreeks.futures_rho


NumericGreeks.futures_rho(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dr: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dr: float (optional)

Returns

float:

method NumericGreeks.gamma

Summary

Calculate the gamma of an option using finite difference methods.

Description

The gamma is calculated according to one of the three difference methods.

Central difference method.

2VS2=BSprice(S+ΔS,K,T,r,b,σ)2BSprice(S,K,T,r,b,σ)+BSprice(SΔS,K,T,r,b,σ)ΔS2

Forward difference method.

2VS2=BSprice(S+2ΔS,K,T,r,b,σ)2BSprice(S+ΔS,K,T,r,b,σ)+BSprice(S,K,T,r,b,σ)ΔS2

Backward difference method.

2VS2=BSprice(S,K,T,r,b,σ)2BSprice(SΔS,K,T,r,b,σ)+BSprice(S2ΔS,K,T,r,b,σ)ΔS2
NumericGreeks.gamma(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float,
method: DifferenceMethod
) -> float

Parameters

S: float

The asset price.

K: float

The strike.

T: float

Time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The volatility.

dS: float (optional)

The absolute amount to change the asset price by. Defaults to 0.01.

method: DifferenceMethod (optional)

The method to use. Defaults to 'central'.

Returns

float: The numeric gamma.

method NumericGreeks.gammap


NumericGreeks.gammap(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dS: float (optional)

Returns

float:

method NumericGreeks.rho

Summary

Calculate the rho on an option using the finite difference.

Description

The rho is calculated according to one of the three difference methods.

Central difference method.

Vr=BSprice(S,K,T,r+Δr,b+Δr,σ)BSprice(S,K,T,rΔr,bΔr,σ)2Δr

Forward difference method.

Vr=BSprice(S,K,T,r+Δr,b+Δr,σ)BSprice(S,K,T,r,b,σ)Δr

Backward difference method.

Vr=BSprice(S,K,T,r,b,σ)BSprice(S,K,T,rΔr,bΔr,σ)Δr
NumericGreeks.rho(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dr: float,
method: DifferenceMethod
) -> float

Parameters

S: float

The asset price.

K: float

The strike.

T: float

Time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The volatility.

dr: float (optional)

The absolute amount to change the rate by. Defaults to 0.001.

method: DifferenceMethod (optional)

The method to use. Defaults to 'central'.

Returns

float: The numeric rho.

method NumericGreeks.rho2


NumericGreeks.rho2(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
db: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
db: float (optional)

Returns

float:

method NumericGreeks.speed


NumericGreeks.speed(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dS: float (optional)

Returns

float:

method NumericGreeks.strike_delta


NumericGreeks.strike_delta(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dK: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dK: float (optional)

Returns

float:

method NumericGreeks.strike_gamma


NumericGreeks.strike_gamma(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dK: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dK: float (optional)

Returns

float:

method NumericGreeks.theta

Summary

Calculate the theta on an option using the finite difference.

Description

The theta is calculated according to one of the three difference methods.

Central difference method.

VT=BSprice(S,K,TΔT,r,b,σ)BSprice(S,K,T+ΔT,r,b,σ)2ΔT

Forward difference method.

VT=BSprice(S,K,T,r,b,σ)BSprice(S,K,T+ΔT,r,b,σ)ΔT

Backward difference method.

VT=BSprice(S,K,TΔT,r,b,σ)BSprice(S,K,T,r,b,σ)ΔT
NumericGreeks.theta(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dT: float,
method: DifferenceMethod
) -> float

Parameters

S: float

The asset price.

K: float

The strike.

T: float

Time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The volatility.

dT: float (optional)

The absolute amount to change the asset price by. Defaults to 1/365.

method: DifferenceMethod (optional)

The method to use. Defaults to 'central'.

Returns

float: The numeric theta.

method NumericGreeks.time_gamma


NumericGreeks.time_gamma(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dT: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dT: float (optional)

Returns

float:

method NumericGreeks.vanna

Summary

The second order derivative of the option price to a change in the asset

Description

price and a change in the volatility.

NumericGreeks.vanna(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dS: float,
dv: float
) -> float

Parameters

S: float

The asset price.

K: float

The strike price.

T: float

The time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The asset volatility.

dS: float (optional)

The change in spot price. Defaults to 0.01.

dv: float (optional)

The change in volatility. Defaults to 0.01.

Returns

float: description

method NumericGreeks.vega

Summary

Calculate the vega on an option using the finite difference.

Description

The vega is calculated according to one of the three difference methods.

Central difference method.

Vσ=BSprice(S,K,T,r,b,σ+Δσ)BSprice(S,K,T,r,b,σΔσ)2Δσ

Forward difference method.

Vσ=BSprice(S,K,T,r,b,σ+Δσ)BSprice(S,K,T,r,b,σ)Δσ

Backward difference method.

Vσ=BSprice(S,K,T,r,b,σ)BSprice(S,K,T,r,b,σΔσ)Δσ
NumericGreeks.vega(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dv: float,
method: DifferenceMethod
) -> float

Parameters

S: float

The asset price.

K: float

The strike.

T: float

Time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The volatility.

dv: float (optional)
method: DifferenceMethod (optional)

The method to use. Defaults to 'central'.

Returns

float: The numeric vega.

method NumericGreeks.vegap


NumericGreeks.vegap(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dv: float
) -> float

Parameters

S: float
K: float
T: float
r: float
b: float
v: float
dv: float (optional)

Returns

float:

method NumericGreeks.vomma

Summary

Calculate the vomma of an option using finite difference methods.

Description

The vomma is calculated according to one of the three difference methods.

Central difference method.

2Vσ2=BSprice(S,K,T,r,b,σ+Δσ)2BSprice(S,K,T,r,b,σ)+BSprice(S,K,T,r,b,σΔσ)Δσ2

Forward difference method.

2Vσ2=BSprice(S,K,T,r,b,σ+2Δσ)2BSprice(S,K,T,r,b,σ+Δσ)+BSprice(S,K,T,r,b,σ)Δσ2

Backward difference method.

2Vσ2=BSprice(S,K,T,r,b,σ)2BSprice(S,K,T,r,b,σΔσ)+BSprice(S,K,T,r,b,σ2Δσ)Δσ2
NumericGreeks.vomma(
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
*,
dv: float
) -> float

Parameters

S: float

The asset price.

K: float

The strike.

T: float

Time to expiry in years.

r: float

The risk free rate.

b: float

The cost of carry.

v: float

The volatility.

dv: float (optional)

The absolute amount to change the volatility price by. Defaults to 0.001.

Returns

float: The numeric vomma.