Lean  $LEAN_TAG$
QuantConnect.Algorithm.Framework.Portfolio.MinimumVariancePortfolioOptimizer Class Reference

Provides an implementation of a minimum variance portfolio optimizer that calculate the optimal weights with the weight range from -1 to 1 and minimize the portfolio variance with a target return of 2% More...

Inheritance diagram for QuantConnect.Algorithm.Framework.Portfolio.MinimumVariancePortfolioOptimizer:
[legend]

Public Member Functions

 MinimumVariancePortfolioOptimizer (double lower=-1, double upper=1, double targetReturn=0.02)
 Initialize a new instance of MinimumVariancePortfolioOptimizer More...
 
double[] Optimize (double[,] historicalReturns, double[] expectedReturns=null, double[,] covariance=null)
 Perform portfolio optimization for a provided matrix of historical returns and an array of expected returns More...
 

Protected Member Functions

LinearConstraint GetBudgetConstraint (int size)
 Sum of all weight is one: 1^T w = 1 / Σw = 1 More...
 
IEnumerable< LinearConstraint > GetBoundaryConditions (int size)
 Boundary constraints on weights: lw ≤ w ≤ up More...
 

Detailed Description

Provides an implementation of a minimum variance portfolio optimizer that calculate the optimal weights with the weight range from -1 to 1 and minimize the portfolio variance with a target return of 2%

The budged constrain is scaled down/up to ensure that the sum of the absolute value of the weights is 1.

Definition at line 29 of file MinimumVariancePortfolioOptimizer.cs.

Constructor & Destructor Documentation

◆ MinimumVariancePortfolioOptimizer()

QuantConnect.Algorithm.Framework.Portfolio.MinimumVariancePortfolioOptimizer.MinimumVariancePortfolioOptimizer ( double  lower = -1,
double  upper = 1,
double  targetReturn = 0.02 
)

Initialize a new instance of MinimumVariancePortfolioOptimizer

Parameters
lowerLower bound
upperUpper bound
targetReturnTarget return

Definition at line 41 of file MinimumVariancePortfolioOptimizer.cs.

Member Function Documentation

◆ GetBudgetConstraint()

LinearConstraint QuantConnect.Algorithm.Framework.Portfolio.MinimumVariancePortfolioOptimizer.GetBudgetConstraint ( int  size)
protected

Sum of all weight is one: 1^T w = 1 / Σw = 1

Parameters
sizenumber of variables
Returns
linear constaraint object

Definition at line 53 of file MinimumVariancePortfolioOptimizer.cs.

Here is the caller graph for this function:

◆ GetBoundaryConditions()

IEnumerable<LinearConstraint> QuantConnect.Algorithm.Framework.Portfolio.MinimumVariancePortfolioOptimizer.GetBoundaryConditions ( int  size)
protected

Boundary constraints on weights: lw ≤ w ≤ up

Parameters
sizenumber of variables
Returns
enumeration of linear constaraint objects

Definition at line 68 of file MinimumVariancePortfolioOptimizer.cs.

Here is the caller graph for this function:

◆ Optimize()

double [] QuantConnect.Algorithm.Framework.Portfolio.MinimumVariancePortfolioOptimizer.Optimize ( double  historicalReturns[,],
double[]  expectedReturns = null,
double  covariance[,] = null 
)

Perform portfolio optimization for a provided matrix of historical returns and an array of expected returns

Parameters
historicalReturnsMatrix of annualized historical returns where each column represents a security and each row returns for the given date/time (size: K x N).
expectedReturnsArray of double with the portfolio annualized expected returns (size: K x 1).
covarianceMulti-dimensional array of double with the portfolio covariance of annualized returns (size: K x K).
Returns
Array of double with the portfolio weights (size: K x 1)

Implements QuantConnect.Algorithm.Framework.Portfolio.IPortfolioOptimizer.

Definition at line 94 of file MinimumVariancePortfolioOptimizer.cs.

Here is the call graph for this function:

The documentation for this class was generated from the following file: