Esempio n. 1
0
def get_relative_features(dDataRelative, sym):
    sma = ft.featMA(dDataRelative, lLookback = 20)
    sma1 = ft.featMA(dDataRelative, lLookback = 10)
    sma2 = ft.featMA(dDataRelative, lLookback = 5)
    sma3 = ft.featMA(dDataRelative, lLookback = 80)
    sma4 = ft.featMA(dDataRelative, lLookback = 40)
    rsi = ft.featRSI(dDataRelative, lLookback = 20)
    rsi1 = ft.featRSI(dDataRelative, lLookback = 10)
    rsi2 = ft.featRSI(dDataRelative, lLookback = 5)
    rsi3 = ft.featRSI(dDataRelative, lLookback = 80)
    rsi4 = ft.featRSI(dDataRelative, lLookback = 40)
    #volumeDelta = ft.featVolumeDelta(dDataRelative, lLookback = 20)
    aroon = ft.featAroon(dDataRelative, lLookback = 20)
    aroon1 = ft.featAroon(dDataRelative, lLookback = 10)
    aroon2 = ft.featAroon(dDataRelative, lLookback = 5)
    aroon3 = ft.featAroon(dDataRelative, lLookback = 80)
    aroon4 = ft.featAroon(dDataRelative, lLookback = 40)
    bollinger = ft.featBollinger(dDataRelative, lLookback = 20)
    bollinger1 = ft.featBollinger(dDataRelative, lLookback = 10)
    bollinger2 = ft.featBollinger(dDataRelative, lLookback = 5)
    bollinger3 = ft.featBollinger(dDataRelative, lLookback = 80)
    bollinger4 = ft.featBollinger(dDataRelative, lLookback = 40)
    #stochastics = ft.featStochastic(dDataRelative, lLookback = 20)
    dfX = pd.DataFrame( index=dDataRelative['close'].index, 
                        columns=['SMA', 'RSI', 'AROON', 'BOLL'], 
                        data=np.zeros((len(dDataRelative['close'].index), 4)))
    dfX['SMA'] = sma[sym] 
    dfX['SMA1'] = sma1[sym] 
    dfX['SMA2'] = sma2[sym] 
    dfX['SMA3'] = sma3[sym] 
    dfX['SMA4'] = sma4[sym] 
    dfX['RSI'] = rsi[sym] 
    dfX['RSI1'] = rsi1[sym] 
    dfX['RSI2'] = rsi2[sym] 
    dfX['RSI3'] = rsi3[sym] 
    dfX['RSI4'] = rsi4[sym] 
    dfX['AROON'] = aroon[sym] 
    dfX['AROON1'] = aroon1[sym] 
    dfX['AROON2'] = aroon2[sym] 
    dfX['AROON3'] = aroon3[sym] 
    dfX['AROON4'] = aroon4[sym] 
    dfX['BOLL'] = bollinger[sym]
    dfX['BOLL1'] = bollinger1[sym]
    dfX['BOLL2'] = bollinger2[sym]
    dfX['BOLL3'] = bollinger3[sym]
    dfX['BOLL4'] = bollinger4[sym]
    return dfX
Esempio n. 2
0
    def get_features_old(self):
        feats = pd.DataFrame( index=self.relative_data['close'].index)
        periods = self.default_periods
        for x in periods:
            feats['SMA' + str(x)] = ft.featMA(self.relative_data, lLookback = x)[self.stock_period.symbol]
        for x in periods:
            feats['RSI' + str(x)] = ft.featRSI(self.relative_data, lLookback = x)[self.stock_period.symbol]
        for x in periods:
            feats['AROON' + str(x)] = ft.featAroon(self.relative_data, lLookback = x)[self.stock_period.symbol]

        for x in periods:
            feats['BOLL' + str(x)] = ft.featBollinger(self.relative_data, lLookback = x)[self.stock_period.symbol]
        for x in periods:
            feats['MOM' + str(x)] = ft.featMomentum(self.relative_data, lLookback = x)[self.stock_period.symbol]
        for x in periods:
            feats['EMA' + str(x)] = ft.featEMA(self.relative_data, lLookback = x)[self.stock_period.symbol]

        #for x in periods:
        #    feats['STD' + str(x)] = ft.featSTD(self.relative_data, lLookback = x)[self.stock_period.symbol]
        #for x in periods:
        #    feats['VOLD' + str(x)] = ft.featVolumeDelta(self.relative_data, lLookback = x)[self.stock_period.symbol]

        return feats