contango.stream.indicators.calculations.ema
contango.stream.indicators.calculations.ema
EMA
EMA(pd: days)
Bases: Indicator[float | None]
Exponential Moving Average.
Uses alpha = 2 / (period + 1) and seeds the first value directly from the first price to avoid bias (towards 0).
Initializes Ema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
days
|
Lookback period to derive the smoothing factor. Larger values -> slower to react to price changes. |
required |
Source code in src\contango\stream\indicators\calculations\ema.py
18 19 20 21 22 23 24 25 26 27 | |
value
property
value: float | None
Returns the latest value for the EMA.
update
update(event: MarketDataEvent) -> float
Takes in a new price and returns the current EMA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
MarketDataEvent
|
The current market data event. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The current EMA. The first call returns |
Source code in src\contango\stream\indicators\calculations\ema.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |