Skip to main content

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.

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

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):

pip install cython numpy setuptools
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)

Development

uv sync --all-groups
PYTHONPATH=src pytest tests/     # 246 tests
mkdocs serve                     # documentation

Relationship to MATLAB MFE Toolbox

This package ports bashtage/mfe-toolbox 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).

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.0.tar.gz (322.9 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.0-py3-none-any.whl (147.5 kB view details)

Uploaded Python 3

File details

Details for the file mfe_toolbox-0.1.0.tar.gz.

File metadata

  • Download URL: mfe_toolbox-0.1.0.tar.gz
  • Upload date:
  • Size: 322.9 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.0.tar.gz
Algorithm Hash digest
SHA256 a98d02bacca40228f6d6c7495207c1815de76fa6692c293d56a07a6f558467f8
MD5 0b3871ba6fa82c6f32475292d2f8bcb9
BLAKE2b-256 c7da799771c1deb8ba754441190acd7cb91b9e3d87bd5e1e643de8c93ae774a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for mfe_toolbox-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: mfe_toolbox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 147.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ce785ffd48ee3842fac14081b123e02da64ac60741db4f65a935d743135ac78
MD5 0b3bb6d565ab9f14d6e9cbb1e998659e
BLAKE2b-256 73810fae082176684eb7c94ad23bb9519a9efda8536c9094189aa3bef5ee6788

See more details on using hashes here.

Provenance

The following attestation bundles were made for mfe_toolbox-0.1.0-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

0.1.2

2 files

This release

0.1.0 This release

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