Stochastic Momentum Index (SMI)
get_smi(quotes, lookback_periods, first_smooth_periods, second_smooth_periods, signal_periods=3)
Parameters
name | type | notes |
---|---|---|
quotes |
Iterable[Quote] | Iterable(such as list or an object having __iter__() ) of the Quote class or its sub-class. • Need help with pandas.DataFrame? |
lookback_periods |
int | Lookback period (N ) for the stochastic. Must be greater than 0. |
first_smooth_periods |
int | First smoothing factor lookback. Must be greater than 0. |
second_smooth_periods |
int | Second smoothing factor lookback. Must be greater than 0. |
signal_periods |
int, default 3 | EMA of SMI lookback periods. Must be greater than 0. |
Historical quotes requirements
You must have at least N+100
periods of quotes
to cover the convergence 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
SMIResults[SMIResult]
- This method returns a time series of all available indicator values for the
quotes
provided. -
SMIResults
is just a list ofSMIResult
. - 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-1
periods will haveNone
SMI values since there’s not enough data to calculate.
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.
SMIResult
name | type | notes |
---|---|---|
date |
datetime | Date |
smi |
float, Optional | Stochastic Momentum Index (SMI) |
signal |
float, Optional | Signal line: an Exponential Moving Average (EMA) of SMI |
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_history_from_feed("SPY")
# Calculate SMI(14,20,5,3)
results = indicators.get_smi(quotes, 14, 20, 5, 3)
About Stochastic Momentum Index (SMI)
Created by William Blau, the Stochastic Momentum Index (SMI) is a double-smoothed variant of the Stochastic Oscillator on a scale from -100 to 100.
[Discuss]