def add_BBANDS(self, timeperiod=20, nbdevup=2, nbdevdn=2, matype=0,
types=['line_dashed_thin', 'line_dashed_thin'],
colors=['tertiary', 'grey_strong'], **kwargs):
"""Bollinger Bands.
Note that the first argument of types and colors refers to upper and lower
bands while second argument refers to middle band. (Upper and lower are
symmetrical arguments, hence only 2 needed.)
"""
if not self.has_close:
raise Exception()
utils.kwargs_check(kwargs, VALID_TA_KWARGS)
if 'kind' in kwargs:
kwargs['type'] = kwargs['kind']
if 'kinds' in kwargs:
types = kwargs['type']
if 'type' in kwargs:
types = [kwargs['type']] * 2
if 'color' in kwargs:
colors = [kwargs['color']] * 2
name = 'BBANDS({},{},{})'.format(str(timeperiod),
str(nbdevup),
str(nbdevdn))
ubb = name + '[Upper]'
bb = name
lbb = name + '[Lower]'
self.pri[ubb] = dict(type='line_' + types[0][5:],
color=colors[0])
self.pri[bb] = dict(type='area_' + types[1][5:],
color=colors[1], fillcolor='fill')
self.pri[lbb] = dict(type='area_' + types[0][5:],
color=colors[0], fillcolor='fill')
(self.ind[ubb],
self.ind[bb],
self.ind[lbb]) = talib.BBANDS(self.df[self.cl].values,
timeperiod, nbdevup, nbdevdn, matype)
评论列表
文章目录