OptimalPortfolios.jl is a light-weight package for portfolio optimization. It essentially wraps julia optimization package JuMP.
s.t.
and
where
Covariance matrix of returns
Execute below on Julia REPL to install the package.
julia> import Pkg
julia> Pkg.add("OptimalPortfolios")
Import the package with
julia> using OptimalPortfolios
Compute maximum Sharpe ratio portfolio with
julia> allocate(X, lower, upper; rf = 0, fullinvest = true, denoise = true, method = "MSR")
X is the
Compute minimum variance portfolio with
julia> allocate(X, lower, upper; fullinvest = true, denoise = true, method = "MV")
Backtest optimal portfolio allocations. -obs_ is the size of historical returns window used to compute optimal portfolio and hold is the holding or rebalance period. Transaction costs are assumed to be zero. P is the
julia> res = backtest(px, obs, hold, lower, upper; rf = 0.0, fullinvest = true, denoise = true, method = "MSR")
julia> plot(res.nav)
julia> println(res.wt)