Clear Filters
Clear Filters

minimum and maximum number of assets in portfolio optimization

2 views (last 30 days)
I am doing a portfolio optimization with a large number of assets using a portfolio object, and I want to be able to set a minimum and maximum number of assets that the optimizer can allocate to. Any idea on how to do this?

Answers (1)

Neelanshu
Neelanshu on 10 Jan 2024
Hello Robert,
I understand from your inquiry that you're interested in setting a minimum and maximum number of assets for the optimizer to allocate in portfolio optimization.
You can employ the “setMinMaxNumAssets” function available since MATLAB R2018b in 'Portfolio' object to impose cardinality constraints on the number of assets in which to invest in a portfolio. This function allows you to define “MinNumAsset”` and “MaxNumAssets”, which represent the minimum and maximum number of assets to be invested in the portfolio, respectively. The total number of allocated assets, which must satisfy the bound constraints, will fall within the range of [MinNumAssets, MaxNumAssets]. To restrict the total number of assets to no more than two, you can use “setMinMaxNumAssets” as demonstrated in the following code snippet:
AssetMean = [ 0.0101110; 0.0043532; 0.0137058 ];
AssetCovar = [ 0.00324625 0.00022983 0.00420395;
0.00022983 0.00049937 0.00019247;
0.00420395 0.00019247 0.00764097 ];
p = Portfolio('AssetMean', AssetMean, 'AssetCovar', AssetCovar);
p = setDefaultConstraints(p);
p = setMinMaxNumAssets(p, [], 2); %setting MaxNumAssets to 2
pwgt = estimateFrontierByReturn(p,[ 0.008, 0.01 ])
pwgt = 3×2
0 0 0.6101 0.3962 0.3899 0.6038
p %the MaxNumAssets property is set to 2
p =
Portfolio with properties: BuyCost: [] SellCost: [] RiskFreeRate: [] AssetMean: [3×1 double] AssetCovar: [3×3 double] TrackingError: [] TrackingPort: [] Turnover: [] BuyTurnover: [] SellTurnover: [] Name: [] NumAssets: 3 AssetList: [] InitPort: [] AInequality: [] bInequality: [] AEquality: [] bEquality: [] LowerBound: [3×1 double] UpperBound: [] LowerBudget: 1 UpperBudget: 1 GroupMatrix: [] LowerGroup: [] UpperGroup: [] GroupA: [] GroupB: [] LowerRatio: [] UpperRatio: [] MinNumAssets: [] MaxNumAssets: 2 BoundType: [3×1 categorical]
You may refer to the following documentation to learn more about “setMinMaxNumAssets”:
Hope this helps.

Categories

Find more on Portfolio Optimization and Asset Allocation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!