Donchian Channels

get_donchian(quotes, lookback_periods=20)


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, default 20 Number of periods (N) for lookback period. Must be greater than 0 to calculate; however we suggest a larger value for an appropriate sample size.

Historical quotes requirements

You must have at least N+1 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.




name type notes
date datetime Date
upper_band Decimal, Optional Upper line is the highest High over N periods
center_line Decimal, Optional Simple average of Upper and Lower bands
lower_band Decimal, Optional Lower line is the lowest Low over N periods
width Decimal, Optional Width as percent of Centerline price. (upper_band-lower_band)/center_line


See Utilities and Helpers for more information.


from stock_indicators import indicators

# This method is NOT a part of the library.
quotes = get_historical_quotes("SPY")

# calculate Donchian(20)
results = indicators.get_donchian(quotes, 20)

About Donchian Channels

Created by Richard Donchian, Donchian Channels, also called Price Channels, are derived from highest High and lowest Low values over a lookback window. [Discuss] 💬