예제 #1
0
    def InitDMI(self, high, low, atr):
        DMp = pd.DataFrame()
        DMn = pd.DataFrame()

        for i in range(1, len(high.values)):
            moveUp = high.values[i] - high.values[i - 1]
            moveDown = low.values[i - 1] - low.values[i]
            # DM+
            if (moveUp > moveDown) and (moveUp > 0):
                DMp = DMp.append(pd.DataFrame({'value': moveUp},
                                              index=[high.index[i]]))
            else:
                DMp = DMp.append(pd.DataFrame({'value': 0},
                                              index=[high.index[i]]))
            # DM-
            if (moveDown > moveUp) and (moveDown > 0):
                DMn = DMn.append(pd.DataFrame({'value': moveDown},
                                              index=[high.index[i]]))
            else:
                DMn = DMn.append(pd.DataFrame({'value': 0},
                                              index=[high.index[i]]))

        DIp = 100 * CreateMovingAverage(DMp, self.n) / atr
        DIn = 100 * CreateMovingAverage(DMn, self.n) / atr
        ADX = 100 * abs(DIp - DIn) / abs(DIp + DIn)
        return DIp, DIn, ADX
예제 #2
0
파일: cci.py 프로젝트: folkien/pyStock
 def InitCCI(self, high, low, close):
     ct = (high + low + close) / 3
     self.rollingMean = CreateMovingAverage(ct, self.n)
     self.rollingStd = CreateMovingStd(ct, self.n)
     data = pd.Series(
         (ct - self.rollingMean) / (self.factor * self.rollingStd),
         name='CCI_' + str(self.n))
     data = data.fillna(0)
     return data
예제 #3
0
파일: atr.py 프로젝트: folkien/pyStock
    def InitATR(self, high, low, close):
        tr = pd.DataFrame()

        for i in range(len(high.values)):
            value = max(high.values[i] - low.values[i],
                        abs(high.values[i] - close.values[i]),
                        abs(low.values[i] - close.values[i]))
            tr = tr.append(pd.DataFrame(
                {'value': value}, index=[high.index[i]]))

        atr = CreateMovingAverage(tr, self.n)
        return tr, atr
예제 #4
0
파일: cci.py 프로젝트: folkien/pyStock
    def __init__(self, high, low, close, n=14):
        indicator.__init__(self, 'CCI%u' % n, 'momentum', close.index)
        self.n = n
        self.factor = 0.015
        self.cci = self.InitCCI(high, low, close)
        self.cciSignal = CreateMovingAverage(self.cci, self.n * 1.5)

        # Signals
        fromBottom, fromTop = FindIntersections(self.cci, -100)
        self.buy = fromBottom
        fromBottom, fromTop = FindIntersections(self.cci, 100)
        self.sell = fromTop
예제 #5
0
 def Init(price):
     jaw = CreateMovingAverage(price, 13, 8)
     teeth = CreateMovingAverage(price, 8, 5)
     lips = CreateMovingAverage(price, 5, 3)
     return jaw, teeth, lips