Detrended Price Oscillator (DPO)
get_dpo(quotes, lookback_periods)
Parameters
name | type | notes |
---|---|---|
quotes | Iterable[Quote] | Iterable of the Quote class or its sub-class. • See here for usage with pandas.DataFrame |
lookback_periods | int | Number of periods (N ) in the moving average. Must be greater than 0. |
Historical quotes requirements
You must have at least N
historical quotes to cover the warmup periods.
quotes
is an Iterable[Quote]
collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.
Return
DPOResults[DPOResult]
- This method returns a time series of all available indicator values for the
quotes
provided. DPOResults
is just a list ofDPOResult
.- It always returns the same number of elements as there are in the historical quotes.
- It does not return a single incremental indicator value.
- The first
N/2-2
and lastN/2+1
periods will beNone
since they cannot be calculated.
DPOResult
name | type | notes |
---|---|---|
date | datetime | Date |
sma | float, Optional | Simple moving average offset by N/2+1 periods |
dpo | float, Optional | Detrended Price Oscillator (DPO) |
Utilities
See Utilities and Helpers for more information.
Example
from stock_indicators import indicators
# This method is NOT a part of the library.
quotes = get_historical_quotes("SPY")
# Calculate
results = indicators.get_dpo(quotes, 14)
About Detrended Price Oscillator (DPO)
Detrended Price Oscillator depicts the difference between price and an offset simple moving average. It is used to identify trend cycles and duration. [Discuss] 💬