skfolio.descriptor.MaxReturn#
- class skfolio.descriptor.MaxReturn(window=21)[source]#
Maximum return over a trailing window.
Computes the maximum return over the last
windowobservations:\[\text{MAX}(t) = \max_{k \in [t-w+1,\, t]} \; r_k\]where \(w\) is the
windowsize. High values identify assets with recent extreme positive returns, capturing lottery-like payoff that may attract speculative demand.The output is NaN until an asset has a full trailing window of active observations. NaN returns are allowed as missing observations and ignored when computing the maximum. If all returns in an active trailing window are missing, the output is NaN. Non-missing
returnsvalues must be finite.Stocks with high MAX are found to earn lower subsequent returns, consistent with investor overpricing of lottery-like payoffs [1].
- Parameters:
- windowint, default=21
Number of trailing observations for the rolling maximum. Must be greater than 1. The default of 21 corresponds to approximately one trading month, matching the original definition in [1].
- Attributes:
- n_assets_int
Number of assets seen during fitting.
- asset_names_ndarray of shape (n_assets,)
Asset names seen during fitting.
- max_return_ndarray of shape (n_assets,)
Last maximum return value for each asset.
Methods
fit_transform(X[, y])Compute rolling maximum returns over the configured window.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
partial_fit_transform(X[, y])Update state and return rolling max return for this batch.
set_params(**params)Set the parameters of this estimator.
References
Examples
>>> from skfolio.datasets import make_synthetic_characteristics >>> from skfolio.descriptor import MaxReturn >>> >>> X = make_synthetic_characteristics() >>> >>> # 1-month rolling max (default) >>> descriptor = MaxReturn() >>> max_ret = descriptor.fit_transform(X) >>> >>> # 1-week rolling max >>> descriptor = MaxReturn(window=5) >>> max_ret_5d = descriptor.fit_transform(X)
- fit_transform(X, y=None, **fit_params)[source]#
Compute rolling maximum returns over the configured window.
- Parameters:
- XAssetPanel
Input panel containing
returns.- yNone
Ignored. Present for compatibility with scikit-learn’s API.
- **fit_paramsdict
Additional fit parameters. Ignored.
- Returns:
- max_returnndarray of shape (n_observations, n_assets)
Rolling maximum return for each observation and asset.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- get_params(deep=True)#
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- partial_fit_transform(X, y=None, **fit_params)[source]#
Update state and return rolling max return for this batch.
This method supports online updates by continuing from the current fitted state. Use
fit_transformto start from a clean state.- Parameters:
- XAssetPanel
Input panel containing
"returns".- yNone
Ignored. Present for compatibility with scikit-learn’s API.
- **fit_paramsdict
Additional fit parameters. Ignored.
- Returns:
- max_returnndarray of shape (n_observations, n_assets)
Rolling maximum return for each observation and asset.
- set_params(**params)#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.