Video length is 2:26

Building a Portfolio Optimization Agent with MATLAB

Portfolio optimization involves multiple steps, from analyzing market data and constructing an efficient frontier to selecting portfolios, running backtests, and visualizing results. Coordinating these tasks often requires choosing the right functions, configuring parameters, and determining the sequence of operations.

In this demonstration, you’ll learn how to build a portfolio optimization agent using MATLAB® AI Agent SDK to automate these workflows.

The example shows how to create an AI agent that runs locally through Ollama™. You’ll see how to provide the agent with MATLAB functions as tools and use a system prompt to guide its behavior as a portfolio management expert.

Once configured, the agent can interpret natural language requests, determine which MATLAB tools to use, and set the required parameters. For example, when asked to “build a diversified portfolio with the best risk-adjusted return,” the agent recognizes that the objective is to maximize the Sharpe ratio and selects the appropriate MATLAB tools to perform the analysis.

You’ll also see how to follow the agent’s execution through the MATLAB Command Window, including the tools it calls and the parameters it uses.

The workflow produces a portfolio summary, asset allocation, historical performance results, and visualizations generated by MATLAB.

Discover how MATLAB AI Agent SDK can help streamline portfolio analysis by combining natural language interaction with existing MATLAB financial modeling and optimization capabilities.

Published: 16 Oct 2026

Related Products