Skip to main content

mfe — Financial Econometrics for Python

PyPI version Python Downloads Downloads/month License: MIT Docs

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

mfe_toolbox-0.1.2.tar.gz (325.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mfe_toolbox-0.1.2-py3-none-any.whl (148.1 kB view details)

Uploaded Python 3

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

Hashes for mfe_toolbox-0.1.2.tar.gz
Algorithm Hash digest
SHA256 eab0cac5c1fd1f6f35d5d8d72b1f730cc3be27259d71a2aba5d68989b0d61818
MD5 7cd43b4acc1fd6ce2033f119a3db74bc
BLAKE2b-256 c936c1233634b2eabcea2e45eb360ad5b7e5a522eaab39e92ff62ad7e30d506b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mfe_toolbox-0.1.2.tar.gz:

Publisher: publish.yml on GabinTB/mfe-toolbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mfe_toolbox-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 66a311178fe5cf8a66760498979a23a0cbec10157fb4998a565d5b90a9cdca12
MD5 962661d68d91bc7c68741c765996ec87
BLAKE2b-256 c25317be94a48792cc41dfea614d14bfcefad4baa2b35cc3806b54ec4eeb23a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mfe_toolbox-0.1.2-py3-none-any.whl:

Publisher: publish.yml on GabinTB/mfe-toolbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page