The data parameter is the input data that can be either a pandas DataFrame or a pandas DataFrameGroupBy object. It contains the data on which the Bollinger Bands will be calculated.
required
date_column
str
The date_column parameter is a string that specifies the name of the column in the data DataFrame that contains the dates.
required
close_column
str
The close_column parameter is a string that specifies the name of the column in the data DataFrame that contains the closing prices of the asset.
required
periods
Union[int, Tuple[int, int], List[int]]
The periods parameter in the augment_bbands function can be specified as an integer, a tuple, or a list. This parameter specifies the number of rolling periods to use when calculating the Bollinger Bands.
20
std_dev
float
The std_dev parameter is a float that represents the number of standard deviations to use when calculating the Bollinger Bands. Bollinger Bands are a technical analysis tool that consists of a middle band (usually a simple moving average) and an upper and lower band that are typically two standard deviations away from the middle band. The std_dev parameter specifies the number of standard deviations. std_dev can be a list of floats as well.
2
reduce_memory
bool
The reduce_memory parameter is a boolean flag that indicates whether or not to reduce the memory usage of the input data before performing the calculation. If set to True, the function will attempt to reduce the memory usage of the input data using techniques such as downcasting numeric columns and converting object columns
False
engine
str
The engine parameter specifies the computation engine to use for calculating the Bollinger Bands. It can take two values: ‘pandas’ or ‘polars’. If ‘pandas’ is selected, the function will use the pandas library for computation. If ‘polars’ is selected,
'pandas'
Returns
Type
Description
pd.DataFrame
The function augment_bbands returns a pandas DataFrame.
Notes
Bollinger Bands are a technical analysis tool developed by John Bollinger in the 1980s. They are used to measure the ‘volatility’ of a stock price or other financial instrument. This indicator consists of three lines which are plotted in relation to an asset’s price:
The Middle Band: This is typically a simple moving average (SMA) of the closing prices over a certain number of days (commonly 20 days).
The Upper Band: This is set a specified number of standard deviations (usually two) above the middle band.
The Lower Band: This is set the same number of standard deviations (again, usually two) below the middle band.
Volatility Indicator: The width of the bands is a measure of volatility. When the bands widen, it indicates increased volatility, and when they contract, it suggests decreased volatility.
Overbought and Oversold Conditions: Prices are considered overbought near the upper band and oversold near the lower band. However, these conditions do not necessarily signal a reversal; prices can remain overbought or oversold for extended periods during strong trends.
Examples
import pandas as pdimport pytimetk as tkdf = tk.load_dataset("stocks_daily", parse_dates = ['date'])df