Portfolio Optimization
The Portfolio Optimization module builds portfolios from the tickers of a Toolkit: minimum variance, maximum Sharpe ratio, mean-variance, risk parity, Hierarchical Risk Parity, minimum CVaR and Black-Litterman weights, the efficient frontier, risk contributions, stress tests and attribution.
Every function of the Portfolio Optimization module has its own page showing how to use it with the MCP and in Python. Pick one from the sidebar on the left.Every function of the Portfolio Optimization module has its own page showing how to use it with the MCP and in Python. Pick one from the .
Use it in Claude, ChatGPT or another AI assistant through the Finance Toolkit MCP, or install the Python package:
pip install financetoolkit -U
Getting Started
When the Toolkit comes from a Portfolio (Portfolio.toolkit), the methods that take weights use the Portfolio’s latest weights by default.
The Portfolio Optimization module is reached through a Toolkit instance, as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "JNJ", "XOM"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.portfolio.get_risk_parity_weights()
The sidebar gives access to every metric in the Portfolio Optimization module, each on its own page showing how to use it with the MCP and in Python. Pick one there to open it.The sidebar gives access to every metric in the Portfolio Optimization module, each on its own page showing how to use it with the MCP and in Python. On a phone, open the to pick one.