Factor selection with MFOCI
mfoci is a Python package designed for financial analysts and researchers who need to retrieve and analyze stock market data.
This package implements the MFOCI algorithm for factor selection in financial data. Supported are also LASSO and k-FOCI factor selection methods as well as data retrieval from Fama-French and Yahoo Finance.
Installation
Install mfoci using pip:
pip install mfoci
Quick Usage
from mfoci import get_fama_french_data, load_stock_returns
from mfoci import select_factors
# Fetch data
tickers = ["MSFT", "AAPL", "NVDA", "AMZN", "META", "GOOG"]
response_vars = load_stock_returns(tickers, start_date="2013-01-02", end_date="2024-01-01")
factors = get_fama_french_data("2013-01-03", end_date="2024-01-01")
# MFOCI factor selection
mfoci_selected, t_values = select_factors(factors, response_vars, "mfoci")
Further usage
from mfoci import get_fama_french_data, load_stock_returns, load_volatility_index
from mfoci import filter_for_common_indices, select_factors
# Fetch Fama-French factors
factors = get_fama_french_data("2004-01-01", end_date="2024-01-01")
# Load stock returns for specific tickers
tickers = ["MSFT", "AAPL", "NVDA", "AMZN", "META", "GOOG"]
response_vars = load_stock_returns(tickers, start_date="2013-01-01", end_date="2024-01-01")
# Load VIX data
response_vars = load_volatility_index("^VIX", start_date="2004-01-01", end_date="2024-01-01")
# Filter for common dates
factors, response_vars = filter_for_common_indices(factors, response_vars)
# Factor selection using LASSO
lasso_selected, coef = select_factors(factors, response_vars, "lasso")
# KFOCI factor selection (ensure Rscript is installed and path is set)
r_path = "C:/Program Files/R/R-4.3.3/bin/x64/Rscript"
kfoci_gauss_selected = select_factors(
factors, response_vars, "kfoci", r_path=r_path, kernel="rbfdot"
)
kfoci_laplace_selected = select_factors(
factors, response_vars, "kfoci", r_path=r_path, kernel="laplacedot"
)
# MFOCI factor selection
mfoci_selected, t_values = select_factors(factors, response_vars, "mfoci")
Metadata
Release files for mfoci 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mfoci-0.2.4.tar.gz | 15.3 kB | Without provenance | Details for mfoci-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mfoci-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for mfoci-0.2.4-py3-none-any.whl |
Total release size: 32.7 kB
Release files / mfoci-0.2.4.tar.gz
| Download URL | mfoci-0.2.4.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3a2a70e01bc07cc7f5ed8a081daab44abae624867d26f0ac738760dfa28babb
|
|
BLAKE2b-256 checksum How to use checksums |
3af711e73b355577bb7bb1c9ee0e862fd7a8e90eeb9bb2fb88c4b2998497516a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / mfoci-0.2.4-py3-none-any.whl
| Download URL | mfoci-0.2.4-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0321484d2d74359e0bc954572a53aeed84c29be5f8a4e6c282c94f3f11d8f052
|
|
BLAKE2b-256 checksum How to use checksums |
052ce8004e695553c872394493a25f14ae5e7103f8bdcbcb3a4d654a788667b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for mfoci 0.2.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.