def add_MACDEXT(self, fastperiod=12, fastmatype=0,
slowperiod=26, slowmatype=0,
signalperiod=9, signalmatype=0,
types=['line', 'line', 'histogram'],
colors=['primary', 'tertiary', 'fill'],
**kwargs):
"""Moving Average Convergence Divergence with Controllable MA Type.
Note that the first argument of types and colors refers to MACD,
the second argument refers to MACD signal line and the third argument
refers to MACD histogram.
"""
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']] * 3
if 'color' in kwargs:
colors = [kwargs['color']] * 3
name = 'MACDEXT({},{},{})'.format(str(fastperiod),
str(slowperiod),
str(signalperiod))
macd = name
smacd = name + '[Sign]'
hmacd = name + '[Hist]'
self.sec[macd] = dict(type=types[0], color=colors[0])
self.sec[smacd] = dict(type=types[1], color=colors[1], on=macd)
self.sec[hmacd] = dict(type=types[2], color=colors[2], on=macd)
(self.ind[macd],
self.ind[smacd],
self.ind[hmacd]) = talib.MACDEXT(self.df[self.cl].values,
fastperiod, fastmatype,
slowperiod, slowmatype,
signalperiod, signalmatype)
评论列表
文章目录