The ModFin project aims to provide users with the necessary tools for modeling and analyzing individual assets and portfolios. This package contains various modules that provide a variety of useful functions and algorithms. Here is a table of the implemented modules:
Note: Modules to be fully implemented on live libraries.
- Analysis of Time Series
- Bet Sizing
- Data Structures
- Online Portfolio
- Option Pricing
ModFin requires Python 3.8 or later and C++ build tools.
If needed, you can install the C++ build tools on Visual Studio.
The project is available on PyPI, and can be installed with pip package manager with the following command:
$ pip install modfin
Alternatively, install the package from the source using the following command:
git clone https://github.com/GabrielAbra/modfin
python setup.py install
The AssetScreening
module offers functions for screening assets based on a predetermined set of metrics. One fundamental approach is to screen assets based on smart betas (Style factors), when a given a combination of traits, are likely to be of interest to a specific investor. The ready to use functions groups are:
This submodule provides bundles of functions that can be used to screen assets. Some of the metrics are:
-
- Beta, Downside Beta, Beta Quotient
- RSquaredScore
- LPM
- ...
-
- Annualized Return
- Exponencial Returns
- Log Returns
- ...
-
- Omega Ratio
- Sortino Ratio
- Tail Ratio
- ...
This submodule provides functions that can be used to screen assets. Some of the screening functions are:
The RiskMatrix
module provides multiple functions for analyzing time series data and generating risk matrices. There are three different types of algorithms that can be distinguished as:
-
- Covariance
- Semicovariance
-
- Empirical Covariance
- Minimum Covariance Determinant
-
- Shrinkage (Basic Shrinkage)
- LedoitWolf (Ledoit-Wolf Shrinkage Method)
- Oracle (Oracle Approximating Shrinkage)
The PortfolioOpt
module provides algorithms for optimization of an a asset portfolios. The algorithms live implemented algorithms are:
-
The
RiskParity
algorithm is a simple algorithm that optimizes a portfolio based on the risk parity weighting. -
The
HierarchicalRiskParity
(HRP) algorithm, implements the allocation based on the book:De Prado, Marcos Lopez. Advances in financial machine learning. John Wiley & Sons, 2018.
The algorithm is a risk based optimisation, which has been shown to generate diversified portfolios with robust out-of-sample properties.
-
The
InverseVariance
algorithm is a simple algorithm that optimizes a portfolio based on the provided risk matrix (usually the covariance matrix). -
The
EfficientFrontier
algorithm provide a portfolio allocation based on the modern portfolio theory (MPT). The algoritms was first proposed by Harry Markowitz in the paper:Markowitz, H.M.. Portfolio Selection. The Journal of Finance, 1952.
ModFin is released under the MIT license, so the code is open source and can be used in any project, provided that the original author is credited.