Portfolio optimization -- estimateCustomObjectivePortfolio equivalent in R2021b?
Show older comments
Hello, Matlab community. I am working on a portfolio optimization exercise, and I'm looking for a way to incorporate a user-defined objective function in the usual Portfolio object workflow. The "estimateCustomObjectivePortfolio" function seems to be exactly what I need, but unfortunately it was introduced in R2022b. I am using a corporate R2021b Matlab license, so my IT department may not let me just upgrade to get the new functionality (I'm checking on that as well).
Assuming I have to live with R2021b for now, I'll give you an example of what I'm trying to accomplish. Consider a fixed-income-only universe of asset classes, and durations for each:
- IG corporate duration = 7 years
- high yield corporate duration = 3 years
- treasury duration = 10 years
- etc.
In the portfolio optimization, I'd like to be able to have a stated duration target for the resulting portfolio. But, the duration of any hypothetical portfolio depends on the portfolio weights the optimizer is considering in any given iteration, and I don't see a way (in my version of Matlab) to state that duration target as a constraint or objective.
Thanks in advance for any thoughts you may have.
Accepted Answer
More Answers (1)
Alejandra Pena-Ordieres
on 8 Apr 2025
Hello,
Since target duration can be added as a linear equality constraint, you can still use the Portfolio object. You won't need the estimateCustomObjectivePortfolio function. Here is the code that you'd need to include the target duration constraint:
% Initialize Portfolio object
p = Portfolio;
% Set moments and problem constraints (other than target duration)
% ...
% Set target duration constraint
assetDurations = [7; 3; 10]; % Example durations for each asset
targetDuration = 5; % Target portfolio duration
p = setEquality(p,assetDurations',targetDuration);
% Get efficient frontier
plotFrontier(p)
Hope this helps!
Categories
Find more on Get Started with Optimization Toolbox 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!