Initial commit of simple moving average indicator

This commit is contained in:
moshferatu 2024-12-04 11:21:28 -08:00
parent d630f45471
commit 33143ac261

7
indicators/sma.py Normal file
View File

@ -0,0 +1,7 @@
from pandas import DataFrame, Series
def sma(data: DataFrame, period: int = 200) -> Series:
"""
Calculate the simple moving average and return it as a Series.
"""
return data['Close'].rolling(window = period).mean().fillna(0)