'''
Price Trend Indicator: Detrended Price Oscillator (DPO)
'''

@@ -53,12 +53,1128 @@
 r (DPO)%0A'''%0A
+from ma import MAIndicator%0Aimport numpy as np%0A%0A%0Aclass DPOIndicator(object):%0A    '''%0A    Detrended Price Oscillator (DPO)%0A    Price = (10/2)+1 period ago price%0A    SMA = 10-period-SMA%0A    Indicator: (Price - SMA)%0A    '''%0A%0A    def __init__(self, data, n=10):%0A        '''%0A        Constructor%0A        data = close prices%0A        n = number of periods%0A        '''%0A        self.data = data%0A        self.n = n%0A        self.shifted_period = (n / 2 + 1)%0A%0A    def indicator(self):%0A        dpo = self.__shiftdata() - self.sma()%5Bself.shifted_period:%5D%0A        return dpo%0A%0A    def indicator_inverse(self):%0A        dpo = self.sma()%5Bself.shifted_period:%5D - self.__shiftdata()%0A        return dpo%0A%0A    def sma(self):%0A        sma = MAIndicator(self.data, self.n, t='simple').ma%0A        return self.__fill_nan(sma)%0A%0A    def __shiftdata(self):%0A        shifteddata = self.__fill_nan(self.data%5Bself.shifted_period:%5D)%0A        return shifteddata%0A%0A    def __fill_nan(self, arr):%0A        displaced_items = np.ndarray((self.shifted_period,))%0A        displaced_items.fill(np.NaN)%0A        arr = np.append(arr, displaced_items)%0A        return arr%0A

Add DPO-Indicator functionality