Online (streaming) portfolio construction: scikit-learn / skfolio-compatible estimators over a keyed dynamic universe
Project description
allocation
Online (streaming) portfolio construction. A home for portfolio methods as
scikit-learn / skfolio-compatible estimators
(fit / partial_fit / predict / weights_), on top of a keyed
dynamic-universe layer so they survive reconstituting universes.
from allocation import ThurstonePortfolio
est = ThurstonePortfolio(calib="market", phi=1.0)
est.fit(returns) # returns: (n_obs, n_assets)
est.weights_ # long-only weights on the simplex
for batch in stream: # streaming / rebalancing
est.partial_fit(batch) # transports a fixed seed ensemble -> low turnover
w = est.weights_
score(X) returns the portfolio's Sharpe ratio (skfolio's scoring convention),
and to_portfolio(X) wraps the fitted weights as a skfolio Portfolio
(pip install allocation[skfolio]) so the output drops into skfolio's metrics,
Population, and cross-validation.
Why a separate package
skfolio is the scikit-learn-native portfolio library, but it is batch: a
changing universe is handled by NaN/incomplete-data mechanics, not by carrying
per-asset state across streaming updates. allocation is the online
complement — estimators with partial_fit, a keyed dynamic universe (in the
spirit of precise), and turnover
control by construction — while staying API-compatible so each estimator can also
be contributed upstream to skfolio.
Methods
| Estimator | Status | Notes |
|---|---|---|
ThurstonePortfolio |
working | Ability tilt: weights are winning probabilities of a correlated race; calibrate to a benchmark under a reference correlation, tilt under the estimate; smooth common-seed transport for partial_fit. Built on thurstone. |
SchurComplementary |
planned | Online version of the Schur-complementary construction (the batch version is in skfolio). |
| baselines | planned | Online equal / cap / minimum-variance / risk-parity for benchmarking. |
Design
allocation/
base.py # BaseOnlinePortfolio: fit / partial_fit / predict / weights_
moments.py # EwmaCovariance (default); any partial_fit/covariance_ estimator plugs in
universe.py # keyed dynamic-universe state (planned)
thurstone.py # ThurstonePortfolio
_thurstone/ # calibration + transport engine
Covariance is pluggable: the default is a light EWMA, but any online estimator
exposing partial_fit and covariance_ (e.g. a precise skater) can be passed
via covariance=.
Status
Early. The Thurstone estimator and the streaming transport work and are tested; the keyed dynamic-universe layer and the Schur estimator are next. The theory behind the Thurstone method (feasibility, redundancy consistency, the implied regularized objective, smoothness/turnover) is written up in the accompanying paper.
License
MIT © Peter Cotton
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 Distribution
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 allocation-0.0.1.tar.gz.
File metadata
- Download URL: allocation-0.0.1.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16615b8919ba8fe3e8c8122d8f802a536ab9311962f1fc3234f424d41629a9ad
|
|
| MD5 |
92fa2820894f5fdf3e1ad6f62d8f9c16
|
|
| BLAKE2b-256 |
58a395d23511e5808e06493dbed9bf96bb0383352a23681ff7ece07b4370e97b
|
File details
Details for the file allocation-0.0.1-py3-none-any.whl.
File metadata
- Download URL: allocation-0.0.1-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c02aaefca230210fa0ea41fc7025a1a878417b68c0b2c7bef5b04c9a8f9ee3ba
|
|
| MD5 |
70a8562e842f29ea071f8278d31ef3c3
|
|
| BLAKE2b-256 |
df2f3206f3549dd2a636281b6d5debc90199fabdbb3cf24b8a999a164a8c8e28
|