Skip to content

european_binomial

module jetblack_options.trees.european_binomial

Summary

Optional valuation with a European binomial implementation.

function jetblack_options.trees.european_binomial.ivol

Summary

Calculate the volatility of an option that is implied by the price.

jetblack_options.trees.european_binomial.ivol(
is_call: bool,
S: float,
K: float,
T: float,
r: float,
b: float,
p: float,
n: int,
*,
max_iterations: int, Optional,
epsilon: float, Optional
) -> float

Parameters

is_call: bool

True for a call, false for a put.

S: float

The current asset price.

K: float

The option strike price

T: float

The time to expiry of the option in years.

r: float

The risk free rate.

b: float

The cost of carry of the asset.

p: float

The option price.

n: int

The number of the steps in the tree.

max_iterations: int, Optional

The maximum number of iterations before a price is returned. Defaults to 20.

epsilon: float, Optional (optional)

The largest acceptable error. Defaults to 1e-8.

Returns

float: The implied volatility.

function jetblack_options.trees.european_binomial.make_numeric_greeks

Summary

Make a class to generate greeks numerically using finite difference methods.

jetblack_options.trees.european_binomial.make_numeric_greeks(
is_call: bool,
n: int
) -> NumericGreeks

Parameters

is_call: bool

True for a call, false for a put.

n: int

The number of the steps in the tree.

Returns

NumericGreeks: A class which can generate Greeks using finite difference methods.

function jetblack_options.trees.european_binomial.price

Summary

A European binomial option pricing tree.

jetblack_options.trees.european_binomial.price(
is_call: bool,
S: float,
K: float,
T: float,
r: float,
b: float,
v: float,
n: int
) -> float

Parameters

is_call: bool

True for a call, false for a put.

S: float

The current asset price.

K: float

The option strike price

T: float

The time to maturity of the option in years.

r: float

The risk free rate.

b: float

The cost of carry of the asset.

v: float

The volatility of the asset.

n: int

The number of the steps in the tree.

Returns

float: The price of the option.