Force Index
get_force_index(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 | Lookback window (N ) for the EMA of Force Index. Must be greater than 0 and is commonly 2 or 13 (shorter/longer view). |
Historical quotes requirements
You must have at least N+100
for 2×N
periods of quotes
, whichever is more, to cover the convergence periods. Since this uses a smoothing technique for EMA, we recommend you use at least N+250
data points prior to the intended usage date for better precision.
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
ForceIndexResults[ForceIndexResult]
- This method returns a time series of all available indicator values for the
quotes
provided. ForceIndexResults
is just a list ofForceIndexResult
.- 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
periods for will beNone
since they cannot be calculated.
⚞ Convergence warning: The first
N+100
periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods.
ForceIndexResult
name | type | notes |
---|---|---|
date | datetime | Date |
force_index | float, Optional | Force Index |
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 ForceIndex(13)
results = indicators.get_force_index(quotes, 13)
About Force Index
Created by Alexander Elder, the Force Index depicts volume-based buying and selling pressure. [Discuss] 💬