Artificial Intelligence, Machine Learning, Random Forest, Finance, Trading.
calculate_sma(data, window): return data.rolling(window=window).mean() def calculate_macd(data, short_window=12, long_window=26, signal_window=9): short_ema = data.ewm(span=short_window, adjust=False).mean() long_ema = data.ewm(span=long_window, adjust=False).mean() macd = short_ema - long_ema