Esempio n. 1
0
    def RSIN(self, DataFrame, N=6):
        '相对强弱指标RSI1:SMA(MAX(CLOSE-LC,0),N1,1)/SMA(ABS(CLOSE-LC),N1,1)*100;'
        CLOSE = DataFrame['close']
        LC = base.REF(CLOSE, 1)
        RSI = base.SMA(QA.MAX(CLOSE - LC, 0), N) / base.SMA(
            base.ABS(CLOSE - LC), N) * 100
        DICT = {
            'RSI': RSI,
        }

        return pd.DataFrame(DICT)
Esempio n. 2
0
    def KDJ(self, DataFrame, N=9, M1=3, M2=3):
        C = DataFrame['close']
        H = DataFrame['high']
        L = DataFrame['low']

        RSV = (C - base.LLV(L, N)) / (base.HHV(H, N) - base.LLV(L, N)) * 100
        K = base.SMA(RSV, M1)
        D = base.SMA(K, M2)
        J = 3 * K - 2 * D
        DICT = {'KDJ_K': K, 'KDJ_D': D, 'KDJ_J': J}
        return pd.DataFrame(DICT)
Esempio n. 3
0
    def RSIJCSC(self, DataFrame, Nshort=6, Nlong=12):
        '相对强弱指标RSI1:SMA(MAX(CLOSE-LC,0),N1,1)/SMA(ABS(CLOSE-LC),N1,1)*100;'
        CLOSE = DataFrame['close']
        LC = base.REF(CLOSE, 1)
        RSIshort = base.SMA(base.MAX(CLOSE - LC, 0), Nshort) / base.SMA(
            base.ABS(CLOSE - LC), Nshort) * 100
        RSIlong = base.SMA(base.MAX(CLOSE - LC, 0), Nlong) / base.SMA(
            base.ABS(CLOSE - LC), Nlong) * 100
        JC = base.CROSS(RSIshort, RSIlong)
        SC = base.CROSS(RSIlong, RSIshort)
        DICT = {'RSIshort': RSIshort, "RSIlong": RSIlong, "JC": JC, "SC": SC}

        return pd.DataFrame(DICT)
Esempio n. 4
0
    def get_indicators(self, DataFrame):
        CLOSE = DataFrame['close']
        CLOSE1 = CLOSE.copy()
        for i in range(len(CLOSE) - 1):
            CLOSE1[i] = CLOSE1[i + 1]
        HIGH = DataFrame['high']
        LOW = DataFrame['low']
        CHANGE = (CLOSE1 - CLOSE) / CLOSE
        # for i in range(len(CHANGE)):
        #     if CHANGE[i] > 0:
        #         CHANGE[i] = True
        #     else:
        #         CHANGE[i] = False
        # CHANGE =

        # cci的天数取14
        typ = (HIGH + LOW + CLOSE) / 3
        CCI = ((typ - base.MA(typ, 14)) /
               (0.015 * base.AVEDEV(typ, 14) + 0.00000001))

        # rsi的天数取6
        LC = base.REF(CLOSE, 1)
        RSI = base.SMA(QA.MAX(CLOSE - LC, 0), 6) / base.SMA(
            base.ABS(CLOSE - LC), 6) * 100

        # macd long取26,short取12,mid取9
        DIF = base.EMA(CLOSE, 12) - base.EMA(CLOSE, 26)
        DEA = base.EMA(DIF, 9)
        MACD = (DIF - DEA) * 2

        # boll N取20
        boll = base.MA(CLOSE, 20)

        # kdj N取9,M1、M2取3
        RSV = (CLOSE - base.LLV(LOW, 9)) / (base.HHV(HIGH, 9) -
                                            base.LLV(LOW, 9)) * 100
        K = base.SMA(RSV, 3)
        D = base.SMA(K, 3)
        J = 3 * K - 2 * D

        # DICT = {'CCI14': CCI, 'RSI6': RSI, 'MACD': MACD, 'BOLL': boll, 'KDJ_J': J, "CLOSE1": CLOSE1}
        DICT = {
            'CLOSE': CLOSE,
            'CCI14': CCI,
            'RSI6': RSI,
            'MACD': MACD,
            'BOLL': boll,
            'KDJ_J': J,
            "CLOSE1": CLOSE1
        }
        return pd.DataFrame(DICT)
Esempio n. 5
0
    def INDS(self, DataFrame):
        CLOSE = DataFrame['close']
        HIGH = DataFrame['high']
        LOW = DataFrame['low']

        # cci的天数取14
        typ = (HIGH + LOW + CLOSE) / 3
        CCI = ((typ - base.MA(typ, 14)) /
               (0.015 * base.AVEDEV(typ, 14) + 0.00000001))

        # rsi的天数取6
        LC = base.REF(CLOSE, 1)
        RSI = base.SMA(QA.MAX(CLOSE - LC, 0), 6) / base.SMA(
            base.ABS(CLOSE - LC), 6) * 100

        # macd long取26,short取12,mid取9
        DIF = base.EMA(CLOSE, 12) - base.EMA(CLOSE, 26)
        DEA = base.EMA(DIF, 9)
        MACD = (DIF - DEA) * 2

        # boll N取20
        boll = base.MA(CLOSE, 20)

        # kdj N取9,M1、M2取3
        RSV = (CLOSE - base.LLV(LOW, 9)) / (base.HHV(HIGH, 9) -
                                            base.LLV(LOW, 9)) * 100
        K = base.SMA(RSV, 3)
        D = base.SMA(K, 3)
        J = 3 * K - 2 * D

        DICT = {
            'CLOSE': CLOSE,
            'CCI14': CCI,
            'RSI6': RSI,
            'MACD': MACD,
            'BOLL': boll,
            'KDJ_J': J
        }
        # DICT = {'CLOSE':CLOSE, 'CCI14':CCI, 'RSI6': RSI, 'MACD':MACD, 'BOLL':boll, 'KDJ_J': J, "CLOSE1": CLOSE1}
        return pd.DataFrame(DICT)