Code
import pandas as pd
def SMA(array, n):
"""Simple moving average"""
return pd.Series(array).rolling(n).mean()
def RSI(array, n):
"""Relative strength index"""
# Approximate; good enough
= pd.Series(array).diff()
gain = gain.copy()
loss < 0] = 0
gain[gain > 0] = 0
loss[loss = gain.ewm(n).mean() / loss.abs().ewm(n).mean()
rs return 100 - 100 / (1 + rs)