Ledge Python binding
Package name on install: ledge-portfolio (import name: ledge).
It exposes Ledge's factor mean-variance solver to NumPy (float64 only) and
releases the GIL while solving. This is an alpha binding; the release
workflow builds abi3 wheels for the supported platforms.
Each distribution includes the Apache-2.0 project license and the generated
Rust dependency notices in THIRD_PARTY_LICENSES.html.
Registry install after the 0.2.0 artifacts are published:
python -m pip install ledge-portfolio==0.2.0
From the repository root:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip maturin
python -m pip install -e python/
python python/examples/rebalance.py
python -m pytest python/tests
For binding development:
cd python
maturin develop
python examples/rebalance.py
Primary API:
from ledge import PortfolioProblem, solve_mean_variance_factor
PortfolioProblem.solve(warm_start=previous_weights) re-solves a single
problem. For rolling multi-date rebalances, prefer
PortfolioProblem.sequence(): the returned PortfolioSequence caches the
equilibration and reduced factorizations across dates and chains full
primal/dual warm starts automatically — each date is one
sequence.solve_next(expected_returns=..., previous_weights=..., benchmark_weights=..., budget=..., equality_rhs=..., inequality_rhs=...)
call (all arguments optional; only factorization-preserving updates are
accepted). See examples/rolling.py and the full
backtest in
../docs/examples/rolling_backtest.py.
For many accounts sharing one model, ledge.solve_batch(problems, steps, chain_previous_weights=..., **solver_kwargs) runs one sequence per account
in parallel over the account axis (the GIL is released for the whole
batch); steps is one list of per-date dicts per account whose keys mirror
the solve_next keyword arguments, and chain_previous_weights=True
anchors each date's turnover at the previous solved date's weights, the
usual backtest convention.
SolveResult reports weights, status, objective, KKT residuals,
iterations, solve time, and adaptive-penalty diagnostics. Infeasible
problems stop early with status 'primal infeasible' (or
'dual infeasible' for unbounded objectives): by default a RuntimeError
names the conflicting portfolio constraints; pass raise_on_failure=False
to inspect SolveResult.certificate, an independently checkable Farkas
combination (or descent direction).
Turnover control around previous_weights: turnover_penalty is a smooth
L2 penalty; l1_turnover_costs (a scalar broadcast to all assets, or a
per-asset array) is exact proportional transaction cost with a genuine
no-trade region, handled by a dedicated proximal block. Both may be
combined. benchmark_weights switches the risk term to active risk
(w - b)' Sigma (w - b) against a tracking benchmark.
Migrating an existing cvxpy rebalance? See
../docs/cvxpy_migration.md — every mapping
in it is executed against cvxpy + Clarabel by
tests/test_migration_guide.py.
See the root README for scope, limitations, and smoke timings.
Metadata
Release files for ledge-portfolio 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ledge_portfolio-0.2.0.tar.gz | 164.8 kB | With provenance | Details for ledge_portfolio-0.2.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| ledge_portfolio-0.2.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for ledge_portfolio-0.2.0-cp39-abi3-win_amd64.whl |
| ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
| ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
| ledge_portfolio-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64 | Details for ledge_portfolio-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
Total release size: 2.9 MB
Release files / ledge_portfolio-0.2.0.tar.gz
| Download URL | ledge_portfolio-0.2.0.tar.gz |
|---|---|
| Size | 164.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a317d721d6c658f3071a2841931fa6ff35dcb62c955d533dc4710f5ead6cad64
|
|
BLAKE2b-256 checksum How to use checksums |
a1458b3c75f2b9c57371aa0c95bfa9a2d02bdc57a5913d60bc3020ce97e99838
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / ledge_portfolio-0.2.0-cp39-abi3-win_amd64.whl
| Download URL | ledge_portfolio-0.2.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 482.0 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cbf5a82eeffd95708ff6c2c9003af18bc1565992d145bb2d9152296dcaddf0eb
|
|
BLAKE2b-256 checksum How to use checksums |
421dd9f697d4801ce383a3c3cc1cdf6f57e8ca8adba0e61f6cacb10eab4d033a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 606.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
244c7c6680e6f01433516369a54b850a415b805284f044f247b2b92536d42c4d
|
|
BLAKE2b-256 checksum How to use checksums |
9cbde3b1c585e237ef154a36ad5979745260366f14ee9707a21e5ae4e14c8c5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 578.7 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
566a2071c35358035805593a12fe6cd57d0053702df0c2279eb79ff125371900
|
|
BLAKE2b-256 checksum How to use checksums |
58595d103e7af72f9d87c20b65d7380bb6ca2510b95f643da267c7a70a8a1d9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / ledge_portfolio-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | ledge_portfolio-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6795594b6bd0aa9ba3209a904ecd5d96f0d553a210a60854ba9f0839b6d33ce8
|
|
BLAKE2b-256 checksum How to use checksums |
ed138c14962a38b484c27a4ffe6b508cda31b8885823c0ba650501a7f9434b6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logSecurity for ledge-portfolio 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for ledge_portfolio-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.