Net returns and drawdowns
Net returns and drawdowns are two of the performance metrics of a portfolio. Here we define functions used to compute portfolio returns and related quantities.
PortfolioOptimisers.calc_net_returns Function
calc_net_returns(w::VecNum, X::MatNum, args...)
calc_net_returns(w::VecNum, X::MatNum, fees::Fees)Compute the net portfolio returns. If fees is provided, it deducts the computed fees from the gross returns.
Returns the portfolio returns as the product of the asset return matrix X and portfolio weights w.
Where:
: T × 1vector of portfolio net returns.: T × Nmatrix of asset returns (observations × assets).: N × 1vector of portfolio weights.: Total fees computed using calc_fees.: Elementwise (Hadamard) subtraction.
Arguments
w: Portfolio weights.X: Asset return matrix (observations × assets).fees:Feesstructure.args...: Additional arguments (ignored).
Returns
val::VecNum: Portfolio net returns.
Examples
julia> calc_net_returns([0.5, 0.5], [0.01 0.02; 0.03 0.04])
2-element Vector{Float64}:
0.015
0.035Related
sourcePortfolioOptimisers.calc_net_asset_returns Function
calc_net_asset_returns(w::VecNum, X::MatNum, args...)
calc_net_asset_returns(w::VecNum, X::MatNum, fees::Fees)Compute the per asset net portfolio returns. If fees is provided, it deducts the computed fees from the gross returns.
Returns the per asset portfolio returns as the product of the asset return matrix X and portfolio weights w.
Where:
: T × Nmatrix of per asset portfolio net returns.: T × Nmatrix of asset returns (observations × assets).: N × 1vector of portfolio weights.: N × 1per asset vector of total portfolio fees computed usingcalc_fees.: Elementwise (Hadamard) multiplication. : Elementwise (Hadamard) subtraction.
Arguments
w: Portfolio weights.X: Asset return matrix (assets × periods).fees:Feesstructure.args...: Additional arguments (ignored).
Returns
ret::MatNum: Per asset portfolio net returns.
Examples
julia> calc_net_asset_returns([0.5, 0.5], [0.01 0.02; 0.03 0.04])
2×2 Matrix{Float64}:
0.005 0.01
0.015 0.02Related
sourcePortfolioOptimisers.cumulative_returns Function
cumulative_returns(X::ArrNum, compound::Bool = false; dims::Int = 1)Compute simple or compounded cumulative returns along a specified dimension.
cumulative_returns computes the cumulative returns for an array of asset or portfolio returns. By default, it computes simple cumulative returns using cumsum. If compound is true, it computes compounded cumulative returns using cumprod(one(eltype(X)) .+ X).
Portfolio cumulative returns
Where:
: T × 1vector of portfolio returns.: Simple cumulative portfolio returns at period j.: Compound cumulative portfolio returns at period j.: T × 1vector of simple cumulative portfolio returns.: T × 1vector of compound cumulative portfolio returns.
Per asset cumulative returns
The same definitions apply as above, but for each individual asset in the returns matrix
Arguments
X: Array of asset or portfolio returns (vector or matrix).compound: Iftrue, computes compounded cumulative returns; otherwise, computes simple cumulative returns.dims: Dimension along which to compute cumulative returns.
Returns
ret::ArrNum: Array of cumulative returns, same shape asX.
Examples
julia> cumulative_returns([0.01, 0.02, -0.01])
3-element Vector{Float64}:
0.01
0.03
0.02
julia> cumulative_returns([0.01, 0.02, -0.01], true)
3-element Vector{Float64}:
1.01
1.0302
1.019898Related
sourcePortfolioOptimisers.drawdowns Function
drawdowns(X::ArrNum, compound::Bool = false; cX::Bool = false, dims::Int = 1)Compute simple or compounded drawdowns along a specified dimension.
Portfolio drawdowns
Where:
: T × 1vector of simple drawdowns.: Simple drawdown at period j.: T × 1vector of compound drawdowns.: Compound drawdown at period j.: T × 1vector of portfolio returns.
Per asset portfolio drawdowns
The same definitions apply as above, but for each individual asset in the returns matrix
Returns
dd::ArrNum: Array of drawdowns, same shape asX.
Details
drawdowns computes the drawdowns for an array of asset or portfolio returns. By default, it computes drawdowns from cumulative returns using cumulative_returns. If compound is true, it computes compounded drawdowns. If cX is true, treats X as cumulative returns; otherwise, computes cumulative returns first.
Examples
julia> drawdowns([0.01, 0.02, -0.01])
3-element Vector{Float64}:
0.0
0.0
-0.009999999999999998
julia> drawdowns([0.01, 0.02, -0.01], true)
3-element Vector{Float64}:
0.0
0.0
-0.010000000000000009Related
source