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

# skfolio.descriptor.EarningsChangeToPrice

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

### *class* skfolio.descriptor.EarningsChangeToPrice(lag=252)

Lagged earnings change divided by current market capitalization.

Computes the change in trailing twelve-month net income over a fixed lag, divided by
current market capitalization:

$$
\text{earnings\_change\_to\_price}(t) =
\frac{\text{net\_income\_ttm}(t) - \text{net\_income\_ttm}(t - \text{lag})}
     {\text{market\_cap}(t)}
$$

The first `lag` observations are NaN because no lagged history is available.

NaNs are allowed as missing observations and propagate when the current, lagged or
market-cap value is missing. Non-missing `net_income_ttm` values must be finite.
Non-missing `market_cap` values must be finite and strictly positive.

This descriptor captures earnings momentum: whether a firm’s profitability is
improving or deteriorating relative to its market value [[1]](#r342023be1f9e-1). A positive value
indicates earnings improvement and a negative value indicates deterioration.

Unlike [`GrowthRate`](https://skfolio.org/generated/skfolio.descriptor.GrowthRate.html.md#skfolio.descriptor.GrowthRate), which computes `x(t) / x(t-lag) - 1`, this formulation
is well-defined when earnings are negative. A standard growth rate with a negative
base produces sign-inverted rankings, making it unsuitable for earnings. By
normalizing the level change with market capitalization, the sign of the output
reflects the direction of change.

This is a convenience subclass of [`ChangeToScale`](https://skfolio.org/generated/skfolio.descriptor.ChangeToScale.html.md#skfolio.descriptor.ChangeToScale) with
`field="net_income_ttm"` and `scale_field="market_cap"`.

This descriptor uses aggregate quantities (net income and market capitalization).
The per-share equivalent is:

$$
\frac{\text{eps\_ttm}(t) - \text{eps\_ttm}(t - \text{lag})}
     {\text{adj\_close}(t)}
$$

The aggregate form is preferred for consistency with the other value descriptors
and to avoid split-adjustment mismatches.

* **Parameters:**
  **lag** *int, default=252*
  : Number of observations to look back. The interpretation depends on the data
    frequency: `lag=12` means 1 year for monthly data, `lag=252` for daily data,
    `lag=4` for quarterly data.
* **Attributes:**
  **n_assets_** *int*
  : Number of assets seen during fitting.

  **asset_names_** *ndarray of shape (n_assets,)*
  : Asset names seen during fitting.

  **change_to_scale_** *ndarray of shape (n_assets,)*
  : Last earnings change to price value for each asset.

### Methods

| [`fit_transform`](#skfolio.descriptor.EarningsChangeToPrice.fit_transform)(X[, y])         | Compute changes in level normalized by current scale.   |
|--------------------------------------------------------------------------------|---------------------------------------------------------|
| [`get_metadata_routing`](#skfolio.descriptor.EarningsChangeToPrice.get_metadata_routing)()        | Get metadata routing of this object.                    |
| [`get_params`](#skfolio.descriptor.EarningsChangeToPrice.get_params)([deep])            | Get parameters for this estimator.                      |
| [`partial_fit_transform`](#skfolio.descriptor.EarningsChangeToPrice.partial_fit_transform)(X[, y]) | Compute changes in level normalized by current scale.   |
| [`set_params`](#skfolio.descriptor.EarningsChangeToPrice.set_params)(\*\*params)        | Set the parameters of this estimator.                   |

#### SEE ALSO
[`ChangeToScale`](https://skfolio.org/generated/skfolio.descriptor.ChangeToScale.html.md#skfolio.descriptor.ChangeToScale)
: Generic change-to-scale descriptor.

[`GrowthRate`](https://skfolio.org/generated/skfolio.descriptor.GrowthRate.html.md#skfolio.descriptor.GrowthRate)
: Simple growth rate for positive-definite characteristics.

[`EarningsToPrice`](https://skfolio.org/generated/skfolio.descriptor.EarningsToPrice.html.md#skfolio.descriptor.EarningsToPrice)
: Level of trailing earnings to price (value signal).

### References

* <a id='r342023be1f9e-1'>**[1]**</a> Fama, E. F., & French, K. R. (2006). “Profitability, investment and average returns.” *Journal of Financial Economics*, 82(3), 491-518.

### Examples

```pycon
>>> from skfolio.datasets import make_synthetic_characteristics
>>> from skfolio.descriptor import EarningsChangeToPrice
>>>
>>> X = make_synthetic_characteristics()
>>>
>>> descriptor = EarningsChangeToPrice(lag=252)
>>> earnings_change_to_price = descriptor.fit_transform(X)
```

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

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

Compute changes in level normalized by current scale.

* **Parameters:**
  **X** *AssetPanel*
  : Input panel containing the `field` and `scale_field` characteristics
    configured at construction.

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

  **\*\*fit_params** *dict*
  : Additional fit parameters. Ignored.
* **Returns:**
  **change_to_scale** *ndarray of shape (n_observations, n_assets)*
  : Change in `field` over the lag window, divided by current `scale_field`
    for each observation and asset.

<a id="skfolio.descriptor.EarningsChangeToPrice.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.EarningsChangeToPrice.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.EarningsChangeToPrice.partial_fit_transform"></a>

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

Compute changes in level normalized by current scale.

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 the `field` and `scale_field` fields configured at
    construction.

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

  **\*\*fit_params** *dict*
  : Additional fit parameters. Ignored.
* **Returns:**
  **change_to_scale** *ndarray of shape (n_observations, n_assets)*
  : Change in `field` over the lag window, divided by current `scale_field`
    for each observation and asset.

<a id="skfolio.descriptor.EarningsChangeToPrice.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.

