gbm

Defined in fynance.research

gbm(n, *, mu=0.0, sigma=0.01, s0=100.0, seed=None)[source]

Geometric Brownian motion price path.

Log-returns are drawn i.i.d. Normal(mu, sigma), so the path’s mean log-return is mu and its volatility sigma.

Parameters:
nint

Number of observations (path length).

mufloat

Mean per-step log-return.

sigmafloat

Per-step log-return volatility.

s0float

Initial price.

seedint, optional

Seed for reproducibility. None is nondeterministic.

Returns:
fynance.core.PriceSeries

Price path of length n.

Examples

>>> import numpy as np
>>> from fynance.research import gbm
>>> a, b = gbm(5, seed=7), gbm(5, seed=7)
>>> bool(np.allclose(a.to_numpy(), b.to_numpy()))
True
>>> int(a.to_numpy().size)
5