[ENH] Add CVXCLA backend integration for faster performance and interactive Plotly support#700
[ENH] Add CVXCLA backend integration for faster performance and interactive Plotly support#700ayushraj09 wants to merge 4 commits intoPyPortfolio:mainfrom
Conversation
- Fix CLA algorithm TypeError with numpy arrays in _compute_w and _compute_lambda - Fix deprecated pandas squeeze parameter in examples.py - Add interactive Plotly plotting support to efficient frontier - Add missing dependencies (packaging, plotly) to pyproject.toml - Add uv.lock to .gitignore for cleaner repo management
- Fix remaining TypeError in _compute_w and _compute_lambda methods - All CLA tests now pass (12/12) including short selling scenarios - Tested with modern NumPy versions >= 1.26.0
|
Honestly, the cla algorithm in this package is extremely slow. You better replace it with a modern implementation, as given in https://github.com/cvxgrp/cvxcla |
|
For a benchmark comparison, see https://github.com/tschm/eqd/blob/main/PresentationEQD.pdf |
|
Can you please check the url for benchmark comparison? |
…ctions for showfig parameter. Fixed test files for depreciation issues.
|
It's a link into a pdf document. A presentation I gave 2 years ago. Slide 5 or so, contains the benchmark |
SummaryThis PR integrates Performance EnhancementCVXCLA Backend Integration
Usage# Before (original implementation)
cla = CLA(expected_returns, cov_matrix)
# After (high-performance backend)
cla = CLA(expected_returns, cov_matrix, use_cvxcla=True)Technical ImplementationBackend Architecture
Enhanced Plotting System
Testing & ValidationComprehensive Test Coverage
Performance Verification# Both backends produce identical results
Original: Expected return: 29.9%, Volatility: 21.8%, Sharpe: 1.38
CVXCLA: Expected return: 29.9%, Volatility: 21.8%, Sharpe: 1.38Dependencies & CompatibilityNew Dependencies
Compatibility Fixes
Files ChangedCore Implementation
|
|
@tschm Thanks for the benchmark comparison which I found in your github: https://github.com/tschm/eqd_markowitz/blob/main/PresentationEQDweb.pdf (corrected url i was asking for :-|) Please review the current PR with changes that add cvxcla integration. |
|
Interesting that you keep both implementations of the cla algorithm in the package. I would remove the previous implementation and point to the cvxvla repo where both implementations are present. Less code is better than more code. Glad you kept the original API so cvxcla is an easy replacement |
|
@tschm Is any there anything else that needs to be done for merging this PR? |
|
@ayushraj09 Many thanks for those contributions. I have no write access to the repo. I would recommend imho to replace the existing cla implementation rather than accumulating code |
Summary
Fixes NumPy and Pandas compatibility issues and adds optional interactive Plotly support for efficient frontier plotting. Fully backward compatible.
Fixes
TypeErrorin CLA (_compute_w,_compute_lambda) using safe.item()extraction.squeeze=Trueinpd.read_csv()with.squeeze().Enhancements
interactive=Trueoption toplot_efficient_frontier()for Plotly-based interactive plots.Dependencies
plotlypackaginguv.lockTesting