It depends on the scale and the structure of the optimization problem.
For research, prototyping, and many production systems, CVXPY is an excellent modeling layer because it lets you express optimization problems clearly and switch between different solvers. However, at sufficiently large scale (thousands of assets, intraday rebalancing, many scenarios, or very low latency requirements), many firms move beyond a generic modeling framework.
A typical progression looks like this:
| Scale | Common approach |
|---|
| Research | CVXPY + OSQP, ECOS, SCS, Clarabel |
| Daily production | CVXPY with commercial solvers (Gurobi, MOSEK, CPLEX) |
| Large institutional | Custom QP/LP solvers or specialized optimization engines |
| HFT / ultra-low latency | Hand-optimized algorithms, incremental updates, custom C++ implementations |
When CVXPY is enough
A standard mean-variance problem
[
\min_x \frac{1}{2}x^T\Sigma x-\mu^Tx
]
with constraints like
- long-only
- leverage
- sector limits
- factor neutrality
- turnover limits
is straightforward in CVXPY and often solves quickly for portfolios with hundreds or a few thousand assets.
The advantage is maintainability: adding a new constraint usually takes a few lines.
When custom solvers become attractive
Large managers may optimize:
- 10,000–100,000 securities
- hundreds of factor constraints
- millions of historical scenarios
- repeated optimizations every few seconds
The bottlenecks become:
- matrix construction
- factorization
- repeated solves
- memory bandwidth
Instead of rebuilding the optimization each time, custom systems exploit:
- sparse matrices
- low-rank covariance models
- warm starts
- cached matrix factorizations
- parallel linear algebra
- GPU acceleration (for some workloads)
Often the optimization algorithm itself is fairly standard (interior point, ADMM, active set), but the implementation is highly specialized.
Transaction costs
Modern portfolio optimizers almost always include transaction costs directly in the objective.
A common formulation is
[
\min_x
\underbrace{\frac{\lambda}{2}x^T\Sigma x}_{risk}
\underbrace{\mu^Tx}{expected\ return}
+
\underbrace{C(x-x_0)}{trading\ cost}
]
where
- (x_0) is current holdings
- (x) is desired holdings
Linear costs
These model commissions or fees:
[
c\sum_i |x_i-x_{0,i}|
]
This is convex and easy for modern solvers.
Market impact
Many models use convex approximations such as
[
k|q|^{1.5}
]
or
[
aq+bq^2
]
where
- (q) is trade size
- larger trades become disproportionately expensive.
Turnover constraints
Instead of penalizing turnover, some managers constrain it directly:
[
\sum_i |x_i-x_{0,i}| \le T
]
This is extremely common.
Risk constraints
The covariance matrix is only one piece.
Professional optimizers usually constrain multiple dimensions of risk.
Examples include:
Volatility
[
x^T\Sigma x \le \sigma_{\max}^2
]
Tracking error
Relative to a benchmark
[
(x-b)^T\Sigma(x-b)\le TE^2
]
Factor exposures
Examples:
- market beta
- value
- momentum
- size
- quality
Constraint:
[
Fx=0
]
or
[
|Fx|\le c
]
Sector limits
For example,
- technology ≤ 25%
- healthcare ≥ 8%
These become linear constraints.
Position limits
Examples:
- max 2% per stock
- min 0%
- max leverage 1.2×
Simple bound constraints.
Liquidity constraints
Prevent trading more than a fraction of average daily volume (ADV):
[
|trade_i| \le 0.1\times ADV_i
]
Concentration constraints
Examples:
- top-10 holdings ≤ 40%
- Herfindahl index limits
- issuer exposure limits
Factor-model optimization
A major scalability improvement is replacing the full covariance matrix with a factor model:
[
\Sigma = BFB^T + D
]
where
- (B): factor loadings
- (F): factor covariance
- (D): idiosyncratic variance
Instead of inverting an (N \times N) covariance matrix, the optimization operates with a much smaller factor covariance matrix when the number of factors is far less than the number of assets. This reduces computational cost and memory usage substantially while capturing the dominant sources of risk.
Solver choices
Different problem structures favor different solvers:
- OSQP: large sparse quadratic programs; widely used for convex portfolio optimization with linear constraints.
- Clarabel: modern interior-point solver supporting quadratic and conic problems.
- MOSEK: high-performance commercial solver, especially strong for conic optimization.
- Gurobi: excellent for quadratic, linear, and mixed-integer formulations; often chosen when discrete decisions (such as minimum lot sizes or cardinality constraints) are involved.
- Custom ADMM / proximal methods: useful when repeatedly solving similar problems at very large scale.
What large asset managers often do
Many quantitative investment firms and asset managers use a hybrid architecture:
- A high-level modeling layer (sometimes CVXPY during research, sometimes an internal domain-specific language).
- A factor-model representation of risk to reduce problem size.
- Convex formulations that incorporate expected returns, transaction costs, and operational constraints.
- Commercial or specialized in-house solvers with warm starts and incremental updates for production workloads.
This approach balances flexibility for researchers with the performance needed to optimize large portfolios on a regular schedule or in response to market events.