From b3c1fa19cfba9b781daca5c60643b7e5acd36907 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sun, 8 Oct 2017 23:23:28 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=E5=A2=9E=E5=8A=A0MACD=E5=92=8CADX?= =?UTF-8?q?=E6=8C=87=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/app/ctaStrategy/ctaTemplate.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vnpy/trader/app/ctaStrategy/ctaTemplate.py b/vnpy/trader/app/ctaStrategy/ctaTemplate.py index 336fa8c7..1b23586e 100644 --- a/vnpy/trader/app/ctaStrategy/ctaTemplate.py +++ b/vnpy/trader/app/ctaStrategy/ctaTemplate.py @@ -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): """布林通道"""