Slope and Linear Regression
||Iterable[Quote]||Iterable(such as list or an object having
• Need help with pandas.DataFrame?
||int||Number of periods (
Historical quotes requirements
You must have at least
N periods of
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.
- This method returns a time series of all available indicator values for the
SlopeResultsis just a list of
- 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-1periods will have
slopesince there’s not enough data to calculate.
Repaint Warning: the
linewill be continuously repainted since it is based on the last quote and lookback period.
||float, Optional||Standard Deviation of Close price over
||float, Optional||R-Squared (R²), aka Coefficient of Determination|
||Decimal, Optional||Best-fit line
See Utilities and Helpers for more information.
from stock_indicators import indicators # This method is NOT a part of the library. quotes = get_history_from_feed("SPY") # calculate 20-period Slope results = indicators.get_slope(quotes, 20)
About Slope and Linear Regression
Slope of the best fit line is determined by an ordinary least-squares simple linear regression on Close price. It can be used to help identify trend strength and direction. Standard Deviation, R², and a best-fit
Line (for last lookback segment) are also output. See also Standard Deviation Channels for an alternative depiction.