From a3742a00de2f39f8e336c5159b3f3b42281d4c2d Mon Sep 17 00:00:00 2001 From: KeKe <45591222+1122455801@users.noreply.github.com> Date: Thu, 7 Nov 2019 17:00:19 +0800 Subject: [PATCH] Update utility.py --- vnpy/trader/utility.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/vnpy/trader/utility.py b/vnpy/trader/utility.py index 256a26f8..ea7bd9dd 100644 --- a/vnpy/trader/utility.py +++ b/vnpy/trader/utility.py @@ -478,6 +478,43 @@ class ArrayManager(object): return aroon_up, aroon_down return aroon_up[-1], aroon_down[-1] + def aroonosc(self, n, array=False): + """ + Aroon Oscillator. + """ + result = talib.AROONOSC(self.high, self.low, n) + + if array: + return result + return result[-1] + + def ultosc(self, array=False): + """ + Ultimate Oscillator. + """ + result = talib.ULTOSC(self.high, self.low, self.close) + if array: + return result + return result[-1] + + def mfi(self, n, array=False): + """ + Money Flow Index. + """ + result = talib.MFI(self.high, self.low, self.close, self.volume, n) + if array: + return result + return result[-1] + + def sma_ohlc(self, n, array=False): + """ + Simple moving average for open, high, low, close. + """ + medio = (self.open + self.high + self.low + self.close) / 4 + result = talib.SMA(medio, n) + if array: + return result + return result[-1] def virtual(func: "callable"): """