☰
Login
Signup
Home
›
dinezh
›
Activity
Activity
Discussions
Comments
24
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
dinezh
Best Python function to calculate RSI def calc_RSI(series, period=14): delta = series.diff().dropna() ups = delta * 0 downs = ups.copy() ups[delta > 0] = delta[delta > 0] downs[delta < 0] = -delta[delta < 0] ups[ups.index[period-1]] = np.mean( ups[:period] )
#first
value is sum of avg gains ups = ups.drop(ups.index[:(period-1)]) downs[downs.index[period-1]] = np.mean( downs[:period] )
#first
value is sum of avg losses downs = downs.drop(downs.index[:(period-1)]) rs = ups.ewm(com=period-1,min_periods=0,adjust=False,ignore_na=False).mean() / \ downs.ewm(com=period-1,min_periods=0,adjust=False,ignore_na=False).mean() return 100 - 100 / (1 + rs)
About
Username
dinezh
Joined
June 2020
Visits
34
Last Active
November 29
Roles
Member
Activity
Discussions
Comments
24
Activity
Not much happening here, yet.