I am new to pandas. What is the best way to calculate the relative strength part in the RSI indicator in pandas? So far I got the following:
from pylab impor
def RSI(series): delta = series.diff() u = delta * 0 d = u.copy() i_pos = delta > 0 i_neg = delta < 0 u[i_pos] = delta[i_pos] d[i_neg] = delta[i_neg] rs = moments.ewma(u, span=27) / moments.ewma(d, span=27) return 100 - 100 / (1 + rs)