Factor-structured mean-variance portfolio optimization
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ledge_portfolio-0.2.0.tar.gz.
File metadata
- Download URL: ledge_portfolio-0.2.0.tar.gz
- Upload date:
- Size: 164.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a317d721d6c658f3071a2841931fa6ff35dcb62c955d533dc4710f5ead6cad64
|
|
| MD5 |
18c4d8f593c032f4715054afa366df60
|
|
| BLAKE2b-256 |
a1458b3c75f2b9c57371aa0c95bfa9a2d02bdc57a5913d60bc3020ce97e99838
|
Provenance
The following attestation bundles were made for ledge_portfolio-0.2.0.tar.gz:
Publisher:
release.yml on Jiangki/ledge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ledge_portfolio-0.2.0.tar.gz -
Subject digest:
a317d721d6c658f3071a2841931fa6ff35dcb62c955d533dc4710f5ead6cad64 - Sigstore transparency entry: 2226120298
- Sigstore integration time:
-
Permalink:
Jiangki/ledge@ef47fd0927368df9ecbb9d550775df8831d84102 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Jiangki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef47fd0927368df9ecbb9d550775df8831d84102 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ledge_portfolio-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: ledge_portfolio-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 482.0 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbf5a82eeffd95708ff6c2c9003af18bc1565992d145bb2d9152296dcaddf0eb
|
|
| MD5 |
abb1c0a1558d42a0d8040ee161b5ea55
|
|
| BLAKE2b-256 |
421dd9f697d4801ce383a3c3cc1cdf6f57e8ca8adba0e61f6cacb10eab4d033a
|
Provenance
The following attestation bundles were made for ledge_portfolio-0.2.0-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on Jiangki/ledge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ledge_portfolio-0.2.0-cp39-abi3-win_amd64.whl -
Subject digest:
cbf5a82eeffd95708ff6c2c9003af18bc1565992d145bb2d9152296dcaddf0eb - Sigstore transparency entry: 2226121571
- Sigstore integration time:
-
Permalink:
Jiangki/ledge@ef47fd0927368df9ecbb9d550775df8831d84102 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Jiangki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef47fd0927368df9ecbb9d550775df8831d84102 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 606.0 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
244c7c6680e6f01433516369a54b850a415b805284f044f247b2b92536d42c4d
|
|
| MD5 |
84af8a646d62243427ac2ba191d4e84d
|
|
| BLAKE2b-256 |
9cbde3b1c585e237ef154a36ad5979745260366f14ee9707a21e5ae4e14c8c5b
|
Provenance
The following attestation bundles were made for ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on Jiangki/ledge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
244c7c6680e6f01433516369a54b850a415b805284f044f247b2b92536d42c4d - Sigstore transparency entry: 2226121910
- Sigstore integration time:
-
Permalink:
Jiangki/ledge@ef47fd0927368df9ecbb9d550775df8831d84102 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Jiangki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef47fd0927368df9ecbb9d550775df8831d84102 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 578.7 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
566a2071c35358035805593a12fe6cd57d0053702df0c2279eb79ff125371900
|
|
| MD5 |
4cbfd34cfbdf39ef06e4fe435e33a0f4
|
|
| BLAKE2b-256 |
58595d103e7af72f9d87c20b65d7380bb6ca2510b95f643da267c7a70a8a1d9a
|
Provenance
The following attestation bundles were made for ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on Jiangki/ledge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ledge_portfolio-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
566a2071c35358035805593a12fe6cd57d0053702df0c2279eb79ff125371900 - Sigstore transparency entry: 2226120899
- Sigstore integration time:
-
Permalink:
Jiangki/ledge@ef47fd0927368df9ecbb9d550775df8831d84102 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Jiangki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef47fd0927368df9ecbb9d550775df8831d84102 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ledge_portfolio-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: ledge_portfolio-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6795594b6bd0aa9ba3209a904ecd5d96f0d553a210a60854ba9f0839b6d33ce8
|
|
| MD5 |
c857f368f0fe0ac706d61a67343caadb
|
|
| BLAKE2b-256 |
ed138c14962a38b484c27a4ffe6b508cda31b8885823c0ba650501a7f9434b6d
|
Provenance
The following attestation bundles were made for ledge_portfolio-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on Jiangki/ledge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ledge_portfolio-0.2.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
6795594b6bd0aa9ba3209a904ecd5d96f0d553a210a60854ba9f0839b6d33ce8 - Sigstore transparency entry: 2226120605
- Sigstore integration time:
-
Permalink:
Jiangki/ledge@ef47fd0927368df9ecbb9d550775df8831d84102 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Jiangki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef47fd0927368df9ecbb9d550775df8831d84102 -
Trigger Event:
workflow_dispatch
-
Statement type: