Returns estimators API¶
CAPMReturns¶
skportfolio.riskreturn._returns_estimators.
CAPMReturns
(
returns_data=False
, frequency=252
, risk_free_rate=0.0
, benchmark=None
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.
CompoundedHistoricalLinearReturns¶
skportfolio.riskreturn._returns_estimators.
CompoundedHistoricalLinearReturns
(
returns_data=False
, frequency=252
, returns_function=None
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.
CompoundedHistoricalLogReturns¶
skportfolio.riskreturn._returns_estimators.
CompoundedHistoricalLogReturns
(
returns_data=False
, frequency=252
, returns_function=None
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.
EMAHistoricalReturns¶
skportfolio.riskreturn._returns_estimators.
EMAHistoricalReturns
(
returns_data=False
, frequency=252
, span=180
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.
MeanHistoricalLinearReturns¶
skportfolio.riskreturn._returns_estimators.
MeanHistoricalLinearReturns
(
returns_data=False
, frequency=252
, returns_function=None
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.
MeanHistoricalLogReturns¶
skportfolio.riskreturn._returns_estimators.
MeanHistoricalLogReturns
(
returns_data=False
, frequency=252
, returns_function=None
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.
MedianHistoricalLinearReturns¶
skportfolio.riskreturn._returns_estimators.
MedianHistoricalLinearReturns
(
returns_data=False
, frequency=252
, returns_function=None
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.
MedianHistoricalLogReturns¶
skportfolio.riskreturn._returns_estimators.
MedianHistoricalLogReturns
(
returns_data=False
, frequency=252
, returns_function=None
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.
RollingMedianReturns¶
skportfolio.riskreturn._returns_estimators.
RollingMedianReturns
(
returns_data=False
, frequency=252
, window=20
)
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.
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.
get_params
(
deep=True
)
Get parameters for this estimator.
deep
(bool, default=True) — If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
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.
**params
(dict) — Estimator parameters.
Estimator instance.
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
.
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.
Transformed array.