Lean
$LEAN_TAG$
|
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...
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... | |
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.
QuantConnect.Algorithm.Framework.Portfolio.MaximumSharpeRatioPortfolioOptimizer.MaximumSharpeRatioPortfolioOptimizer | ( | double | lower = -1 , |
double | upper = 1 , |
||
double | riskFreeRate = 0.0 |
||
) |
Initialize a new instance of MaximumSharpeRatioPortfolioOptimizer
lower | Lower constraint |
upper | Upper constraint |
riskFreeRate |
Definition at line 40 of file MaximumSharpeRatioPortfolioOptimizer.cs.
|
protected |
Sum of all weight is one: 1^T w = 1 / Σw = 1
size | number of variables |
Definition at line 52 of file MaximumSharpeRatioPortfolioOptimizer.cs.
|
protected |
Boundary constraints on weights: lw ≤ w ≤ up
size | number of variables |
Definition at line 67 of file MaximumSharpeRatioPortfolioOptimizer.cs.
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
historicalReturns | Matrix of annualized historical returns where each column represents a security and each row returns for the given date/time (size: K x N). |
expectedReturns | Array of double with the portfolio annualized expected returns (size: K x 1). |
covariance | Multi-dimensional array of double with the portfolio covariance of annualized returns (size: K x K). |
Implements QuantConnect.Algorithm.Framework.Portfolio.IPortfolioOptimizer.
Definition at line 93 of file MaximumSharpeRatioPortfolioOptimizer.cs.