Portfolio optimization tool and GUI "Too many input arguments"

1 view (last 30 days)
Hi, I'm learning about OOP in Finance and found out this great webinar from 2010 called "Build a Portfolio Analysis Application using Object Oriented Programming Techniques". I'm trying to run the code (originally written in 2010a) in 2017b and I'm stucked with the warning "Too Many Input Arguments". I Traced the error source to a Callback of the GUI that executes a method called computeEfficientFrontier(this,constraintSet). The function takes only 1 argument outside the Object definition and only 1 argument (a Matrix) was passed, neverttheless I keep getting the Warning and the code aborts. Can somebody help me out with this..., Here's the code:
function error_msg = compute_EfficientFrontier(this,constraintSet)
% Compute efficient frontier
% constraintSet: optional constraints matrix (e.g. from portcons)
% error_msg: contains error message in case of failure, empty otherwise
% predefine output
error_msg = [];
% only run if data available
if isempty(this.prices(:,this.assetselection))
error_msg = 'No data available';
return
end
%%And the callback that triggers the warning:
% Optimize portfolios
msg = handles.model.computeEfficientFrontier(conSet);
if ~isempty(msg)
% enable control
set(handles.button_portopt_computeefficientfrontier,'Enable','on');
msgbox(msg,'Warning');
return
end
  3 Comments
Diego Ochoa
Diego Ochoa on 15 Mar 2018
Ok, finally got the red tape...
Error using message
Invalid Message ID format: 'Too many input arguments.'.
Error in portfoliotool>button_portopt_computeefficientfrontier_Callback (line 1200)
error(message(msg));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in portfoliotool (line 25)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)portfoliotool('button_portopt_computeefficientfrontier_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

Sign in to comment.

Answers (1)

Diego Ochoa
Diego Ochoa on 15 Mar 2018
So, yes, I'm answering my own question with a high probability it will be erased soon. As it comes, the Msg warning comes because the computeEfficientFrontier method calls the Financial toolbox portopt , which will be deprecated and no longer takes as arguments the constraint set. So more arguments were passed than allowed. Here the text in the Doc:
portopt has been partially removed and will no longer accept ConSet or varargin arguments. Use Portfolio instead to solve portfolio problems that are more than a long-only fully-invested portfolio. For information on the workflow when using Portfolio objects, see Portfolio Object Workflow. For more information on migrating portopt code to Portfolio, see portopt Migration to Portfolio Object.

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!