Initial commit of simple moving average indicator
This commit is contained in:
parent
d630f45471
commit
33143ac261
7
indicators/sma.py
Normal file
7
indicators/sma.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user