mfe — Financial Econometrics for Python
Python port of Kevin Sheppard's Oxford MFE Toolbox, optimised for HFT data.
Complements arch — covering everything arch is missing.
Upstream: ported from
bashtage/mfe-toolbox— see the project homepage and MATLAB Central entry for the original MATLAB implementation by Kevin Sheppard (Oxford MFE).
Documentation
Full documentation at gabintb.github.io/mfe-toolbox, including:
What's inside
| Module | Contents |
|---|---|
mfe.realized |
RV, BPV, MedRV, realized kernel, TSRV, MSRV, Hayashi-Yoshida, multivariate kernel, BNS jump test |
mfe.multivariate |
DCC, CCC, BEKK, O-GARCH, GO-GARCH, RCC |
mfe.univariate |
HAR-RV (standard / MODIFIED / matrix intervals / HAR-J), HEAVY |
mfe.timeseries |
VAR (4 VCV options), Granger causality, IRF, Beveridge-Nelson |
mfe.bootstrap |
Wild bootstrap, SPA test (Hansen 2005), StepM (Romano-Wolf 2005) |
mfe.crosssection |
Fama-MacBeth, OLS/OLSNW, PCA |
mfe.tests_stat |
ARCH-LM, Ljung-Box, HAC LM, Diebold-Mariano, Mincer-Zarnowitz |
mfe.distributions |
Skew-t (analytic score), GED, multivariate normal log-likelihood |
Installation
pip install mfe-toolbox
Cython extensions (optional, recommended for production)
Cython compilation gives 10–800× speedups on hot paths (realized kernel inner loop, Hayashi-Yoshida sweep, DCC/BEKK recursions):
uv run python setup_cython.py build_ext --inplace
Quick start
from mfe.realized import price_filter, returns_from_prices, realized_kernel, bns_jump_test
from mfe.realized._types import SamplingType
prices_5m, times_5m = price_filter(
tick_prices, tick_times,
sampling_type=SamplingType.CALENDAR_TIME,
sampling_interval=300,
)
r = returns_from_prices(prices_5m)
rk = realized_kernel(r)
jmp = bns_jump_test(r)
from mfe.multivariate import DCC, RCC
dcc = DCC().fit(returns) # (T, K) → (T, K, K) sigma_t
rcc = RCC().fit(returns) # covariance targeting by construction
from mfe.univariate import HEAVY
heavy = HEAVY().fit(daily_returns, realized_variances)
Upstream
This package ports the Oxford MFE Toolbox
by Kevin Sheppard to Python, fixing several bugs present in the MATLAB source
(memory leaks, silent non-convergence, O(N²) algorithms replaced with
O(N log N) Cython implementations). See UPSTREAM.md for the
full list of files reviewed, intentional corrections, and deferred items.
Development
uv sync --all-groups
PYTHONPATH=src pytest tests/ # 246 tests
mkdocs serve # documentation
License
MIT
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 mfe_toolbox-0.1.2.tar.gz.
File metadata
- Download URL: mfe_toolbox-0.1.2.tar.gz
- Upload date:
- Size: 325.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eab0cac5c1fd1f6f35d5d8d72b1f730cc3be27259d71a2aba5d68989b0d61818
|
|
| MD5 |
7cd43b4acc1fd6ce2033f119a3db74bc
|
|
| BLAKE2b-256 |
c936c1233634b2eabcea2e45eb360ad5b7e5a522eaab39e92ff62ad7e30d506b
|
Provenance
The following attestation bundles were made for mfe_toolbox-0.1.2.tar.gz:
Publisher:
publish.yml on GabinTB/mfe-toolbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mfe_toolbox-0.1.2.tar.gz -
Subject digest:
eab0cac5c1fd1f6f35d5d8d72b1f730cc3be27259d71a2aba5d68989b0d61818 - Sigstore transparency entry: 2704513413
- Sigstore integration time:
-
Permalink:
GabinTB/mfe-toolbox@257292fddfc6a5ac6e5e9d70c35b688da892a102 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/GabinTB
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@257292fddfc6a5ac6e5e9d70c35b688da892a102 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mfe_toolbox-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mfe_toolbox-0.1.2-py3-none-any.whl
- Upload date:
- Size: 148.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66a311178fe5cf8a66760498979a23a0cbec10157fb4998a565d5b90a9cdca12
|
|
| MD5 |
962661d68d91bc7c68741c765996ec87
|
|
| BLAKE2b-256 |
c25317be94a48792cc41dfea614d14bfcefad4baa2b35cc3806b54ec4eeb23a8
|
Provenance
The following attestation bundles were made for mfe_toolbox-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on GabinTB/mfe-toolbox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mfe_toolbox-0.1.2-py3-none-any.whl -
Subject digest:
66a311178fe5cf8a66760498979a23a0cbec10157fb4998a565d5b90a9cdca12 - Sigstore transparency entry: 2704513449
- Sigstore integration time:
-
Permalink:
GabinTB/mfe-toolbox@257292fddfc6a5ac6e5e9d70c35b688da892a102 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/GabinTB
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@257292fddfc6a5ac6e5e9d70c35b688da892a102 -
Trigger Event:
push
-
Statement type: