A quantitative finance client needed portfolio rebalancing fast enough to run in production. The existing Python implementation was too slow, and the math needed to accommodate additional risk constraints. I redesigned the problem formulation as a Second-Order Cone Program (a class of convex optimization problem that solvers can handle efficiently and reliably), built a high-performance library in Rust, and made it callable from Python.
Highlights
- Extended classical Markowitz mean-variance optimization by reformulating novel soft constraint penalty functions as Second-Order Cone Programs (SOCP) to maintain convexity and computational efficiency while enabling nuanced risk control.
- Built a custom Rust optimization library leveraging the Clarabel.rs solver, achieving a 50× performance improvement over the existing Python implementation (from ~5 ms to ~100 μs per solve).
- Designed Python bindings using PyO3/maturin supporting both NumPy arrays and Polars DataFrames, with careful attention to memory lifetime constraints across language boundaries.
- Conducted solver stability analysis using decision tree classification on thousands of optimization runs to identify critical equilibration scaling parameters that eliminated convergence failures.
- Worked closely with a mathematically sophisticated client to translate complex financial portfolio requirements into implementable algorithms.
Technology
- Rust
- Clarabel.rs (SOCP solver)
- PyO3 / maturin (Python bindings)
- Python
- NumPy / Polars
- Quadratic programming / SOCP
- scikit-learn (decision tree analysis)