class

Stochasta::Portfolio::Optimizer

Inherits Reference < Object

Constructors

new(expected_returns : Array(Float64), covariance_matrix : Array(Array(Float64)))
Source

Instance methods

covariance_matrix
Source
covariance_matrix=(covariance_matrix : Array(Array(Float64)))
Source
expected_returns
Source
expected_returns=(expected_returns : Array(Float64))
Source
max_sharpe_weights(risk_free_rate : Float64 = 0.0, iterations : Int32 = 100, swarm_size : Int32 = 40) : Array(Float64)

Finds the weights that maximize the Sharpe Ratio Constraints: long-only (weights >= 0), sum of weights = 1.0

Source
min_variance_weights(iterations : Int32 = 100, swarm_size : Int32 = 40) : Array(Float64)

Finds the weights that minimize the portfolio variance Constraints: long-only (weights >= 0), sum of weights = 1.0

Source
n_assets
Source
n_assets=(n_assets : Int32)
Source
normalize_weights(raw : Array(Float64)) : Array(Float64)

Normalizes a raw weight vector to sum to 1.0

Source
portfolio_return(weights : Array(Float64)) : Float64

Computes the expected return of a portfolio given its weights

Source
portfolio_variance(weights : Array(Float64)) : Float64

Computes the variance of a portfolio given its weights

Source