Financial market analysis tool implementing the MFOCI algorithm for factor selection
Project description
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")
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 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 mfoci-0.2.1.tar.gz.
File metadata
- Download URL: mfoci-0.2.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84e8822dc666d3a99578f12e90aa06181859fd31049a2ec74d0d1182d2e812cf
|
|
| MD5 |
fa163357dd0b67da85a515e41b42b571
|
|
| BLAKE2b-256 |
9721556e536b213fb604ff697343f6f8209971edcd5fd5e88a16d8a264a273ad
|
File details
Details for the file mfoci-0.2.1-py3-none-any.whl.
File metadata
- Download URL: mfoci-0.2.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
697e0f6e03388df3284a65d0158df6b92f9af38e9fceba910637675f63e39447
|
|
| MD5 |
37b3966a0a7ec6c737f636d39cc255f5
|
|
| BLAKE2b-256 |
0d00f73ec38cfcd77ea165bd6f8024bd9c9809ce3141f3257fbc67bc8fbaf5c4
|