Skip to content

Instantly share code, notes, and snippets.

Created Aug 17, 2021
What would you like to do?
def get_sma(data, period):
return data.rolling(window=period).mean() # moving average using panda's rolling
def get_bollinger_bands(data, sma, periods):
std = data.rolling(window=periods).std()
upper = sma + std * 2 # add 2 standard deviations (upper band)
lower = sma - std * 2 # substract 2 standard deviations (lower band)
return upper, lower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment