コード例 #1
0
def technical_indicators_df(daily_data):
    """
    Assemble a dataframe of technical indicator series for a single stock
    """
    o = daily_data['Open'].values
    c = daily_data['Close'].values
    h = daily_data['High'].values
    l = daily_data['Low'].values
    v = daily_data['Vol'].astype(float).values
    # define the technical analysis matrix

    # Most data series are normalized by their series' mean
    ta = pd.DataFrame()
    ta['MA5'] = tb.SMA(c,timeperiod=5)
    
    ta['BBANDS_U'],ta['BBANDS_M'],ta['BBANDS_L']= tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
    # ta['BBANDS_M'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[1] / \
    #                     tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[1].mean()
    # ta['BBANDS_L'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[2] / \
    #                     tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[2].mean()
    ta['AD'] = tb.AD(h, l, c, v) / tb.AD(h, l, c, v).mean()
    ta['ATR'] = tb.ATR(h, l, c, timeperiod=14) / tb.ATR(h, l, c, timeperiod=14).mean()
    ta['HT_DC'] = tb.HT_DCPERIOD(c) / tb.HT_DCPERIOD(c).mean()
    ta["High/Open"] = h / o
    ta["Low/Open"] = l / o
    ta["Close/Open"] = c / o
    return ta
コード例 #2
0
def genTA(data, y, t): #t is timeperiod
    indicators  = {}
    y_ind = copy.deepcopy(y)
   
    for ticker in data:
    ## Overlap
        indicators[ticker] = ta.SMA(data[ticker].iloc[:,3], timeperiod=t).to_frame()        
        indicators[ticker]['EMA'] = ta.EMA(data[ticker].iloc[:,3], timeperiod=t)       
        indicators[ticker]['BBAND_Upper'], indicators[ticker]['BBAND_Middle' ], indicators[ticker]['BBAND_Lower' ] = ta.BBANDS(data[ticker].iloc[:,3], timeperiod=t, nbdevup=2, nbdevdn=2, matype=0)         
        indicators[ticker]['HT_TRENDLINE'] = ta.HT_TRENDLINE(data[ticker].iloc[:,3])
        indicators[ticker]['SAR'] = ta.SAR(data[ticker].iloc[:,1], data[ticker].iloc[:,2], acceleration=0, maximum=0)
        #rename SMA column
        indicators[ticker].rename(columns={indicators[ticker].columns[0]: "SMA"}, inplace=True)
    ## Momentum
        indicators[ticker]['RSI'] = ta.RSI(data[ticker].iloc[:,3], timeperiod=(t-1))
        indicators[ticker]['MOM'] = ta.MOM(data[ticker].iloc[:,3], timeperiod=(t-1))
        indicators[ticker]['ROC'] = ta.ROC(data[ticker].iloc[:,3], timeperiod=(t-1))
        indicators[ticker]['ROCP']= ta.ROCP(data[ticker].iloc[:,3],timeperiod=(t-1))
        indicators[ticker]['STOCH_SLOWK'], indicators[ticker]['STOCH_SLOWD'] = ta.STOCH(data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3], fastk_period=t, slowk_period=int(.6*t), slowk_matype=0, slowd_period=int(.6*t), slowd_matype=0)
        indicators[ticker]['MACD'], indicators[ticker]['MACDSIGNAL'], indicators[ticker]['MACDHIST'] = ta.MACD(data[ticker].iloc[:,3], fastperiod=t,slowperiod=2*t,signalperiod=int(.7*t))
        
    ## Volume
        indicators[ticker]['OBV'] = ta.OBV(data[ticker].iloc[:,3], data[ticker].iloc[:,4])
        indicators[ticker]['AD'] = ta.AD(data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3], data[ticker].iloc[:,4])
        indicators[ticker]['ADOSC'] = ta.ADOSC(data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3], data[ticker].iloc[:,4], fastperiod=int(.3*t), slowperiod=t)
        
    ## Cycle
        indicators[ticker]['HT_DCPERIOD'] = ta.HT_DCPERIOD(data[ticker].iloc[:,3])
        indicators[ticker]['HT_TRENDMODE']= ta.HT_TRENDMODE(data[ticker].iloc[:,3])
    
    ## Price
        indicators[ticker]['AVGPRICE'] = ta.AVGPRICE(data[ticker].iloc[:,0], data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3])
        indicators[ticker]['TYPPRICE'] = ta.TYPPRICE(data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3])
    
    ## Volatility
        indicators[ticker]['ATR'] = ta.ATR(data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3],  timeperiod=(t-1))
    
    ## Statistics
        indicators[ticker]['BETA'] = ta.BETA(data[ticker].iloc[:,1], data[ticker].iloc[:,2], timeperiod=(t-1))
        indicators[ticker]['LINEARREG'] = ta.LINEARREG(data[ticker].iloc[:,3], timeperiod=t)
        indicators[ticker]['VAR'] = ta.VAR(data[ticker].iloc[:,3], timeperiod=t, nbdev=1)
    
    ## Math Transform
        indicators[ticker]['EXP'] = ta.EXP(data[ticker].iloc[:,3])
        indicators[ticker]['LN'] = ta.LN(data[ticker].iloc[:,3])
    
    ## Patterns (returns integers - but norming might not really do anything but wondering if they should be normed)
        indicators[ticker]['CDLENGULFING'] = ta.CDLENGULFING(data[ticker].iloc[:,0], data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3])
        indicators[ticker]['CDLDOJI']      = ta.CDLDOJI(data[ticker].iloc[:,0], data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3])
        indicators[ticker]['CDLHAMMER']    = ta.CDLHAMMER(data[ticker].iloc[:,0], data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3])
        indicators[ticker]['CDLHANGINGMAN']= ta.CDLHANGINGMAN(data[ticker].iloc[:,0], data[ticker].iloc[:,1], data[ticker].iloc[:,2], data[ticker].iloc[:,3])
        
    #drop 'nan' values
        indicators[ticker].drop(indicators[ticker].index[np.arange(0,63)], inplace=True)
        y_ind[ticker].drop(y_ind[ticker].index[np.arange(0,63)], inplace=True)
        
    #Normalize Features
    indicators_norm = normData(indicators)
        
    return indicators_norm, indicators, y_ind
コード例 #3
0
    def technical_indicators_df(self):
        o = self.daily_data['Open'].values
        c = self.daily_data['Close'].values
        h = self.daily_data['High'].values
        l = self.daily_data['Low'].values
        v = self.daily_data['Volume'].astype(float).values
        # define the technical analysis matrix

        ta = pd.DataFrame()
        ta['MA5'] = tb.MA(c, timeperiod=5)
        ta['MA10'] = tb.MA(c, timeperiod=10)
        ta['MA20'] = tb.MA(c, timeperiod=20)
        ta['MA60'] = tb.MA(c, timeperiod=60)
        ta['MA120'] = tb.MA(c, timeperiod=120)
        ta['MA5'] = tb.MA(v, timeperiod=5)
        ta['MA10'] = tb.MA(v, timeperiod=10)
        ta['MA20'] = tb.MA(v, timeperiod=20)
        ta['ADX'] = tb.ADX(h, l, c, timeperiod=14)
        ta['ADXR'] = tb.ADXR(h, l, c, timeperiod=14)
        ta['MACD'] = tb.MACD(c, fastperiod=12, slowperiod=26, signalperiod=9)[0]
        ta['RSI'] = tb.RSI(c, timeperiod=14)
        ta['BBANDS_U'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[0]
        ta['BBANDS_M'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[1]
        ta['BBANDS_L'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[2]
        ta['AD'] = tb.AD(h, l, c, v)
        ta['ATR'] = tb.ATR(h, l, c, timeperiod=14)
        ta['HT_DC'] = tb.HT_DCPERIOD(c)

        self.ta = ta
コード例 #4
0
def add_cycle_indicators(data_list):
    for data in data_list:
        #HT_DCPERIOD - Hilbert Transform - Dominant Cycle Period
        real = talib.HT_DCPERIOD(data.Close)
        data['HT_DCPERIOD'] = real

        #HT_DCPHASE - Hilbert Transform - Dominant Cycle Phase
        real = talib.HT_DCPHASE(data.Close)
        data['HT_DCPHASE'] = real

        #HT_PHASOR - Hilbert Transform - Phasor Components
        inphase, quadrature = talib.HT_PHASOR(data.Close)
        data['HT_PHASOR_inphase'] = inphase
        data['HT_PHASOR_quadrature'] = quadrature

        #HT_SINE - Hilbert Transform - SineWave
        sine, leadsine = talib.HT_SINE(data.Close)
        data['HT_SINE_sine'] = sine
        data['HT_SINE_leadsine'] = leadsine

        #HT_TRENDMODE - Hilbert Transform - Trend vs Cycle Mode
        integer = talib.HT_TRENDMODE(data.Close)
        data['HT_TRENDMODE'] = integer

    return data_list
コード例 #5
0
def HT_dcperiod(close_ts):
    import talib
    close_np = close_ts.cpu().detach().numpy()
    close_df = pd.DataFrame(close_np)
    HT_dcperiod = close_df.apply(lambda x: talib.HT_DCPERIOD(x))
    HT_dcperiod_ts = torch.tensor(HT_dcperiod.values, dtype=close_ts.dtype, device=close_ts.device)
    return HT_dcperiod_ts
コード例 #6
0
def Cylcle_Indicators(dataframe):
	"""

	Cycle Indicators

	HT_DCPERIOD          Hilbert Transform - Dominant Cycle Period
	HT_DCPHASE           Hilbert Transform - Dominant Cycle Phase
	HT_PHASOR            Hilbert Transform - Phasor Components
	HT_SINE              Hilbert Transform - SineWave
	HT_TRENDMODE         Hilbert Transform - Trend vs Cycle Mode

	"""

	#Cycle Indicator Functions
	#HT_DCPERIOD - Hilbert Transform - Dominant Cycle Period
	df[f'{ratio}_HT_DCPERIOD'] = talib.HT_DCPERIOD(Close)
	#HT_DCPHASE - Hilbert Transform - Dominant Cycle Phase
	df[f'{ratio}_HT_DCPHASE'] = talib.HT_DCPHASE(Close)
	#HT_PHASOR - Hilbert Transform - Phasor Components
	inphase, quadrature = talib.HT_PHASOR(Close)
	#HT_SINE - Hilbert Transform - SineWave
	sine, leadsine = talib.HT_SINE(Close)
	#HT_TRENDMODE - Hilbert Transform - Trend vs Cycle Mode
	integer = talib.HT_TRENDMODE(Close)

	return
コード例 #7
0
ファイル: backtest.py プロジェクト: Cris-Li/pyfcim
def convert_f(_df):
    _df.index = pd.to_datetime(_df.time)
    _df.index = _df.index.tz_localize('UTC')
    _df.index.name = 'Date'
    _df['MA5'] = talib.MA(_df.close, timeperiod=5)
    _df['upper'], _df['middle'], _df['lower'] = talib.BBANDS(_df.close, matype=talib.MA_Type.T3)
    _df['CCI'] = talib.CCI(_df.high, _df.low, _df.close, timeperiod=24)
    _df['macd'], macdsignal, macdhist = talib.MACD(_df.close)
    _df['HT_DCPERIOD'] = talib.HT_DCPERIOD(_df.close)
    _df['buy_point'] = (_df.close > _df.MA5 - 0.02) & (_df.close < _df.MA5 - 0.02).shift(1) & (
                _df.close < _df.MA5 + 0.02)  # & (_df.intensity < 0.2)
    _df['sell_point'] = ((_df.close > _df.middle).shift(1) & (_df.close < _df.middle)) | (
            (_df.close > _df.upper).shift(1) & (_df.close < _df.upper)) | ((_df.close > _df.lower).shift(1) & (
                _df.close < _df.lower))  # | (_df.intensity > 0.25)
    # _df['buy_point'] = (_df.close > _df.MA5 - 0.02) & (_df.close < _df.MA5 - 0.02).shift(1) & (
    #             _df.close < _df.MA5 + 0.02)
    # _df['sell_point'] = ((_df.close > _df.middle).shift(1) & (_df.close < _df.middle)) | (
    #         (_df.close > _df.upper).shift(1) & (_df.close < _df.upper))
    # 生成sell_point序列
    # idx, = np.where(_df['buy_point'] == True)
    # for j in idx:
    #     cal_sell(j, _df)

    _df.rename(columns={'open': 'O', 'high': 'H', 'low': 'L', 'close': 'C'}, inplace=True)
    return _df
コード例 #8
0
def cycle_process(event):
    print(event.widget.get())
    cycle = event.widget.get()

    upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)
    fig, axes = plt.subplots(2, 1, sharex=True)
    ax1, ax2 = axes[0], axes[1]
    axes[0].plot(close, 'rd-', markersize=3)
    axes[0].plot(upperband, 'y-')
    axes[0].plot(middleband, 'b-')
    axes[0].plot(lowerband, 'y-')
    axes[0].set_title(cycle, fontproperties="SimHei")

    if cycle == '希尔伯特变换——主要的循环周期':
        real = ta.HT_DCPERIOD(close)
        axes[1].plot(real, 'r-')
    elif cycle == '希尔伯特变换,占主导地位的周期阶段':
        real = ta.HT_DCPHASE(close)
        axes[1].plot(real, 'r-')
    elif cycle == '希尔伯特变换——相量组件':
        inphase, quadrature = ta.HT_PHASOR(close)
        axes[1].plot(inphase, 'r-')
        axes[1].plot(quadrature, 'g-')
    elif cycle == '希尔伯特变换——正弦曲线':
        sine, leadsine = ta.HT_SINE(close)
        axes[1].plot(sine, 'r-')
        axes[1].plot(leadsine, 'g-')
    elif cycle == '希尔伯特变换——趋势和周期模式':
        integer = ta.HT_TRENDMODE(close)
        axes[1].plot(integer, 'r-')

    plt.show()
コード例 #9
0
ファイル: ta_features.py プロジェクト: WeiyuLee/TB-ETF
def ta_HT_DCPERIOD(HT_DCPERIOD_conf, curr_close_price_seq):

    curr_feature_list = []

    HT_DCPERIOD_seqs = talib.HT_DCPERIOD(curr_close_price_seq)

    curr_feature_list.append("HT_DCPERIOD")

    return HT_DCPERIOD_seqs, curr_feature_list
コード例 #10
0
ファイル: data_preprocessing.py プロジェクト: xg86/StarTrader
    def technical_indicators_df(self, daily_data):
        """
        Assemble a dataframe of technical indicator series for a single stock
        """
        o = daily_data['Open'].values
        c = daily_data['Close'].values
        h = daily_data['High'].values
        l = daily_data['Low'].values
        v = daily_data['Volume'].astype(float).values
        # define the technical analysis matrix

        # Most data series are normalized by their series' mean
        ta = pd.DataFrame()
        ta['MA5'] = tb.MA(c, timeperiod=5) / tb.MA(c, timeperiod=5).mean()
        ta['MA10'] = tb.MA(c, timeperiod=10) / tb.MA(c, timeperiod=10).mean()
        ta['MA20'] = tb.MA(c, timeperiod=20) / tb.MA(c, timeperiod=20).mean()
        ta['MA60'] = tb.MA(c, timeperiod=60) / tb.MA(c, timeperiod=60).mean()
        ta['MA120'] = tb.MA(c, timeperiod=120) / tb.MA(c,
                                                       timeperiod=120).mean()
        ta['MA5'] = tb.MA(v, timeperiod=5) / tb.MA(v, timeperiod=5).mean()
        ta['MA10'] = tb.MA(v, timeperiod=10) / tb.MA(v, timeperiod=10).mean()
        ta['MA20'] = tb.MA(v, timeperiod=20) / tb.MA(v, timeperiod=20).mean()
        ta['ADX'] = tb.ADX(h, l, c, timeperiod=14) / tb.ADX(
            h, l, c, timeperiod=14).mean()
        ta['ADXR'] = tb.ADXR(h, l, c, timeperiod=14) / tb.ADXR(
            h, l, c, timeperiod=14).mean()
        ta['MACD'] = tb.MACD(c, fastperiod=12, slowperiod=26, signalperiod=9)[0] / \
                     tb.MACD(c, fastperiod=12, slowperiod=26, signalperiod=9)[0].mean()
        ta['RSI'] = tb.RSI(c, timeperiod=14) / tb.RSI(c, timeperiod=14).mean()
        ta['BBANDS_U'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[0] / \
                         tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[0].mean()
        ta['BBANDS_M'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[1] / \
                         tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[1].mean()
        ta['BBANDS_L'] = tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[2] / \
                         tb.BBANDS(c, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0)[2].mean()
        ta['AD'] = tb.AD(h, l, c, v) / tb.AD(h, l, c, v).mean()
        ta['ATR'] = tb.ATR(h, l, c, timeperiod=14) / tb.ATR(
            h, l, c, timeperiod=14).mean()
        ta['HT_DC'] = tb.HT_DCPERIOD(c) / tb.HT_DCPERIOD(c).mean()
        ta["High/Open"] = h / o
        ta["Low/Open"] = l / o
        ta["Close/Open"] = c / o

        self.ta = ta
コード例 #11
0
ファイル: cycle_indicators.py プロジェクト: ueqt/ulib
def HT_DCPERIOD(close):
    ''' Hilbert Transform - Dominant Cycle Period 希尔伯特变换-主导周期

    分组: Cycle Indicators 周期指标

    简介: 将价格作为信息信号,计算价格处在的周期的位置,作为择时的依据。

    real = HT_DCPERIOD(close)
    '''
    return talib.HT_DCPERIOD(close)
コード例 #12
0
ファイル: cycle.py プロジェクト: xuzhipenganhui/orca
 def eval(self, environment, gene, date1, date2):
     date1_ = environment.shift_date(date1, -(self.window - 1), -1)
     df = gene.next_value(environment, date1_, date2)
     res = pd.DataFrame(np.nan,
                        index=df.ix[date1:date2].index,
                        columns=df.columns)
     for i, j in product(range(res.shape[0]), range(res.shape[1])):
         res.iloc[i, j] = talib.HT_DCPERIOD(df.values[i:i + self.window,
                                                      j])[-1]
     return res
コード例 #13
0
 def _get_indicators(security, open_name, close_name, high_name, low_name,
                     volume_name):
     """
     expand the features of the data through technical analysis across 26 different signals
     :param security: data which features are going to be expanded
     :param open_name: open price column name
     :param close_name: close price column name
     :param high_name: high price column name
     :param low_name: low price column name
     :param volume_name: traded volumn column name
     :return: expanded and extracted data
     """
     open_price = security[open_name].values
     close_price = security[close_name].values
     low_price = security[low_name].values
     high_price = security[high_name].values
     volume = security[volume_name].values if volume_name else None
     security['MOM'] = talib.MOM(close_price)
     security['HT_DCPERIOD'] = talib.HT_DCPERIOD(close_price)
     security['HT_DCPHASE'] = talib.HT_DCPHASE(close_price)
     security['SINE'], security['LEADSINE'] = talib.HT_SINE(close_price)
     security['INPHASE'], security['QUADRATURE'] = talib.HT_PHASOR(
         close_price)
     security['ADXR'] = talib.ADXR(high_price, low_price, close_price)
     security['APO'] = talib.APO(close_price)
     security['AROON_UP'], _ = talib.AROON(high_price, low_price)
     security['CCI'] = talib.CCI(high_price, low_price, close_price)
     security['PLUS_DI'] = talib.PLUS_DI(high_price, low_price, close_price)
     security['PPO'] = talib.PPO(close_price)
     security['MACD'], security['MACD_SIG'], security[
         'MACD_HIST'] = talib.MACD(close_price)
     security['CMO'] = talib.CMO(close_price)
     security['ROCP'] = talib.ROCP(close_price)
     security['FASTK'], security['FASTD'] = talib.STOCHF(
         high_price, low_price, close_price)
     security['TRIX'] = talib.TRIX(close_price)
     security['ULTOSC'] = talib.ULTOSC(high_price, low_price, close_price)
     security['WILLR'] = talib.WILLR(high_price, low_price, close_price)
     security['NATR'] = talib.NATR(high_price, low_price, close_price)
     security['RSI'] = talib.RSI(close_price)
     security['EMA'] = talib.EMA(close_price)
     security['SAREXT'] = talib.SAREXT(high_price, low_price)
     # security['TEMA'] = talib.EMA(close_price)
     security['RR'] = security[close_name] / security[close_name].shift(
         1).fillna(1)
     security['LOG_RR'] = np.log(security['RR'])
     if volume_name:
         security['MFI'] = talib.MFI(high_price, low_price, close_price,
                                     volume)
         # security['AD'] = talib.AD(high_price, low_price, close_price, volume)
         # security['OBV'] = talib.OBV(close_price, volume)
         security[volume_name] = np.log(security[volume_name])
     security.drop([open_name, close_name, high_name, low_name], axis=1)
     security = security.dropna().astype(np.float32)
     return security
コード例 #14
0
def add_indicators(data):
    df = data.copy(deep=True)
    for indicator in lookup:
        try:
            result = getattr(talib, indicator)(df.Close)
            if isinstance(result, tuple):
                for i, val in enumerate(result):
                    df[f'{indicator}_{i}'] = val
            else:
                df[f'{indicator}'] = val
        except (KeyboardInterrupt, SystemError):
            raise
        except:
            try:
                result = getattr(talib, indicator)(df.High, df.Low)
                if isinstance(result, tuple):
                    for i, val in enumerate(result):
                        df[f'{indicator}_{i}'] = val
                else:
                    df[f'{indicator}'] = val
            except (KeyboardInterrupt, SystemError):
                raise
            except:
                try:
                    result = getattr(talib, indicator)(df.High, df.Low,
                                                       df.Close)
                    if isinstance(result, tuple):
                        for i, val in enumerate(result):
                            df[f'{indicator}_{i}'] = val
                    else:
                        df[f'{indicator}'] = val
                except (KeyboardInterrupt, SystemError):
                    raise
                except:
                    try:
                        result = getattr(talib, indicator)(df.Open, df.High,
                                                           df.Low, df.Close)
                        if isinstance(result, tuple):
                            for i, val in enumerate(result):
                                df[f'{indicator}_{i}'] = val
                        else:
                            df[f'{indicator}'] = val
                    except (KeyboardInterrupt, SystemError):
                        raise
                    except:
                        print(f'issue with {indicator}')

    df.OBV = talib.OBV(df.Close, df.Volume)
    df.AD = talib.AD(df.High, df.Low, df.Close, df.Volume)
    df.ADOSC = talib.ADOSC(df.High, df.Low, df.Close, df.Volume)
    df['HT_DCPERIOD'] = talib.HT_DCPERIOD(df.Close)
    df['HT_DCPHASE'] = talib.HT_DCPHASE(df.Close)

    return df
コード例 #15
0
def sexy(k):
    if len(k) > 3:
        vm = wrap(k)
        print("--talib--")
        print(list(talib.HT_DCPERIOD(vm)))
        print(list(talib.HT_DCPHASE(vm)))
        print(list(talib.HT_PHASOR(vm)))
        print(list(talib.HT_SINE(vm)))
        print(list(talib.HT_TRENDMODE(vm)))
        print("--talib--")
    else:
        pass
コード例 #16
0
def getCycleIndicators(df):
    high = df['High']
    low = df['Low']
    close = df['Close']
    open = df['Open']
    volume = df['Volume']

    df['DCPERIOD'] = ta.HT_DCPERIOD(close)
    df['DCPHASE'] = ta.HT_DCPHASE(close)
    df['INPHASE'], df['QUADRATURE'] = ta.HT_PHASOR(close)
    df['SINE'], df['LEADSINE'] = ta.HT_SINE(close)
    df['TRENDMODE'] = ta.HT_TRENDMODE(close)
コード例 #17
0
def computeHilbertTransformSignals(ticker, pd):
    closeField = config.ticker2ReturnFieldMap[ticker]
    close = numpy.array(pd[closeField])
    pd['Hilbert.DCPeriod'] = talib.HT_DCPERIOD(close)
    pd['Hilbert.DCPhase'] = talib.HT_DCPHASE(close)
    pd['Hilbert.inphase'], pd['Hilbert.quadrature'] = talib.HT_PHASOR(close)
    pd['Hilbert.sine'], pd['Hilbert.leadsine'] = talib.HT_SINE(close)
    pd['Hilbert.TrendMode'] = talib.HT_TRENDMODE(close)
    fields = [
        'Hilbert.DCPeriod', 'Hilbert.DCPhase', 'Hilbert.inphase',
        'Hilbert.quadrature', 'Hilbert.sine', 'Hilbert.leadsine',
        'Hilbert.TrendMode'
    ]
    return pd, fields
コード例 #18
0
    def default_idts(self):
        """
        Assemble a dataframe of technical indicator series for a single stock
        """
        o = self.data['open'].values
        c = self.data['close'].values
        h = self.data['high'].values
        l = self.data['low'].values
        v = self.data['volume'].astype(float).values
        # define the technical analysis matrix

        # Most data series are normalized by their series' mean
        ta = pd.DataFrame()
        ta['MA5'] = tb.MA(c, timeperiod=5)
        ta['MA10'] = tb.MA(c, timeperiod=10)
        ta['MA20'] = tb.MA(c, timeperiod=20)
        ta['MA60'] = tb.MA(c, timeperiod=60)
        ta['MA120'] = tb.MA(c, timeperiod=120)
        ta['MA5'] = tb.MA(v, timeperiod=5)
        ta['MA10'] = tb.MA(v, timeperiod=10)
        ta['MA20'] = tb.MA(v, timeperiod=20)
        ta['ADX'] = tb.ADX(h, l, c, timeperiod=14)
        ta['ADXR'] = tb.ADXR(h, l, c, timeperiod=14)
        ta['MACD'] = tb.MACD(c, fastperiod=12, slowperiod=26,
                             signalperiod=9)[0]
        ta['RSI'] = tb.RSI(c, timeperiod=14)
        ta['BBANDS_U'] = tb.BBANDS(c,
                                   timeperiod=5,
                                   nbdevup=2,
                                   nbdevdn=2,
                                   matype=0)[0]
        ta['BBANDS_M'] = tb.BBANDS(c,
                                   timeperiod=5,
                                   nbdevup=2,
                                   nbdevdn=2,
                                   matype=0)[1]
        ta['BBANDS_L'] = tb.BBANDS(c,
                                   timeperiod=5,
                                   nbdevup=2,
                                   nbdevdn=2,
                                   matype=0)[2]
        ta['AD'] = tb.AD(h, l, c, v)
        ta['ATR'] = tb.ATR(h, l, c, timeperiod=14)
        ta['HT_DC'] = tb.HT_DCPERIOD(c)
        ta["High/Open"] = h / o
        ta["Low/Open"] = l / o
        ta["Close/Open"] = c / o
        ta.index = self.data.index
        return ta
コード例 #19
0
def ht_dcperiod(candles: np.ndarray, source_type: str = "close", sequential: bool = False) -> Union[float, np.ndarray]:
    """
    HT_DCPERIOD - Hilbert Transform - Dominant Cycle Period

    :param candles: np.ndarray
    :param source_type: str - default: "close"
    :param sequential: bool - default: False

    :return: float | np.ndarray
    """
    candles = slice_candles(candles, sequential)

    source = get_candle_source(candles, source_type=source_type)
    res = talib.HT_DCPERIOD(source)

    return res if sequential else res[-1]
コード例 #20
0
def generate_tech_data_default(stock,
                               open_name,
                               close_name,
                               high_name,
                               low_name,
                               volume_name='vol'):
    open_price = stock[open_name].values
    close_price = stock[close_name].values
    low_price = stock[low_name].values
    high_price = stock[high_name].values
    volume = stock[volume_name].values
    data = stock.copy()
    data['MOM'] = talib.MOM(close_price)
    data['HT_DCPERIOD'] = talib.HT_DCPERIOD(close_price)
    data['HT_DCPHASE'] = talib.HT_DCPHASE(close_price)
    data['sine'], data['leadsine'] = talib.HT_SINE(close_price)
    data['inphase'], data['quadrature'] = talib.HT_PHASOR(close_price)
    data['ADXR'] = talib.ADXR(high_price, low_price, close_price)
    data['APO'] = talib.APO(close_price)
    data['AROON_UP'], _ = talib.AROON(high_price, low_price)
    data['CCI'] = talib.CCI(high_price, low_price, close_price)
    data['PLUS_DI'] = talib.PLUS_DI(high_price, low_price, close_price)
    data['PPO'] = talib.PPO(close_price)
    data['macd'], data['macd_sig'], data['macd_hist'] = talib.MACD(close_price)
    data['CMO'] = talib.CMO(close_price)
    data['ROCP'] = talib.ROCP(close_price)
    data['fastk'], data['fastd'] = talib.STOCHF(high_price, low_price,
                                                close_price)
    data['TRIX'] = talib.TRIX(close_price)
    data['ULTOSC'] = talib.ULTOSC(high_price, low_price, close_price)
    data['WILLR'] = talib.WILLR(high_price, low_price, close_price)
    data['NATR'] = talib.NATR(high_price, low_price, close_price)
    data['MFI'] = talib.MFI(high_price, low_price, close_price, volume)
    data['RSI'] = talib.RSI(close_price)
    data['AD'] = talib.AD(high_price, low_price, close_price, volume)
    data['OBV'] = talib.OBV(close_price, volume)
    data['EMA'] = talib.EMA(close_price)
    data['SAREXT'] = talib.SAREXT(high_price, low_price)
    data['TEMA'] = talib.EMA(close_price)
    #data = data.drop([open_name, close_name, high_name, low_name, volume_name, 'amount', 'count'], axis=1)
    data = drop_columns(data, [
        open_name, close_name, high_name, low_name, volume_name, 'amount',
        'count'
    ])
    data = data.dropna().astype(np.float32)
    return data
コード例 #21
0
def get_additional_factors(open, high, low, close, volume):

    # Overlap Studies Functions
    mat = get_all_factors(open, high, low, close, volume)

    mat = np.column_stack((mat, talib.HT_TRENDLINE(close)))  ## close
    mat = np.column_stack((mat, talib.KAMA(close, timeperiod=30)))  ##close

    #Momentum Indicator Functions
    mat = np.column_stack((mat, talib.ADX(high, low, close, timeperiod=14)))
    mat = np.column_stack((mat, talib.ADXR(high, low, close, timeperiod=14)))
    mat = np.column_stack(
        (mat, talib.APO(close, fastperiod=12, slowperiod=26, matype=0)))
    mat = np.column_stack((mat, talib.AROONOSC(high, low, timeperiod=14)))
    mat = np.column_stack((mat, talib.BOP(open, high, low, close)))
    mat = np.column_stack((mat, talib.MOM(close, timeperiod=10)))

    #Volume Indicator Functions
    mat = np.column_stack((mat, talib.AD(high, low, close, volume)))
    mat = np.column_stack(
        (mat, talib.ADOSC(high,
                          low,
                          close,
                          volume,
                          fastperiod=3,
                          slowperiod=10)))
    mat = np.column_stack((mat, talib.OBV(close, volume)))

    #Volatility Indicator Functions
    mat = np.column_stack((mat, talib.NATR(high, low, close, timeperiod=14)))
    mat = np.column_stack((mat, talib.TRANGE(high, low, close)))

    #Price Transform Functions
    mat = np.column_stack((mat, talib.AVGPRICE(open, high, low, close)))
    mat = np.column_stack((mat, talib.MEDPRICE(high, low)))
    mat = np.column_stack((mat, talib.TYPPRICE(high, low, close)))
    mat = np.column_stack((mat, talib.WCLPRICE(high, low, close)))

    #Cycle Indicator Functions
    mat = np.column_stack((mat, talib.HT_DCPERIOD(close)))
    mat = np.column_stack((mat, talib.HT_DCPHASE(close)))
    mat = np.column_stack((mat, talib.HT_TRENDMODE(close)))

    # 20

    return mat
コード例 #22
0
def ht_dcperiod(client, symbol, timeframe="6m", col="close"):
    """This will return a dataframe of
    Hilbert Transform - Dominant Cycle Period
    for the given symbol across
    the given timeframe

    Args:
        client (pyEX.Client); Client
        symbol (string); Ticker
        timeframe (string); timeframe to use, for pyEX.chart
        col (string); column to use to calculate

    Returns:
        DataFrame: result
    """
    df = client.chartDF(symbol, timeframe)
    x = t.HT_DCPERIOD(df[col].values)
    return pd.DataFrame({col: df[col].values, "ht_dcperiod": x})
コード例 #23
0
    def test_HT_DCPERIOD(self):
        class MyHT_DCPERIOD(OperatorHT_DCPERIOD):
            def __init__(self, name, **kwargs):
                super(MyHT_DCPERIOD, self).__init__(100, name, **kwargs)

        self.env.add_operator('ht_dcperiod', {
            'operator': MyHT_DCPERIOD,
        })
        string = 'ht_dcperiod(open)'
        gene = self.env.parse_string(string)
        self.assertRaises(IndexError, gene.eval, self.env, self.dates[98],
                          self.dates[-1])
        ser = gene.eval(self.env, self.dates[99], self.dates[99]).iloc[0]
        data = self.env.get_data_value('open')
        res = []
        for i, val in ser.iteritems():
            res.append(talib.HT_DCPERIOD(data[i].values[:100])[-1] == val)
        self.assertTrue(all(res))
コード例 #24
0
def get_cycle_indicators(df_price):

    df_local = df_price.copy()
    df_nonna_idxs = df_local[~df_local.Close.isna()].Close.index

    np_adj_close = df_local.Adj_Close.values
    np_close = df_local.Close.values
    np_open = df_local.Open.values
    np_high = df_local.High.values
    np_low = df_local.Low.values
    np_volume = df_local.Volume.values

    np_nan_indices = np.isnan(np_close)

    #HT_DCPERIOD-Hilbert Transform - Dominant Cycle Period
    HT_DCPERIOD = pd.Series(ta.HT_DCPERIOD(np_adj_close[~np_nan_indices]),
                            index=df_nonna_idxs)
    df_local['HT_DCPERIOD'] = HT_DCPERIOD

    #HT_DCPHASE-Hilbert Transform - Dominant Cycle Phase
    HT_DCPHASE = pd.Series(ta.HT_DCPHASE(np_adj_close[~np_nan_indices]),
                           index=df_nonna_idxs)
    df_local['HT_DCPHASE'] = HT_DCPHASE

    #HT_PHASOR-Hilbert Transform - Phasor Components
    HT_PHASOR = ta.HT_PHASOR(np_adj_close[~np_nan_indices])

    df_local['HT_PHASOR_INPHASE'] = pd.Series(HT_PHASOR[0],
                                              index=df_nonna_idxs)
    df_local['HT_PHASOR_QUADRATURE'] = pd.Series(HT_PHASOR[1],
                                                 index=df_nonna_idxs)

    #HT_SINE - Hilbert Transform - SineWave
    HT_SINE = ta.HT_SINE(np_adj_close[~np_nan_indices])

    df_local['HT_SINE_SINE'] = pd.Series(HT_SINE[0], index=df_nonna_idxs)
    df_local['HT_SINE_LEADSINE'] = pd.Series(HT_SINE[1], index=df_nonna_idxs)

    #HT_TRENDMODE-Hilbert Transform - Trend vs Cycle Mode
    HT_TRENDMODE = pd.Series(ta.HT_TRENDMODE(np_adj_close[~np_nan_indices]),
                             index=df_nonna_idxs)
    df_local['HT_TRENDMODE'] = HT_TRENDMODE

    return df_local
コード例 #25
0
 def _get_indicators(security, open_name, close_name, high_name, low_name,
                     volume_name):
     open_price = security[open_name].values
     close_price = security[close_name].values
     low_price = security[low_name].values
     high_price = security[high_name].values
     volume = security[volume_name].values if volume_name else None
     security['MOM'] = talib.MOM(close_price)
     security['HT_DCPERIOD'] = talib.HT_DCPERIOD(close_price)
     security['HT_DCPHASE'] = talib.HT_DCPHASE(close_price)
     security['SINE'], security['LEADSINE'] = talib.HT_SINE(close_price)
     security['INPHASE'], security['QUADRATURE'] = talib.HT_PHASOR(
         close_price)
     security['ADXR'] = talib.ADXR(high_price, low_price, close_price)
     security['APO'] = talib.APO(close_price)
     security['AROON_UP'], _ = talib.AROON(high_price, low_price)
     security['CCI'] = talib.CCI(high_price, low_price, close_price)
     security['PLUS_DI'] = talib.PLUS_DI(high_price, low_price, close_price)
     security['PPO'] = talib.PPO(close_price)
     security['MACD'], security['MACD_SIG'], security[
         'MACD_HIST'] = talib.MACD(close_price)
     security['CMO'] = talib.CMO(close_price)
     security['ROCP'] = talib.ROCP(close_price)
     security['FASTK'], security['FASTD'] = talib.STOCHF(
         high_price, low_price, close_price)
     security['TRIX'] = talib.TRIX(close_price)
     security['ULTOSC'] = talib.ULTOSC(high_price, low_price, close_price)
     security['WILLR'] = talib.WILLR(high_price, low_price, close_price)
     security['NATR'] = talib.NATR(high_price, low_price, close_price)
     security['RSI'] = talib.RSI(close_price)
     security['EMA'] = talib.EMA(close_price)
     security['SAREXT'] = talib.SAREXT(high_price, low_price)
     security['RR'] = security[close_name] / security[close_name].shift(
         1).fillna(1)
     security['LOG_RR'] = np.log(security['RR'])
     if volume_name:
         security['MFI'] = talib.MFI(high_price, low_price, close_price,
                                     volume)
         security[volume_name] = np.log(security[volume_name])
     security.drop([open_name, close_name, high_name, low_name], axis=1)
     security = security.dropna().astype(np.float32)
     return security
コード例 #26
0
ファイル: talib_fractal.py プロジェクト: zsl3034669/GolemQ
def talib_patterns_func(data, *args, **kwargs):
    """
    计算Talib Pattern Recognition Functions, 统计出累加值
    累加值大的,有极大几率为短期最佳买入点和卖出点
    支持QA add_func,第二个参数 默认为 indices= 为已经计算指标
    理论上这个函数只计算单一标的,不要尝试传递复杂标的,indices会尝试拆分。
    """
    # 针对多标的,拆分 indices 数据再自动合并
    code = data.index.get_level_values(level=1)[0]
    if ('indices' in kwargs.keys()):
        indices = kwargs['indices'].loc[(slice(None), code), :]
    elif (len(args) > 0):
        indices = args[0].loc[(slice(None), code), :]
    else:
        indices = None

    open = data.open.values
    high = data.high.values
    low = data.low.values
    close = data.close.values
    ret_cumsum = None
    ret_labels = None

    for fractal_pattern in fractal_patterns:
        integer = fractal_pattern['func'](open, high, low, close)

        if (ret_cumsum is None):
            ret_cumsum = integer
            ret_labels = integer
        else:
            ret_cumsum = ret_cumsum + integer
            ret_labels = np.c_[ret_labels, integer]

    if (indices is None):
        indices = pd.DataFrame(ret_cumsum,
                               columns=['talib_patterns'],
                               index=data.index)
    else:
        indices['talib_patterns'] = ret_cumsum

    indices['dcperiod'] = talib.HT_DCPERIOD(data.close.values)
    return indices
コード例 #27
0
def generate_tech_data(stock, open_name, close_name, high_name, low_name):
    open_price = stock[open_name].values
    close_price = stock[close_name].values
    low_price = stock[low_name].values
    high_price = stock[high_name].values
    data = pd.DataFrame(stock)
    data['MOM'] = talib.MOM(close_price)
    data['SMA'] = talib.SMA(close_price)
    data['HT_DCPERIOD'] = talib.HT_DCPERIOD(close_price)
    data['HT_DCPHASE'] = talib.HT_DCPHASE(close_price)
    data['sine'], data['leadsine'] = talib.HT_SINE(close_price)
    data['inphase'], data['quadrature'] = talib.HT_PHASOR(close_price)
    data['HT_TRENDMODE'] = talib.HT_TRENDMODE(close_price)
    data['SAREXT'] = talib.SAREXT(high_price, low_price)
    data['ADX'] = talib.ADX(high_price, low_price, close_price)
    data['ADXR'] = talib.ADX(high_price, low_price, close_price)
    data['APO'] = talib.APO(close_price)
    data['AROON_UP'], data['AROON_DOWN'] = talib.AROON(high_price, low_price)
    data['AROONOSC'] = talib.AROONOSC(high_price, low_price)
    data['BOP'] = talib.BOP(open_price, high_price, low_price, close_price)
    data['CCI'] = talib.CCI(high_price, low_price, close_price)
    data['PLUS_DI'] = talib.PLUS_DI(high_price, low_price, close_price)
    data['PLUS_DM'] = talib.PLUS_DM(high_price, low_price)
    data['PPO'] = talib.PPO(close_price)
    data['macd'], data['macd_sig'], data['macd_hist'] = talib.MACD(close_price)
    data['RSI'] = talib.RSI(close_price)
    data['CMO'] = talib.CMO(close_price)
    data['ROC'] = talib.ROC(close_price)
    data['ROCP'] = talib.ROCP(close_price)
    data['ROCR'] = talib.ROCR(close_price)
    data['slowk'], data['slowd'] = talib.STOCH(high_price, low_price,
                                               close_price)
    data['fastk'], data['fastd'] = talib.STOCHF(high_price, low_price,
                                                close_price)
    data['TRIX'] = talib.TRIX(close_price)
    data['ULTOSC'] = talib.ULTOSC(high_price, low_price, close_price)
    data['WILLR'] = talib.WILLR(high_price, low_price, close_price)
    data['NATR'] = talib.NATR(high_price, low_price, close_price)
    data['TRANGE'] = talib.TRANGE(high_price, low_price, close_price)
    data = data.drop([open_name, close_name, high_name, low_name], axis=1)
    data = data.dropna()
    return data
コード例 #28
0
ファイル: cycle_indicators.py プロジェクト: xiebing77/xquant
def handle_cycle_indicators(args, axes, i, klines_df, close_times,
                            display_count):
    # talib
    if args.HT_DCPERIOD:
        name = 'HT_DCPERIOD'
        real = talib.HT_DCPERIOD(klines_df["close"])
        i += 1
        axes[i].set_ylabel(name)
        axes[i].grid(True)
        axes[i].plot(close_times, real[-display_count:], "y:", label=name)

    if args.HT_DCPHASE:
        name = 'HT_DCPHASE'
        real = talib.HT_DCPHASE(klines_df["close"])
        i += 1
        axes[i].set_ylabel(name)
        axes[i].grid(True)
        axes[i].plot(close_times, real[-display_count:], "y:", label=name)

    if args.HT_PHASOR:
        name = 'HT_PHASOR'
        real = talib.HT_PHASOR(klines_df["close"])
        i += 1
        axes[i].set_ylabel(name)
        axes[i].grid(True)
        axes[i].plot(close_times, real[-display_count:], "y:", label=name)

    if args.HT_SINE:
        name = 'HT_SINE'
        real = talib.HT_SINE(klines_df["close"])
        i += 1
        axes[i].set_ylabel(name)
        axes[i].grid(True)
        axes[i].plot(close_times, real[-display_count:], "y:", label=name)

    if args.HT_TRENDMODE:
        name = 'HT_TRENDMODE'
        real = talib.HT_TRENDMODE(klines_df["close"])
        i += 1
        axes[i].set_ylabel(name)
        axes[i].grid(True)
        axes[i].plot(close_times, real[-display_count:], "y:", label=name)
コード例 #29
0
def ht_dcperiod(candles: np.ndarray,
                source_type: str = "close",
                sequential: bool = False) -> Union[float, np.ndarray]:
    """
    HT_DCPERIOD - Hilbert Transform - Dominant Cycle Period

    :param candles: np.ndarray
    :param source_type: str - default: "close"
    :param sequential: bool - default=False

    :return: float | np.ndarray
    """
    warmup_candles_num = get_config('env.data.warmup_candles_num', 240)
    if not sequential and len(candles) > warmup_candles_num:
        candles = candles[-warmup_candles_num:]

    source = get_candle_source(candles, source_type=source_type)
    res = talib.HT_DCPERIOD(source)

    return res if sequential else res[-1]
コード例 #30
0
ファイル: DataUtils.py プロジェクト: wuxx1016/RLTarder
def generate_tech_data(stock, open_name, close_name, high_name, low_name, max_time_window=10):
    open_price = stock[open_name].values
    close_price = stock[close_name].values
    low_price = stock[low_name].values
    high_price = stock[high_name].values
    data = pd.DataFrame(stock)
    data['MOM'] = talib.MOM(close_price, timeperiod=max_time_window)
    # data['_SMA'] = talib.SMA(close_price)
    data['HT_DCPERIOD'] = talib.HT_DCPERIOD(close_price)
    data['HT_DCPHASE'] = talib.HT_DCPHASE(close_price)
    data['sine'], data['leadsine'] = talib.HT_SINE(close_price)
    data['inphase'], data['quadrature'] = talib.HT_PHASOR(close_price)
    # data['_HT_TRENDMODE'] = talib.HT_TRENDMODE(close_price)
    # data['_SAREXT'] = talib.SAREXT(high_price, low_price)
    # data['_ADX'] = talib.ADX(high_price, low_price, close_price)
    data['ADXR'] = talib.ADXR(high_price, low_price, close_price, timeperiod=max_time_window)
    data['APO'] = talib.APO(close_price, fastperiod=max_time_window // 2, slowperiod=max_time_window)
    data['AROON_UP'], _ = talib.AROON(high_price, low_price, timeperiod=max_time_window)
    # data['_BOP'] = talib.BOP(open_price, high_price, low_price, close_price)
    data['CCI'] = talib.CCI(high_price, low_price, close_price, timeperiod=max_time_window)
    data['PLUS_DI'] = talib.PLUS_DI(high_price, low_price, close_price, timeperiod=max_time_window)
    # data['_PLUS_DM'] = talib.PLUS_DM(high_price, low_price)
    data['PPO'] = talib.PPO(close_price, fastperiod=max_time_window // 2, slowperiod=max_time_window)
    data['macd'], data['macd_sig'], data['macd_hist'] = talib.MACD(close_price, fastperiod=max_time_window // 2, slowperiod=max_time_window, signalperiod=max_time_window // 2)
    data['CMO'] = talib.CMO(close_price, timeperiod=max_time_window)
    #     data['ROC'] = talib.ROC(close_price)
    data['ROCP'] = talib.ROCP(close_price, timeperiod=max_time_window)
    #     data['ROCR'] = talib.ROCR(close_price)
    #     data['slowk'], data['slowd'] = talib.STOCH(high_price, low_price, close_price)
    data['fastk'], data['fastd'] = talib.STOCHF(high_price, low_price, close_price)
    data['TRIX'] = talib.TRIX(close_price, timeperiod=max_time_window)
    data['ULTOSC'] = talib.ULTOSC(high_price, low_price, close_price, timeperiod1=max_time_window // 2, timeperiod2=max_time_window, timeperiod3=max_time_window * 2)
    data['WILLR'] = talib.WILLR(high_price, low_price, close_price, timeperiod=max_time_window)
    data['NATR'] = talib.NATR(high_price, low_price, close_price, timeperiod=max_time_window)
    # data['_TRANGE'] = talib.TRANGE(high_price, low_price, close_price)
    data = data.drop([open_name, close_name, high_name, low_name], axis=1)
    #     data.columns=data.columns.map(lambda x:x[1:])
    data = data.dropna().astype(np.float32)
    return data