Python bindings for the mlfinance AFML toolkit
Project description
pymlfinance
Python bindings for mlfinance — a Rust implementation of concepts from Advances in Financial Machine Learning by Marcos López de Prado.
Installation
pip install pymlfinance
With Polars plugin support:
pip install pymlfinance[polars]
Quick Start
import numpy as np
import pymlfinance as ml
# EWMA smoothing
prices = np.array([100.0, 101.5, 99.8, 102.3, 101.0])
smoothed = ml.core.ewma(prices, 3)
# CUSUM event filter
events = ml.data.cusum_filter(prices, 1.5)
# Triple-barrier labeling
from pymlfinance import TripleBarrierConfig
config = TripleBarrierConfig(upper_barrier=0.02, lower_barrier=0.02, max_holding_period=10)
# Fractional differentiation
stationary = ml.sampling.frac_diff_ffd(prices, 0.5, 1e-4)
# HRP portfolio allocation
returns = np.random.randn(100, 5) * 0.02
weights = ml.features.hrp_weights(returns)
# Sharpe ratio
ret = np.random.randn(252) * 0.01
sr = ml.backtesting.sharpe_ratio(ret)
Modules
| Module | Description |
|---|---|
pymlfinance.core |
EWMA, cumsum, returns, matrix utilities |
pymlfinance.data |
Bar generation (tick, volume, dollar, information-driven), CUSUM filter |
pymlfinance.labeling |
Triple-barrier, meta-labeling, trend-scanning |
pymlfinance.sampling |
Sequential bootstrapping, sample weights, fractional differentiation |
pymlfinance.features |
Structural breaks, entropy, microstructure, HRP, denoising |
pymlfinance.modeling |
Bet sizing, cross-validation, feature importance |
pymlfinance.backtesting |
Backtest statistics, overfitting detection, strategy risk |
Polars Plugin
import polars as pl
import pymlfinance # registers .ml namespace
df = pl.DataFrame({"price": [100.0, 101.5, 99.8, 102.3, 101.0]})
df.with_columns(pl.col("price").ml.ewma(span=3).alias("smoothed"))
Documentation
Disclaimer
This software is provided for educational and research purposes only. It does not constitute financial advice. Use of this code for trading or investment decisions is entirely at your own risk. The authors accept no liability for any financial losses incurred.
License
BUSL-1.1 — see LICENSE.
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 pymlfinance-0.1.1.tar.gz.
File metadata
- Download URL: pymlfinance-0.1.1.tar.gz
- Upload date:
- Size: 11.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e66b25e3141683ff9dd9f89eadeb5dbb6d62c1a8906bdfbe9faf9c12628438c9
|
|
| MD5 |
f202bb5f5236e8812a5a9f16c129b468
|
|
| BLAKE2b-256 |
63e20778a321659debb9cc4abdc9eea50e4c1813e475ce870ed8daf561efb64f
|
File details
Details for the file pymlfinance-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: PyPy, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f538399a988b11228de9f67fae0ed2ab0a1ed47eece72c2c5e04cea7615c94a
|
|
| MD5 |
87c4ec66678342370d3ccf83195d04ef
|
|
| BLAKE2b-256 |
49424582a7daa0fdabe52ca46313093895c3d1d3c81954df0faeca8c18b6d3d2
|
File details
Details for the file pymlfinance-0.1.1-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57387b048abb3566f3e6864af5fcbe2edd8f22ac9c39865c924782241f0cc6cb
|
|
| MD5 |
44df6a7ba9d224a643e9638cf116d57d
|
|
| BLAKE2b-256 |
796ac36c4469b4d679b896e1b08147eb6958bc742e35f366b6fed99fed2fd4a2
|
File details
Details for the file pymlfinance-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.14t, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67b0c26fca4b8a31aa35060f5bffc88e90db7e1ecd940513f2edb9c0bb574e17
|
|
| MD5 |
1eb6984e02ad8ae57af59adaf89ab572
|
|
| BLAKE2b-256 |
41b266193a5118cac2a21ba46a2fb066780f307a05063e9cfd1da4424529b85d
|
File details
Details for the file pymlfinance-0.1.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b374ecbcf1dac281d1e90d61299459e97c7e83de610b6881e71066c4dc6326cf
|
|
| MD5 |
0b5edc19d5f074cb589f10c51863b125
|
|
| BLAKE2b-256 |
b020e0ccc43a82022cb587c3abaaa900da5a2a6616e2f955fe64fe7d9f8571d6
|
File details
Details for the file pymlfinance-0.1.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.14, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddcf801fd443187bda1791f80a8952bcdb96fb1d6d976d009a82532a326d85c4
|
|
| MD5 |
0ae4ade2ff8c084a28b45e0167fab60d
|
|
| BLAKE2b-256 |
27b1fcb63b9ab9fdb45f326188abc08cb9054a641dfeeda1f46cf847df08851a
|
File details
Details for the file pymlfinance-0.1.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.13t, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06146d6b8d251fb81fb0aaef8495fc85c18bd8345c03160bb196a6bd9bab0749
|
|
| MD5 |
3e76bbb5e629b9acb1492bdbe7b756d5
|
|
| BLAKE2b-256 |
5eed450a228603e374bab63c5e5f6b6b3d9220b47ab1852ced416751fbbab9e8
|
File details
Details for the file pymlfinance-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da0c6024250ff19013d255e6024490d5b0e216733f37ed150277d244c8e03fdb
|
|
| MD5 |
4c2b5f26d278bfd0f67c72ed6fbe6da6
|
|
| BLAKE2b-256 |
88572e8dcea8f6074fe122161c01002c2d4336efed914a98e259b170351172ac
|
File details
Details for the file pymlfinance-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f821da19973ddadece7a20376de9c02f96f58d716af82a0ae98ab995d498f0f
|
|
| MD5 |
df5672bfd991c4a8d8c372583b1fdffa
|
|
| BLAKE2b-256 |
6d23b2898dfbd5cd3c396b2a316dc6b7a08c9b597b0e0370ebd06460499bc260
|
File details
Details for the file pymlfinance-0.1.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ecbea0e8cd12759966467325522954157b8e82fa4785719c22131d3a2b72ed9
|
|
| MD5 |
63b14a5c2f605c95a17b551933a9c3a4
|
|
| BLAKE2b-256 |
ddf5ba438071da1a49a8dd8500be96b8002ceb2f2850f82ad6ae97e0f90e2a6e
|
File details
Details for the file pymlfinance-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85206ddb06a9bdc1e4ed0af20693148286ffc2575264e329b92a154d20c47c26
|
|
| MD5 |
fd843f793d76048439b4f31f9131dccf
|
|
| BLAKE2b-256 |
ac0fda92ac26ea82611efb83b57923beb14ad82f8186c377863a001fc1b26a2b
|
File details
Details for the file pymlfinance-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b564498c4bc72c3b540848a442368506374c14678912451db3caa2b2aa8d257
|
|
| MD5 |
fb1490f30dd83f1c590249ed43c849f1
|
|
| BLAKE2b-256 |
8bd06f80ec219a90d6616f86bf6c2cfa74a05884a8eb009f8f7ea578147f9777
|
File details
Details for the file pymlfinance-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.8 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cd5e19e044a4b8507e1fff74ad8ea4cd906261656e480d3f406360a13508236
|
|
| MD5 |
45a58ddd43bfbeef9cc13d4410766d9a
|
|
| BLAKE2b-256 |
658936ee0c658badf3d23707a207873bef6de649da6c5792a149657b2104445e
|
File details
Details for the file pymlfinance-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffa4f2e4e34a4d5e5879df9cb777d9733b61d67f84dfade5d21923a9a2aa19ff
|
|
| MD5 |
4010d9c6a9ac169ecead0cd5ac8c81d4
|
|
| BLAKE2b-256 |
dd7a2a6e3eb1bfd8aa0bca88367a211152eae909ccafb2b77ce6a4ce7817a271
|
File details
Details for the file pymlfinance-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
267c4dba87167c6a6d26d766d864a0fc77a62cbc5da55628daadd0994eeb6053
|
|
| MD5 |
ec515f1d9e4a3d7e911b20a96ad953a9
|
|
| BLAKE2b-256 |
b6449a20fc8984b77e6a6a230b563e9614ba3d6ab83bd7eb0304fc99fb456cf6
|
File details
Details for the file pymlfinance-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df635f61455d35775ce320c07a6ca6548b253ef2607f9088d838fd1f20c2ebf8
|
|
| MD5 |
7c8aa81e023b22b41fc93f7e0c683ef2
|
|
| BLAKE2b-256 |
a8f3006a544e45e648575372bbd5fe065605cbc592b405d3b704469bf0a78bb4
|
File details
Details for the file pymlfinance-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5de200f9798e16a4959a2e5d1bf68ab2264a276bf8fba868204a47d80bac3970
|
|
| MD5 |
b44e2ae7aedb28688383d1a9ed4bfaa4
|
|
| BLAKE2b-256 |
e87f1920dffb7b8508d0f09fbb869f24f04707b1c5ca69bd755d6e6e27e0bafc
|
File details
Details for the file pymlfinance-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
313b779ae4220b6d006f45e39fb8d8ee29ebc657235d29232ba3ccbaec883216
|
|
| MD5 |
f0a4afc2e6d5df92b5c8b84951e5ceb8
|
|
| BLAKE2b-256 |
bb469fc8baf6f6570bf4365f35fb18e6cbadeb2fda6fe06b70ccdcd29f5329f2
|
File details
Details for the file pymlfinance-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a4aa0fb6700165e49fbf88e05b1e452384f324656f3e7968b03c2334931fc05
|
|
| MD5 |
6449d5e2cacef6a874c601a9f0c3ac98
|
|
| BLAKE2b-256 |
0f98bb309d7471eca3e466d73b4e8b291e92bcf3a47f6ca884bc1a593f13d58d
|
File details
Details for the file pymlfinance-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pymlfinance-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.3 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
573889e2193c7628c1a0447bfb7253f8008e413fc1b2e914b25538262b5f7c57
|
|
| MD5 |
7352e53ed9aea0fa47bf084ea8adc4a8
|
|
| BLAKE2b-256 |
09c3f15d7222b291a167103e17a00235eafc84d7170f83bb9776946fd3c1c041
|