module

Stochasta::Portfolio::Risk

Class methods

monte_carlo_cvar(simulated_returns : Array(Float64), confidence : Float64 = 0.95) : Float64

Computes Monte Carlo Conditional Value at Risk (CVaR) Returns the loss as a positive value

Source
monte_carlo_var(simulated_returns : Array(Float64), confidence : Float64 = 0.95) : Float64

Computes Monte Carlo Value at Risk (VaR) Returns the loss as a positive value

Source
parametric_cvar(mean_return : Float64, std_dev : Float64, confidence : Float64 = 0.95) : Float64

Computes the parametric Conditional Value at Risk (CVaR) under normal distribution Returns the loss as a positive value

Source
parametric_var(mean_return : Float64, std_dev : Float64, confidence : Float64 = 0.95) : Float64

Computes the parametric Value at Risk (VaR) under normal distribution assumption Returns the loss as a positive value (fraction of portfolio value)

Source
z_score(confidence : Float64) : Float64

Returns the Z-score for a given confidence level (e.g., 0.95 -> 1.64485, 0.99 -> 2.32635) Uses inverse error function approximation or standard values for common metrics

Source