Skip to main content

donchian

Calculate the Donchian Channels.

Three lines generated by moving average calculations that comprise an indicator formed by upper and lower bands around a midrange or median band. The upper band marks the highest price of a security over N periods while the lower band marks the lowest price of a security over N periods. The area between the upper and lower bands represents the Donchian Channel.

Examples

from openbb import obb
# Get the Donchian Channels.
stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')
donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)
obb.technical.donchian(lower_length=1, upper_length=3, data='[{'date': '2023-01-02', 'open': 110.0, 'high': 120.0, 'low': 100.0, 'close': 115.0, 'volume': 10000.0}, {'date': '2023-01-03', 'open': 165.0, 'high': 180.0, 'low': 150.0, 'close': 172.5, 'volume': 15000.0}, {'date': '2023-01-04', 'open': 146.67, 'high': 160.0, 'low': 133.33, 'close': 153.33, 'volume': 13333.33}, {'date': '2023-01-05', 'open': 137.5, 'high': 150.0, 'low': 125.0, 'close': 143.75, 'volume': 12500.0}, {'date': '2023-01-06', 'open': 132.0, 'high': 144.0, 'low': 120.0, 'close': 138.0, 'volume': 12000.0}]')

Parameters

data: list[openbb_core.provider.abstract.data.Data]

list of data to be used for the calculation.

Optional: False


index: str

Index column name to use with data, by default 'date'.

Default: date

Optional: True


lower_length: int

Number of periods for the lower band, by default 20.

Default: 20

Optional: True


upper_length: int

Number of periods for the upper band, by default 20.

Default: 20

Optional: True


offset: int

Offset of the Donchian Channel, by default 0.

Optional: True


Returns

results: list[Data]

Serializable results.


provider: None

Provider name.


warnings: Optional[list[Warning_]]

list of warnings.


chart: Optional[Chart]

Chart object.


extra: dict[str, Any]

Extra info.