<a id="skfolio-descriptor-maxreturn"></a>

# skfolio.descriptor.MaxReturn

<a id="skfolio.descriptor.MaxReturn"></a>

### *class* skfolio.descriptor.MaxReturn(window=21)

Maximum return over a trailing window.

Computes the maximum return over the last `window` observations:

$$
\text{MAX}(t) = \max_{k \in [t-w+1,\, t]} \; r_k
$$

where $w$ is the `window` size. 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 `returns` values must be finite.

Stocks with high MAX are found to earn lower subsequent returns, consistent with
investor overpricing of lottery-like payoffs [[1]](#rad7917c3d156-1).

* **Parameters:**
  **window** *int, 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]](#rad7917c3d156-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`](#skfolio.descriptor.MaxReturn.fit_transform)(X[, y])         | Compute rolling maximum returns over the configured window.   |
|--------------------------------------------------------------------------------|---------------------------------------------------------------|
| [`get_metadata_routing`](#skfolio.descriptor.MaxReturn.get_metadata_routing)()        | Get metadata routing of this object.                          |
| [`get_params`](#skfolio.descriptor.MaxReturn.get_params)([deep])            | Get parameters for this estimator.                            |
| [`partial_fit_transform`](#skfolio.descriptor.MaxReturn.partial_fit_transform)(X[, y]) | Update state and return rolling max return for this batch.    |
| [`set_params`](#skfolio.descriptor.MaxReturn.set_params)(\*\*params)        | Set the parameters of this estimator.                         |

### References

* <a id='rad7917c3d156-1'>**[1]**</a> “Maxing out: stocks as lotteries and the cross-section of expected returns” Journal of Financial Economics. Bali, Cakici & Whitelaw (2011).

### Examples

```pycon
>>> 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)
```

<a id="skfolio.descriptor.MaxReturn.fit_transform"></a>

#### fit_transform(X, y=None, \*\*fit_params)

Compute rolling maximum returns over the configured window.

* **Parameters:**
  **X** *AssetPanel*
  : Input panel containing `returns`.

  **y** *None*
  : Ignored. Present for compatibility with scikit-learn’s API.

  **\*\*fit_params** *dict*
  : Additional fit parameters. Ignored.
* **Returns:**
  **max_return** *ndarray of shape (n_observations, n_assets)*
  : Rolling maximum return for each observation and asset.

<a id="skfolio.descriptor.MaxReturn.get_metadata_routing"></a>

#### get_metadata_routing()

Get metadata routing of this object.

Please check [User Guide](https://skfolio.org/user_guide/metadata_routing.html.md#metadata-routing) on how the routing
mechanism works.

* **Returns:**
  **routing** *MetadataRequest*
  : A `MetadataRequest` encapsulating
    routing information.

<a id="skfolio.descriptor.MaxReturn.get_params"></a>

#### 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.

<a id="skfolio.descriptor.MaxReturn.partial_fit_transform"></a>

#### partial_fit_transform(X, y=None, \*\*fit_params)

Update state and return rolling max return for this batch.

This method supports online updates by continuing from the current fitted state.
Use `fit_transform` to start from a clean state.

* **Parameters:**
  **X** *AssetPanel*
  : Input panel containing `"returns"`.

  **y** *None*
  : Ignored. Present for compatibility with scikit-learn’s API.

  **\*\*fit_params** *dict*
  : Additional fit parameters. Ignored.
* **Returns:**
  **max_return** *ndarray of shape (n_observations, n_assets)*
  : Rolling maximum return for each observation and asset.

<a id="skfolio.descriptor.MaxReturn.set_params"></a>

#### 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:**
  **\*\*params** *dict*
  : Estimator parameters.
* **Returns:**
  **self** *estimator instance*
  : Estimator instance.

