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

Provides an implementation of a portfolio optimizer that maximizes the portfolio Sharpe Ratio. The interval of weights in optimization method can be changed based on the long-short algorithm. The default model uses flat risk free rate and weight for an individual security range from -1 to 1. More...

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

Public Member Functions

 MaximumSharpeRatioPortfolioOptimizer (double lower=-1, double upper=1, double riskFreeRate=0.0)
 Initialize a new instance of MaximumSharpeRatioPortfolioOptimizer 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 portfolio optimizer that maximizes the portfolio Sharpe Ratio. The interval of weights in optimization method can be changed based on the long-short algorithm. The default model uses flat risk free rate and weight for an individual security range from -1 to 1.

Definition at line 28 of file MaximumSharpeRatioPortfolioOptimizer.cs.

Constructor & Destructor Documentation

◆ MaximumSharpeRatioPortfolioOptimizer()

QuantConnect.Algorithm.Framework.Portfolio.MaximumSharpeRatioPortfolioOptimizer.MaximumSharpeRatioPortfolioOptimizer ( double  lower = -1,
double  upper = 1,
double  riskFreeRate = 0.0 
)

Initialize a new instance of MaximumSharpeRatioPortfolioOptimizer

Parameters
lowerLower constraint
upperUpper constraint
riskFreeRate

Definition at line 40 of file MaximumSharpeRatioPortfolioOptimizer.cs.

Member Function Documentation

◆ GetBudgetConstraint()

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

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

Parameters
sizenumber of variables
Returns
linear constraint object

Definition at line 52 of file MaximumSharpeRatioPortfolioOptimizer.cs.

Here is the caller graph for this function:

◆ GetBoundaryConditions()

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

Boundary constraints on weights: lw ≤ w ≤ up

Parameters
sizenumber of variables
Returns
enumeration of linear constraint objects

Definition at line 67 of file MaximumSharpeRatioPortfolioOptimizer.cs.

Here is the caller graph for this function:

◆ Optimize()

double [] QuantConnect.Algorithm.Framework.Portfolio.MaximumSharpeRatioPortfolioOptimizer.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 93 of file MaximumSharpeRatioPortfolioOptimizer.cs.

Here is the call graph for this function:

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