-
Notifications
You must be signed in to change notification settings - Fork 2
/
sma.py
30 lines (21 loc) · 915 Bytes
/
sma.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
""" SMA Indicator
"""
import math
import pandas
from talib import abstract
from analyzers.utils import IndicatorUtils
class SMA(IndicatorUtils):
def analyze(self, historical_data, period_count=15):
"""Performs a SMA analysis on the historical data
Args:
historical_data (list): A matrix of historical OHCLV data.
period_count (int, optional): Defaults to 15. The number of data points to consider for
our simple moving average.
Returns:
pandas.DataFrame: A dataframe containing the indicators and hot/cold values.
"""
dataframe = self.convert_to_dataframe(historical_data)
sma_values = abstract.SMA(dataframe, period_count).to_frame()
sma_values.dropna(how='all', inplace=True)
sma_values.rename(columns={0: 'sma'}, inplace=True)
return sma_values