[Add]增加MACD和ADX指标

This commit is contained in:
vn.py 2017-10-08 23:23:28 +08:00
parent 8cb236f823
commit b3c1fa19cf

View File

@ -530,6 +530,23 @@ class ArrayManager(object):
return result
return result[-1]
#----------------------------------------------------------------------
def macd(self, fastPeriod, slowPeriod, signalPeriod, array=False):
"""MACD指标"""
macd, signal, hist = talib.MACD(self.close, fastPeriod,
slowPeriod, signalPeriod)
if array:
return macd, signal, hist
return macd[-1], signal[-1], hist[-1]
#----------------------------------------------------------------------
def adx(self, n, array=False):
"""ADX指标"""
result = talib.ADX(self.high, self.low, self.close, n)
if array:
return result
return result[-1]
#----------------------------------------------------------------------
def boll(self, n, dev, array=False):
"""布林通道"""