module

Stochasta::Portfolio::GBM

Class methods

random_normal

Box-Muller transform to generate a standard normal random variable N(0, 1)

Source
simulate_path(s0 : Float64, mu : Float64, sigma : Float64, t : Float64 = 1.0, steps : Int32 = 252) : Array(Float64)

Simulates a single price path using Geometric Brownian Motion Params:

  • s0: initial price
  • mu: expected annual drift
  • sigma: annual volatility
  • t: total time in years (e.g. 1.0)
  • steps: number of time steps Returns an Array(Float64) representing the price path of size steps + 1
Source
simulate_paths(s0 : Float64, mu : Float64, sigma : Float64, t : Float64 = 1.0, steps : Int32 = 252, n_paths : Int32 = 1000) : Array(Array(Float64))

Simulates multiple price paths Returns an Array(Array(Float64)) containing n_paths arrays

Source