code: def relative_strength(prices, periods=14):
      
      deltas = np.diff(prices)
      seed = deltas[:periods + 1]
      up = seed[seed >= 0].sum() / periods
      down = -seed[seed < 0].sum() / periods
      ratio = up / down
      rsi = np.zeros_like(prices)
      rsi[:periods] = 100. - 100. / (1. + ratio)
  
      for i in range(periods, len(prices)):
          delta = deltas[i - 1]  # Cause the diff is 1 shorter
  
          if delta > 0:
              upval = delta
              downval = 0.
          else:
              upval = 0.
              downval = -delta
  
          up = (up * (periods - 1) + upval) / periods
          down = (down * (periods - 1) + downval) / periods
  
          ratio = up / down
          rsi[i] = 100. - 100. / (1. + ratio)
  
      return rsi
docs: compute the <periods> period relative strength indicator
      http://stockcharts.com/school/doku.php?\
          id=chart_school:glossary_r#relativestrengthindex
      http://www.investopedia.com/terms/r/rsi.asp