API Reference#
This is the class and function reference of skfolio
. Please refer to
the full user guide for further details, as the class and
function raw specifications may not be enough to give full guidelines on their
uses.
skfolio.measures
: Measures#
Module that includes all Measures functions used across skfolio
.
Base Classe#
Base Enum of measures |
Classes#
Enumeration of performance measures |
|
Enumeration of risk measures |
|
Enumeration of other risk measures not used in convex optimization |
|
Enumeration of ratio measures |
Functions#
|
Compute the mean. |
|
Compute the cumulative returns from the returns. |
|
Compute the drawdowns' series from the returns. |
|
Compute the variance (second moment). |
|
Compute the semi-variance (second lower partial moment). |
|
Compute the standard-deviation (square root of the second moment). |
|
Compute the semi standard-deviation (semi-deviation) (square root of the second lower partial moment). |
|
Compute the third central moment. |
|
Compute the Fourth central moment. |
|
Compute the fourth lower partial moment. |
|
Compute the historical CVaR (conditional value at risk). |
|
Compute the mean absolute deviation (MAD). |
|
Compute the historical value at risk (VaR). |
|
Compute the worst realization (worst return). |
|
Compute the first lower partial moment. |
|
Compute the entropic risk measure. |
|
Compute the EVaR (entropic value at risk) and its associated risk aversion. |
|
Compute the Drawdown at risk. |
|
Compute the historical CDaR (conditional drawdown at risk). |
|
Compute the maximum drawdown. |
|
Compute the average drawdown. |
|
Compute the EDaR (entropic drawdown at risk). |
|
Compute the Ulcer index. |
|
Compute the Gini mean difference (GMD). |
|
Compute the OWA weights used for the Gini mean difference (GMD) computation. |
|
Computes the effective number of assets, defined as the inverse of the Herfindahl index [R3692bcdb1be2-1]: |
skfolio.portfolio
: Portfolio#
Portfolio module.
Portfolio
and MultiPeriodPortfolio
objects are returned by the predict
method of
Optimization estimators.
They need to be homogenous to the convex optimization problems meaning that Portfolio
is the dot product of the assets weights with the assets returns and
MultiPeriodPortfolio
is a list of Portfolio
.
Base Classe#
Base Portfolio class for all portfolios in skfolio. |
Classes#
Portfolio class. |
|
Multi-Period Portfolio class. |
skfolio.population
: Population#
Classes#
Population Class. |
skfolio.optimization.naive
: Naive Optimization Estimators#
Classes#
Equally Weighted estimator. |
|
Inverse Volatility estimator. |
|
Random weight estimator. |
skfolio.optimization.convex
: Convex Optimization Estimators#
Enum#
Enumeration of objective functions. |
Classes#
Base class for all convex optimization estimators in skfolio. |
|
Mean-Risk Optimization estimator. |
|
Risk Budgeting Optimization estimator. |
|
Maximum Diversification Optimization estimator. |
|
Distributionally Robust CVaR. |
skfolio.optimization.cluster
: Clustering Optimization Estimators#
Classes#
Base Hierarchical Clustering Optimization estimator. |
|
Hierarchical Risk Parity estimator. |
|
Hierarchical Equal Risk Contribution estimator. |
|
Nested Clusters Optimization estimator. |
skfolio.optimization.ensemble
: Ensemble Optimization Estimators#
Classes#
Handles parameter management for ensemble estimators. |
|
Stack of optimizations with a final optimization. |
skfolio.prior
: Prior Estimators#
skfolio package
Model Dataclass#
Prior model dataclass. |
Base Class#
Base class for all prior estimators in skfolio. |
Classes#
Empirical Prior estimator. |
|
Black & Litterman Prior Model estimator. |
|
Factor Model estimator. |
Loading Matrix Classes for Factor Models#
Base class for all Loading Matrix estimators. |
|
Loading Matrix Regression estimator. |
skfolio.moments.mu
: Mu Estimators#
skfolio package
Base Class#
Base class for all expected returns estimators in skfolio. |
Classes#
Empirical Expected Returns (Mu) estimator. |
|
Exponentially Weighted Expected Returns (Mu) estimator. |
|
Shrinkage Expected Returns (Mu) estimator. |
|
Equilibrium Expected Returns (Mu) estimator. |
|
Shrinkage methods for the ShrunkMu estimator |
skfolio.moments.covariance
: Covariance Estimators#
skfolio package
Base Class#
Base class for all covariance estimators in |
Classes#
Empirical Covariance estimator. |
|
Exponentially Weighted Covariance estimator. |
|
Gerber Covariance estimator. |
|
Covariance Denoising estimator. |
|
Covariance Detoning estimator. |
|
LedoitWolf Covariance Estimator. |
|
Oracle Approximating Shrinkage Estimator as proposed in [Re9a22b087643-1]. |
|
Covariance estimator with shrinkage. |
|
Sparse inverse covariance with cross-validated choice of the l1 penalty. |
|
Implied Covariance estimator. |
skfolio.distance
: Distance Estimators#
skfolio package
Base Class#
Base class for all distance estimators in skfolio. |
Classes#
Pearson Distance estimator. |
|
Kendall Distance estimator. |
|
Spearman Distance estimator. |
|
Covariance Distance estimator. |
|
Distance Correlation estimator. |
|
Mutual Information estimator. |
skfolio.cluster
: Cluster Estimators#
skfolio package
Classes#
Hierarchical Clustering. |
|
Methods for calculating the distance between clusters in the linkage matrix. |
skfolio.uncertainty_set
: Uncertainty set Estimators#
skfolio package
Model Dataclass#
Ellipsoidal uncertainty set dataclass. |
Base Classes#
Base class for all Mu Uncertainty Set estimators in |
|
Base class for all Covariance Uncertainty Set estimators in |
Classes#
Empirical Mu Uncertainty Set. |
|
Empirical Covariance Uncertainty set. |
|
Bootstrap Mu Uncertainty set. |
|
Bootstrap Covariance Uncertainty set. |
skfolio.pre_selection
: Pre-selection Transformers#
skfolio package
Classes#
Transformer for dropping highly correlated assets. |
|
Transformer for selecting the |
|
Transformer for selecting non dominated assets. |
|
Transformer to select assets with complete data across the entire observation period. |
|
Transformer to select assets that do not expire within a specified lookahead period after the end of the observation period. |
skfolio.model_selection
: Model Selection#
skfolio package
Base Classes#
Base class for all combinatorial cross-validators. |
Classes#
Combinatorial Purged Cross-Validation. |
|
Walk Forward Cross-Validator. |
Functions#
|
Generate cross-validated |
|
Find the optimal number of folds (total folds and test folds) for a target training size and a target number of test paths. |
skfolio.metrics
: Metrics#
skfolio package
Functions#
|
Make a scorer from a measure or from a custom score function. |
skfolio.datasets
: Datasets#
Functions#
Load the prices of 20 assets from the S&P 500 Index composition. |
|
Load the prices of the S&P 500 Index. |
|
Load the prices of 5 factor ETFs. |
|
|
Load the prices of 64 assets from the FTSE 100 Index composition. |
|
Load the prices of 1455 assets from the NASDAQ Composite Index. |
skfolio.preprocessing
: Preprocessing#
Functions#
|
Transforms a DataFrame of prices to linear or logarithmic returns. |
skfolio.utils.stats
: Stats#
Functions#
|
Enumeration of the Number of Bins Methods |
Compute the optimal histogram bin size using the Freedman-Diaconis rule [R8d5b646da1d1-1]. |
|
Compute the optimal histogram bin size using Knuth's rule [R8c3fe88ee915-1]. |
|
Returns True if Cholesky decomposition can be computed. |
|
Raises an error if the matrix is not square. |
|
Raises an error if the matrix is not symmetric. |
|
Raises an error if the matrix is not a distance matrix. |
|
|
Compute the nearest covariance matrix that is positive definite and with a cholesky decomposition than can be computed. |
|
Convert a covariance matrix to a correlation matrix. |
|
Convert a correlation matrix to a covariance matrix given its standard-deviation vector. |
Compute the commutation matrix. |
|
|
Compute the optimal number of clusters based on Two-Order Difference to Gap Statistic [Re0e718a4c413-1]. |
|
Produces n random weights that sum to one from an uniform distribution (non-uniform distribution over a simplex) |
Produces n random weights that sum to one from a dirichlet distribution (uniform distribution over a simplex) |
|
Apply weight constraints to an initial array of weights by minimizing the relative weight deviation of the final weights from the initial weights. |