-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindicator_base.py
More file actions
28 lines (20 loc) · 836 Bytes
/
indicator_base.py
File metadata and controls
28 lines (20 loc) · 836 Bytes
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
from candle_builder import CandleBuilder
class IndicatorBase(object):
def __init__(self, params):
self.params = params
self.values = []
self.candle_builder = CandleBuilder(cache_size=1)
self.candle_size = params['candle_size'] if 'candle_size' in params else 1
self.candle_builder.add_request_update(self.candle_size, self)
def on_new_candle(self, candle):
pass
def update(self, candle):
self.candle_builder.on_new_candle(candle)
def has_enough_data(self):
raise Exception('has_enough_data not implemented')
def get_value(self, idx=None):
raise Exception('get_value not implemented')
def export_data(self):
return {'name': self.__class__.__name__,
'params': self.params,
'data': self.values}