portfolio · cvxpy · mcp
Optimization Engine
Multi-asset portfolio optimization engine — mean-variance, risk parity, HRP, Black-Litterman, CVaR — packaged on PyPI, with a Streamlit UI, CLI, and MCP server.
Overview
A multi-asset portfolio optimization engine with a clean Python API, a Streamlit UI, a CLI, and an MCP server so agents can call it as tools. Published on PyPI as finport-optengine — one pip install away. Built on cvxpy, scipy, pandas, and scikit-learn, with the UI, data providers, MCP server, and regression support behind optional extras.
The engine is opinionated about one thing: an allocation is not a result until you can see what it rests on. Every solve returns the weights and the evidence — which solver answered, whether the constraints held, how well-conditioned the covariance estimate was, how concentrated the book is in risk rather than capital, and how much of the backtest survives out of sample.
Install
pip install finport-optengine # core engine + CLI
pip install "finport-optengine[mcp]" # + MCP server (optengine-mcp)
pip install "finport-optengine[all]" # everything for the worked examples
What it does
- Mean-variance, global min variance, max Sharpe, risk parity / ERC, HRP, Black-Litterman, mean-CVaR, max diversification, inverse volatility, equal weight.
- Per-asset weight bounds, group / asset-class bounds, target return / target volatility / risk-aversion utility.
- Long-only or leveraged, with optional turnover budgets vs. previous weights.
- Diagnostics on every solve: solver used, constraint compliance, covariance conditioning, risk concentration, out-of-sample decay.
- MCP server (
optengine-mcp) speaks the Model Context Protocol over stdio, so agents call the engine as tools instead of writing code. - Pre-trade checks: a point-in-time universe, shock-based stress scenarios, and a mandate audit that can refuse a non-compliant book.
- Honest failures: an inaccurate solve raises instead of returning a degraded answer, and a solver crash is never passed off as an impossible mandate.
- Streamlit UI for non-coders; CLI for batch runs.
Stack
Python · cvxpy · scipy · pandas · scikit-learn · plotly · Streamlit · MCP. UI, data providers (yfinance / Parquet), the MCP server, and regression live behind optional extras.
Status
On PyPI as finport-optengine (v0.7.0). Open source, 1,307 tests, with type checking and a Windows cell in CI. Agents can call it over MCP.