-
-
Save anthonymorast/a5a10e8b831026ccea4f9ac466e2920b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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