Skip to content

Instantly share code, notes, and snippets.

@jsrimr
Created September 6, 2019 04:53
Show Gist options
  • Save jsrimr/d39012e19ee582bc54b0e45a2015179a to your computer and use it in GitHub Desktop.
Save jsrimr/d39012e19ee582bc54b0e45a2015179a to your computer and use it in GitHub Desktop.
def get_bollinger_diffs(df, n=20, k=2):
ma_n = df['c'].rolling(n).mean()
Bol_upper = df['c'].rolling(n).mean() + k* df['c'].rolling(n).std()
Bol_lower = df['c'].rolling(n).mean() - k* df['c'].rolling(n).std()
return (Bol_upper - Bol_lower).mean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment