Skip to main content

No project description provided

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mfoci-0.1.6.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

mfoci-0.1.6-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file mfoci-0.1.6.tar.gz.

File metadata

  • Download URL: mfoci-0.1.6.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.1 Windows/11

File hashes

Hashes for mfoci-0.1.6.tar.gz
Algorithm Hash digest
SHA256 3ded3e112a7011d146998c6b25d4ce88d0053e6291474745c183babaa3fad888
MD5 f0b8afdc63060222dd1fe409597a4937
BLAKE2b-256 925cb68226d82e34a55df24f0f197eba39312e2e3c6c692d8e4f83f1cb1c5517

See more details on using hashes here.

File details

Details for the file mfoci-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: mfoci-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.1 Windows/11

File hashes

Hashes for mfoci-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d4a82ebde9a70849bde8eca856c43bb5fd0ba0062696c429e6f3e65698c3688c
MD5 3ddee140c00223a5245e9470b814ce3f
BLAKE2b-256 f02937973e6c99141060dc16548771fafb0d3f9c4bd9825bc287f78b7c1ad665

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page