Returns estimators API

CAPMReturns

class
skportfolio.riskreturn._returns_estimators.CAPMReturns(returns_data=False, frequency=252, risk_free_rate=0.0, benchmark=None)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CompoundedHistoricalLinearReturns

class
skportfolio.riskreturn._returns_estimators.CompoundedHistoricalLinearReturns(returns_data=False, frequency=252, returns_function=None)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

CompoundedHistoricalLogReturns

class
skportfolio.riskreturn._returns_estimators.CompoundedHistoricalLogReturns(returns_data=False, frequency=252, returns_function=None)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

EMAHistoricalReturns

class
skportfolio.riskreturn._returns_estimators.EMAHistoricalReturns(returns_data=False, frequency=252, span=180)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

MeanHistoricalLinearReturns

class
skportfolio.riskreturn._returns_estimators.MeanHistoricalLinearReturns(returns_data=False, frequency=252, returns_function=None)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

MeanHistoricalLogReturns

class
skportfolio.riskreturn._returns_estimators.MeanHistoricalLogReturns(returns_data=False, frequency=252, returns_function=None)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

MedianHistoricalLinearReturns

class
skportfolio.riskreturn._returns_estimators.MedianHistoricalLinearReturns(returns_data=False, frequency=252, returns_function=None)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

MedianHistoricalLogReturns

class
skportfolio.riskreturn._returns_estimators.MedianHistoricalLogReturns(returns_data=False, frequency=252, returns_function=None)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.

RollingMedianReturns

class
skportfolio.riskreturn._returns_estimators.RollingMedianReturns(returns_data=False, frequency=252, window=20)
Bases
skportfolio.riskreturn._returns_estimators.BaseReturnsEstimator sklearn.base.TransformerMixin sklearn.base.BaseEstimator

Base class for return estimator. It provides the basic infrastructure for all estimators of expected returns. It either can take price data or returns data, by specifying the returns_data=False or True respectively. The returns calculation is done with the standard .pct_change() of Pandas, unless otherwise specified by specification of the returns_function callable.

Methods
  • fit_transform(X, y, **fit_params) (X_new : ndarray array of shape (n_samples, n_features_new)) Fit to data, then transform it.
  • get_params(deep) (params : dict) Get parameters for this estimator.
  • set_params(**params) (self : estimator instance) Set the parameters of this estimator.
method
get_params(deep=True)

Get parameters for this estimator.

Parameters
  • deep (bool, default=True) If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns (params : dict)

Parameter names mapped to their values.

method
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as :class:~sklearn.pipeline.Pipeline). The latter have parameters of the form <component>__<parameter> so that it's possible to update each component of a nested object.

Parameters
  • **params (dict) Estimator parameters.
Returns (self : estimator instance)

Estimator instance.

method
fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
  • X (array-like of shape (n_samples, n_features)) Input samples.
  • y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) Target values (None for unsupervised transformations).
  • **fit_params (dict) Additional fit parameters.
Returns (X_new : ndarray array of shape (n_samples, n_features_new))

Transformed array.