コード例 #1
0
ファイル: indicators.py プロジェクト: kkt86/TradingEnv
def add_indicators(data: pd.DataFrame) -> pd.DataFrame:
    """
    This method creates technical indicators, based on the OHLC and volume bars
    :param data: pandas DataFrame, containing open, high, low and close and
                 optional volume columns
    :return: DataFrame with added technical indicators
    """
    assert 'open' in data.columns, "open column not present or with different name"
    assert 'high' in data.columns, "high column not present or with different name"
    assert 'low' in data.columns, "low column not present or with different name"
    assert 'close' in data.columns, "close column not present or with different name"

    try:
        data['RSI'] = ta.rsi(data["close"])
        data['TSI'] = ta.tsi(data["close"])
        data['UO'] = ta.uo(data["high"], data["low"], data["close"])
        data['AO'] = ta.ao(data["high"], data["low"])
        data['MACD_diff'] = ta.macd_diff(data["close"])
        data['Vortex_pos'] = ta.vortex_indicator_pos(data["high"], data["low"], data["close"])
        data['Vortex_neg'] = ta.vortex_indicator_neg(data["high"], data["low"], data["close"])
        data['Vortex_diff'] = abs(data['Vortex_pos'] - data['Vortex_neg'])
        data['Trix'] = ta.trix(data["close"])
        data['Mass_index'] = ta.mass_index(data["high"], data["low"])
        data['CCI'] = ta.cci(data["high"], data["low"], data["close"])
        data['DPO'] = ta.dpo(data["close"])
        data['KST'] = ta.kst(data["close"])
        data['KST_sig'] = ta.kst_sig(data["close"])
        data['KST_diff'] = (data['KST'] - data['KST_sig'])
        data['Aroon_up'] = ta.aroon_up(data["close"])
        data['Aroon_down'] = ta.aroon_down(data["close"])
        data['Aroon_ind'] = (data['Aroon_up'] - data['Aroon_down'])
        data['BBH'] = ta.bollinger_hband(data["close"])
        data['BBL'] = ta.bollinger_lband(data["close"])
        data['BBM'] = ta.bollinger_mavg(data["close"])
        data['BBHI'] = ta.bollinger_hband_indicator(data["close"])
        data['BBLI'] = ta.bollinger_lband_indicator(data["close"])
        data['KCHI'] = ta.keltner_channel_hband_indicator(data["high"], data["low"], data["close"])
        data['KCLI'] = ta.keltner_channel_lband_indicator(data["high"], data["low"], data["close"])
        data['DCHI'] = ta.donchian_channel_hband_indicator(data["close"])
        data['DCLI'] = ta.donchian_channel_lband_indicator(data["close"])
        data['DR'] = ta.daily_return(data["close"])
        data['DLR'] = ta.daily_log_return(data["close"])

        if 'volume' in data.columns:
            data['MFI'] = ta.money_flow_index(data["high"], data["low"], data["close"], data["volume"])
            data['ADI'] = ta.acc_dist_index(data["high"], data["low"], data["close"], data["volume"])
            data['OBV'] = ta.on_balance_volume(data["close"], data["volume"])
            data['CMF'] = ta.chaikin_money_flow(data["high"], data["low"], data["close"], data["volume"])
            data['FI'] = ta.force_index(data["close"], data["volume"])
            data['EM'] = ta.ease_of_movement(data["high"], data["low"], data["close"], data["volume"])
            data['VPT'] = ta.volume_price_trend(data["close"], data["volume"])
            data['NVI'] = ta.negative_volume_index(data["close"], data["volume"])

        data.fillna(method='bfill', inplace=True)

        return data

    except (AssertionError, Exception) as error:
        raise IndicatorsError(error)
        LOGGER.error(error)
コード例 #2
0
ファイル: indicators.py プロジェクト: azarshab-saeed/RLTrader
def add_indicators(df):
    df['RSI'] = ta.rsi(df["Close"])
    df['MFI'] = ta.money_flow_index(df["High"], df["Low"], df["Close"],
                                    df["Volume"])
    df['TSI'] = ta.tsi(df["Close"])
    df['UO'] = ta.uo(df["High"], df["Low"], df["Close"])
    df['AO'] = ta.ao(df["High"], df["Low"])

    df['MACD_diff'] = ta.macd_diff(df["Close"])
    df['Vortex_pos'] = ta.vortex_indicator_pos(df["High"], df["Low"],
                                               df["Close"])
    df['Vortex_neg'] = ta.vortex_indicator_neg(df["High"], df["Low"],
                                               df["Close"])
    df['Vortex_diff'] = abs(df['Vortex_pos'] - df['Vortex_neg'])
    df['Trix'] = ta.trix(df["Close"])
    df['Mass_index'] = ta.mass_index(df["High"], df["Low"])
    df['CCI'] = ta.cci(df["High"], df["Low"], df["Close"])
    df['DPO'] = ta.dpo(df["Close"])
    df['KST'] = ta.kst(df["Close"])
    df['KST_sig'] = ta.kst_sig(df["Close"])
    df['KST_diff'] = (df['KST'] - df['KST_sig'])
    df['Aroon_up'] = ta.aroon_up(df["Close"])
    df['Aroon_down'] = ta.aroon_down(df["Close"])
    df['Aroon_ind'] = (df['Aroon_up'] - df['Aroon_down'])

    df['BBH'] = ta.bollinger_hband(df["Close"])
    df['BBL'] = ta.bollinger_lband(df["Close"])
    df['BBM'] = ta.bollinger_mavg(df["Close"])
    df['BBHI'] = ta.bollinger_hband_indicator(df["Close"])
    df['BBLI'] = ta.bollinger_lband_indicator(df["Close"])
    df['KCHI'] = ta.keltner_channel_hband_indicator(df["High"], df["Low"],
                                                    df["Close"])
    df['KCLI'] = ta.keltner_channel_lband_indicator(df["High"], df["Low"],
                                                    df["Close"])
    df['DCHI'] = ta.donchian_channel_hband_indicator(df["Close"])
    df['DCLI'] = ta.donchian_channel_lband_indicator(df["Close"])

    df['ADI'] = ta.acc_dist_index(df["High"], df["Low"], df["Close"],
                                  df["Volume"])
    df['OBV'] = ta.on_balance_volume(df["Close"], df["Volume"])
    df['CMF'] = ta.chaikin_money_flow(df["High"], df["Low"], df["Close"],
                                      df["Volume"])
    df['FI'] = ta.force_index(df["Close"], df["Volume"])
    df['EM'] = ta.ease_of_movement(df["High"], df["Low"], df["Close"],
                                   df["Volume"])
    df['VPT'] = ta.volume_price_trend(df["Close"], df["Volume"])
    df['NVI'] = ta.negative_volume_index(df["Close"], df["Volume"])

    df['DR'] = ta.daily_return(df["Close"])
    df['DLR'] = ta.daily_log_return(df["Close"])

    df.fillna(method='bfill', inplace=True)

    return df
コード例 #3
0
    def channel(self, df, period=50):

        df.columns = map(str.lower, df.columns)
        df.sort_index(inplace=True)
        df = df.reset_index()

        if ta.donchian_channel_hband_indicator(df.close, period)[0] == 1.0:
            return 'long'

        elif ta.donchian_channel_lband_indicator(df.close, period)[0] == 1.0:
            return 'short'

        return 'none'
コード例 #4
0
def add_candle_indicators(df, l, ck, hk, lk, vk):
    df[l + 'rsi'] = ta.rsi(df[ck])
    df[l + 'mfi'] = ta.money_flow_index(df[hk], df[lk], df[ck], df[vk])
    df[l + 'tsi'] = ta.tsi(df[ck])
    df[l + 'uo'] = ta.uo(df[hk], df[lk], df[ck])
    df[l + 'ao'] = ta.ao(df[hk], df[lk])
    df[l + 'macd_diff'] = ta.macd_diff(df[ck])
    df[l + 'vortex_pos'] = ta.vortex_indicator_pos(df[hk], df[lk], df[ck])
    df[l + 'vortex_neg'] = ta.vortex_indicator_neg(df[hk], df[lk], df[ck])
    df[l + 'vortex_diff'] = abs(df[l + 'vortex_pos'] - df[l + 'vortex_neg'])
    df[l + 'trix'] = ta.trix(df[ck])
    df[l + 'mass_index'] = ta.mass_index(df[hk], df[lk])
    df[l + 'cci'] = ta.cci(df[hk], df[lk], df[ck])
    df[l + 'dpo'] = ta.dpo(df[ck])
    df[l + 'kst'] = ta.kst(df[ck])
    df[l + 'kst_sig'] = ta.kst_sig(df[ck])
    df[l + 'kst_diff'] = (df[l + 'kst'] - df[l + 'kst_sig'])
    df[l + 'aroon_up'] = ta.aroon_up(df[ck])
    df[l + 'aroon_down'] = ta.aroon_down(df[ck])
    df[l + 'aroon_ind'] = (df[l + 'aroon_up'] - df[l + 'aroon_down'])
    df[l + 'bbh'] = ta.bollinger_hband(df[ck])
    df[l + 'bbl'] = ta.bollinger_lband(df[ck])
    df[l + 'bbm'] = ta.bollinger_mavg(df[ck])
    df[l + 'bbhi'] = ta.bollinger_hband_indicator(df[ck])
    df[l + 'bbli'] = ta.bollinger_lband_indicator(df[ck])
    df[l + 'kchi'] = ta.keltner_channel_hband_indicator(df[hk], df[lk], df[ck])
    df[l + 'kcli'] = ta.keltner_channel_lband_indicator(df[hk], df[lk], df[ck])
    df[l + 'dchi'] = ta.donchian_channel_hband_indicator(df[ck])
    df[l + 'dcli'] = ta.donchian_channel_lband_indicator(df[ck])
    df[l + 'adi'] = ta.acc_dist_index(df[hk], df[lk], df[ck], df[vk])
    df[l + 'obv'] = ta.on_balance_volume(df[ck], df[vk])
    df[l + 'cmf'] = ta.chaikin_money_flow(df[hk], df[lk], df[ck], df[vk])
    df[l + 'fi'] = ta.force_index(df[ck], df[vk])
    df[l + 'em'] = ta.ease_of_movement(df[hk], df[lk], df[ck], df[vk])
    df[l + 'vpt'] = ta.volume_price_trend(df[ck], df[vk])
    df[l + 'nvi'] = ta.negative_volume_index(df[ck], df[vk])
    df[l + 'dr'] = ta.daily_return(df[ck])
    df[l + 'dlr'] = ta.daily_log_return(df[ck])
    df[l + 'ma50'] = df[ck].rolling(window=50).mean()
    df[l + 'ma100'] = df[ck].rolling(window=100).mean()
    df[l + '26ema'] = df[[ck]].ewm(span=26).mean()
    df[l + '12ema'] = df[[ck]].ewm(span=12).mean()
    df[l + 'macd'] = (df[l + '12ema'] - df[l + '26ema'])
    df[l + '100sd'] = df[[ck]].rolling(100).std()
    df[l + 'upper_band'] = df[l + 'ma100'] + (df[l + '100sd'] * 2)
    df[l + 'lower_band'] = df[l + 'ma100'] - (df[l + '100sd'] * 2)
    df[l + 'ema'] = df[ck].ewm(com=0.5).mean()
    df[l + 'momentum'] = df[ck] - 1
    return df
コード例 #5
0
ファイル: analysis.py プロジェクト: shrey1098/BSHDEV
    def dch():
        dch = ta.donchian_channel_hband(close, n=20, fillna=False)
        dchi = ta.donchian_channel_hband_indicator(close, n=20, fillna=False)
        dcl = ta.donchian_channel_lband(close, n=20, fillna=False)
        dcli = ta.donchian_channel_lband_indicator(close, n=20, fillna=False)

        if close[-1] == dch[-1]:
            vot_status_dc = "DCH Signals is: Strong Sell"
        elif dch[-1] > close[-1] > dch[-1] - 2:
            vot_status_dc = "DCH Signals is: Sell"
        elif dcl[-1] == close[-1]:
            vot_status_dc = "DCH Signals is: Strong Buy"
        elif dcl[-1] < close[-1] <= dcl[-1] + 2:
            vot_status_dc = "DCH Signals is: Buy"
        else:
            vot_status_dc = "DCH Signals is: Hold"
        return vot_status_dc
コード例 #6
0
def add_indicators(df):
    df['RSI'] = ta.rsi(df["Close"])
    df['TSI'] = ta.tsi(df["Close"])
    df['UO'] = ta.uo(df["High"], df["Low"], df["Close"])
    df['AO'] = ta.ao(df["High"], df["Low"])

    df['MACD_diff'] = ta.macd_diff(df["Close"])
    df['Vortex_pos'] = ta.vortex_indicator_pos(df["High"], df["Low"],
                                               df["Close"])
    df['Vortex_neg'] = ta.vortex_indicator_neg(df["High"], df["Low"],
                                               df["Close"])
    df['Vortex_diff'] = abs(df['Vortex_pos'] - df['Vortex_neg'])
    df['Trix'] = ta.trix(df["Close"])
    df['Mass_index'] = ta.mass_index(df["High"], df["Low"])
    df['CCI'] = ta.cci(df["High"], df["Low"], df["Close"])
    df['DPO'] = ta.dpo(df["Close"])
    df['KST'] = ta.kst(df["Close"])
    df['KST_sig'] = ta.kst_sig(df["Close"])
    df['KST_diff'] = (df['KST'] - df['KST_sig'])
    df['Aroon_up'] = ta.aroon_up(df["Close"])
    df['Aroon_down'] = ta.aroon_down(df["Close"])
    df['Aroon_ind'] = (df['Aroon_up'] - df['Aroon_down'])

    df['BBH'] = ta.bollinger_hband(df["Close"])
    df['BBL'] = ta.bollinger_lband(df["Close"])
    df['BBM'] = ta.bollinger_mavg(df["Close"])
    df['BBHI'] = ta.bollinger_hband_indicator(df["Close"])
    df['BBLI'] = ta.bollinger_lband_indicator(df["Close"])
    df['KCHI'] = ta.keltner_channel_hband_indicator(df["High"], df["Low"],
                                                    df["Close"])
    df['KCLI'] = ta.keltner_channel_lband_indicator(df["High"], df["Low"],
                                                    df["Close"])
    df['DCHI'] = ta.donchian_channel_hband_indicator(df["Close"])
    df['DCLI'] = ta.donchian_channel_lband_indicator(df["Close"])

    df['DR'] = ta.daily_return(df["Close"])
    df['DLR'] = ta.daily_log_return(df["Close"])

    df.fillna(method='bfill', inplace=True)

    return df
コード例 #7
0
ta_df['KCL'] = ta.keltner_channel_lband(
    df["High"],
    df["Low"],
    df["Close"])
ta_df['KCHI'] = ta.keltner_channel_hband_indicator(df["High"],
                                                   df["Low"],
                                                   df["Close"])
ta_df['KCLI'] = ta.keltner_channel_lband_indicator(df["High"],
                                                   df["Low"],
                                                   df["Close"])
ta_df['DCH'] = ta.donchian_channel_hband(
    df["Close"])
ta_df['DCL'] = ta.donchian_channel_lband(
    df["Close"])
ta_df['DCHI'] = ta.donchian_channel_hband_indicator(df["Close"])
ta_df['DCLI'] = ta.donchian_channel_lband_indicator(df["Close"])

ta_df['ADI'] = ta.acc_dist_index(df["High"],
                                 df["Low"],
                                 df["Close"],
                                 df["Volume BTC"])
ta_df['OBV'] = ta.on_balance_volume(df["Close"],
                                    df["Volume BTC"])
ta_df['OBVM'] = ta.on_balance_volume_mean(
    df["Close"],
    df["Volume BTC"])
ta_df['CMF'] = ta.chaikin_money_flow(df["High"],
                                     df["Low"],
                                     df["Close"],
                                     df["Volume BTC"])
ta_df['FI'] = ta.force_index(df["Close"],
コード例 #8
0
def get_data(context, data_, window):
    # Crear ventana de datos.

    h1 = data_.history(
        context.symbols,
        context.row_features,
        bar_count=window,
        frequency=str(context.bar_period) + "T",
    )

    h1 = h1.swapaxes(2, 0)

    norm_data = []
    close_prices = []

    for i, asset in enumerate(context.assets):
        data = h1.iloc[i]
        close = h1.iloc[i].close
        if context.include_ha:
            ha = heikenashi(data)
            data = pd.concat((data, ha), axis=1)

        for period in [3, 6, 8, 10, 15, 20]:
            data["rsi" + str(period)] = ta.rsi(data.close,
                                               n=period,
                                               fillna=True)
            data["stoch" + str(period)] = ta.stoch(data.high,
                                                   data.low,
                                                   data.close,
                                                   n=period,
                                                   fillna=True)
            data["stoch_signal" + str(period)] = ta.stoch_signal(
                high=data.high,
                low=data.low,
                close=data.close,
                n=period,
                d_n=3,
                fillna=True)

            data["dpo" + str(period)] = ta.dpo(close=data.close,
                                               n=period,
                                               fillna=True)
            data["atr" + str(period)] = ta.average_true_range(high=data.high,
                                                              low=data.low,
                                                              close=data.close,
                                                              n=period,
                                                              fillna=True)

        for period in [6, 7, 8, 9, 10]:
            data["williams" + str(period)] = ta.wr(high=data.high,
                                                   low=data.low,
                                                   close=data.close,
                                                   lbp=period,
                                                   fillna=True)
        for period in [12, 13, 14, 15]:
            data["proc" + str(period)] = ta.trix(close=data.close,
                                                 n=period,
                                                 fillna=True)

        data["macd_diff"] = ta.macd_diff(close=data.close,
                                         n_fast=15,
                                         n_slow=30,
                                         n_sign=9,
                                         fillna=True)

        data["macd_signal"] = ta.macd_signal(close=data.close,
                                             n_fast=15,
                                             n_slow=30,
                                             n_sign=9,
                                             fillna=True)

        data["bb_high_indicator"] = ta.bollinger_hband_indicator(
            close=data.close, n=15, ndev=2, fillna=True)

        data["bb_low_indicator"] = ta.bollinger_lband_indicator(
            close=data.close, n=15, ndev=2, fillna=True)

        data["dc_high_indicator"] = ta.donchian_channel_hband_indicator(
            close=data.close, n=20, fillna=True)

        data["dc_low_indicator"] = ta.donchian_channel_lband_indicator(
            close=data.close, n=20, fillna=True)

        data["ichimoku_a"] = ta.ichimoku_a(high=data.high,
                                           low=data.low,
                                           n1=9,
                                           n2=26,
                                           fillna=True)

        data.fillna(method="bfill")

        # Normalizar los valores
        for feature in data.columns:
            norm_feature = preprocessing.normalize(
                data[feature].values.reshape(-1, 1), axis=0)
            data[feature] = pd.DataFrame(data=norm_feature,
                                         index=data.index,
                                         columns=[feature])

        norm_data.append(data.values)
        close_prices.append(close)
        context.features = data.columns

    return np.array(norm_data), np.array(close_prices)
コード例 #9
0
ファイル: Test_TA_Lib.py プロジェクト: toimfortes/TALibraries
                                                price['Volume'],
                                                fillna=True)
X['negative_volume_index'] = ta.negative_volume_index(price['Adj. Close'],
                                                      price['Volume'],
                                                      fillna=True)
X['average_true_range'] = ta.average_true_range(price['High'],
                                                price['Low'],
                                                price['Adj. Close'],
                                                n=14,
                                                fillna=True)
# X['KCU'] = ta.keltner_channel_hband_indicator(price['High'], price['Low'], price['Adj. Close'], n=10, fillna=True)
X['keltner_channel_lband_indicator'] = ta.keltner_channel_lband_indicator(
    price['High'], price['Low'], price['Adj. Close'], n=10, fillna=True)
X['donchian_channel_hband_indicator'] = ta.donchian_channel_hband_indicator(
    price['Adj. Close'], n=20, fillna=True)
X['donchian_channel_lband_indicator'] = ta.donchian_channel_lband_indicator(
    price['Adj. Close'], n=20, fillna=True)
X['macd_signal'] = ta.macd_signal(price['Adj. Close'],
                                  n_fast=12,
                                  n_slow=26,
                                  n_sign=9,
                                  fillna=True)
X['adx_pos'] = ta.adx_pos(price['High'],
                          price['Low'],
                          price['Adj. Close'],
                          n=14,
                          fillna=True)
X['adx_neg'] = ta.adx_neg(price['High'],
                          price['Low'],
                          price['Adj. Close'],
                          n=14,
                          fillna=True)
コード例 #10
0
    def get_trayectory(self, t_intervals):
        """
        :param t_intervals: número de intervalos en cada trayectoria
        :return: Datos con características de la trayectoria sintética y precios de cierre en bruto de al misma
        """
        trayectories = []
        closes = []
        p = True
        for i, asset in enumerate(self.context.assets):
            synthetic_return = np.exp(
                self.drift[i] + self.stdev[i] * norm.ppf(np.random.rand((t_intervals * self.frequency) + self.frequency, 1)))
            initial_close = self.close[i, -1]
            synthetic_close = np.zeros_like(synthetic_return)
            synthetic_close[0] = initial_close

            for t in range(1, synthetic_return.shape[0]):
                synthetic_close[t] = synthetic_close[t - 1] * synthetic_return[t]

            OHLC = []

            for t in range(synthetic_return.shape[0]):
                if t % self.frequency == 0 and t > 0:
                    open = synthetic_close[t - self.frequency]
                    high = np.max(synthetic_close[t - self.frequency: t])
                    low = np.min(synthetic_close[t - self.frequency: t])
                    close = synthetic_close[t]

                    OHLC.append([open, high, close, low])

            data = pd.DataFrame(data=OHLC, columns=["open", "high", "low", "close"])

            close = data.close

            if self.context.include_ha:
                ha = heikenashi(data)
                data = pd.concat((data, ha), axis=1)

            for period in [3, 6, 8, 10, 15, 20]:
                data["rsi" + str(period)] = ta.rsi(data.close, n=period, fillna=True)
                data["stoch" + str(period)] = ta.stoch(data.high, data.low, data.close, n=period, fillna=True)
                data["stoch_signal" + str(period)] = ta.stoch_signal(high=data.high,
                                                                     low=data.low,
                                                                     close=data.close,
                                                                     n=period,
                                                                     d_n=3,
                                                                     fillna=True)

                data["dpo" + str(period)] = ta.dpo(close=data.close,
                                                   n=period,
                                                   fillna=True)

                data["atr" + str(period)] = ta.average_true_range(high=data.high,
                                                                  low=data.low,
                                                                  close=data.close,
                                                                  n=period,
                                                                  fillna=True)

            for period in [6, 7, 8, 9, 10]:
                data["williams" + str(period)] = ta.wr(high=data.high,
                                                       low=data.low,
                                                       close=data.close,
                                                       lbp=period,
                                                       fillna=True)
            for period in [12, 13, 14, 15]:
                data["proc" + str(period)] = ta.trix(close=data.close,
                                                     n=period,
                                                     fillna=True)

            data["macd_diff"] = ta.macd_diff(close=data.close,
                                             n_fast=15,
                                             n_slow=30,
                                             n_sign=9,
                                             fillna=True)

            data["macd_signal"] = ta.macd_signal(close=data.close,
                                                 n_fast=15,
                                                 n_slow=30,
                                                 n_sign=9,
                                                 fillna=True)

            data["bb_high_indicator"] = ta.bollinger_hband_indicator(close=data.close,
                                                                     n=15,
                                                                     ndev=2,
                                                                     fillna=True)

            data["bb_low_indicator"] = ta.bollinger_lband_indicator(close=data.close,
                                                                    n=15,
                                                                    ndev=2,
                                                                    fillna=True)

            data["dc_high_indicator"] = ta.donchian_channel_hband_indicator(close=data.close,
                                                                            n=20,
                                                                            fillna=True)

            data["dc_low_indicator"] = ta.donchian_channel_lband_indicator(close=data.close,
                                                                           n=20,
                                                                           fillna=True)

            data["ichimoku_a"] = ta.ichimoku_a(high=data.high,
                                               low=data.low,
                                               n1=9,
                                               n2=26,
                                               fillna=True)

            data.fillna(method="bfill")

            # Normalizar los valores
            for feature in data.columns:
                norm_feature = preprocessing.normalize(data[feature].values.reshape(-1, 1), axis=0)
                data[feature] = pd.DataFrame(data=norm_feature, index=data.index, columns=[feature])

            self.assets = data.columns

            trayectories.append(data.values)
            closes.append(close)

        return np.array(trayectories), np.array(closes)
コード例 #11
0
ファイル: dataUtils.py プロジェクト: reiserbc/Sredictio
def add_technical_indicators(df):
    """
    Args:
        df (pd.DataFrame): The processed dataframe returned by `process_data`.

    Returns:
        pd.DataFrame: The updated dataframe with the technical indicators inside.

    Acknowledgements:
        - Thanks for Adam King for this compilation of technical indicators!
          The original file and code can be found here:
          https://github.com/notadamking/RLTrader/blob/e5b83b1571f9fcfa6a67a2a810222f1f1751996c/util/indicators.py

    """

    # Add momentum indicators
    df["AO"] = ta.ao(df["High"], df["Low"])
    df["MFI"] = ta.money_flow_index(df["High"], df["Low"], df["Close"],
                                    df["Volume"])
    df["RSI"] = ta.rsi(df["Close"])
    df["TSI"] = ta.tsi(df["Close"])
    df["UO"] = ta.uo(df["High"], df["Low"], df["Close"])

    # Add trend indicators
    df["Aroon_up"] = ta.aroon_up(df["Close"])
    df["Aroon_down"] = ta.aroon_down(df["Close"])
    df["Aroon_ind"] = (df["Aroon_up"] - df["Aroon_down"])
    df["CCI"] = ta.cci(df["High"], df["Low"], df["Close"])
    df["DPO"] = ta.dpo(df["Close"])
    df["KST"] = ta.kst(df["Close"])
    df["KST_sig"] = ta.kst_sig(df["Close"])
    df["KST_diff"] = (df["KST"] - df["KST_sig"])
    df["MACD_diff"] = ta.macd_diff(df["Close"])
    df["Mass_index"] = ta.mass_index(df["High"], df["Low"])
    df["Trix"] = ta.trix(df["Close"])
    df["Vortex_pos"] = ta.vortex_indicator_pos(df["High"], df["Low"],
                                               df["Close"])
    df["Vortex_neg"] = ta.vortex_indicator_neg(df["High"], df["Low"],
                                               df["Close"])
    df["Vortex_diff"] = abs(df["Vortex_pos"] - df["Vortex_neg"])

    # Add volatility indicators
    df["BBH"] = ta.bollinger_hband(df["Close"])
    df["BBL"] = ta.bollinger_lband(df["Close"])
    df["BBM"] = ta.bollinger_mavg(df["Close"])
    df["BBHI"] = ta.bollinger_hband_indicator(df["Close"])
    df["BBLI"] = ta.bollinger_lband_indicator(df["Close"])
    df["KCHI"] = ta.keltner_channel_hband_indicator(df["High"], df["Low"],
                                                    df["Close"])
    df["KCLI"] = ta.keltner_channel_lband_indicator(df["High"], df["Low"],
                                                    df["Close"])
    df["DCHI"] = ta.donchian_channel_hband_indicator(df["Close"])
    df["DCLI"] = ta.donchian_channel_lband_indicator(df["Close"])

    # Volume indicators
    df["ADI"] = ta.acc_dist_index(df["High"], df["Low"], df["Close"],
                                  df["Volume"])
    df["CMF"] = ta.chaikin_money_flow(df["High"], df["Low"], df["Close"],
                                      df["Volume"])
    df["EM"] = ta.ease_of_movement(df["High"], df["Low"], df["Close"],
                                   df["Volume"])
    df["FI"] = ta.force_index(df["Close"], df["Volume"])
    df["NVI"] = ta.negative_volume_index(df["Close"], df["Volume"])
    df["OBV"] = ta.on_balance_volume(df["Close"], df["Volume"])
    df["VPT"] = ta.volume_price_trend(df["Close"], df["Volume"])

    # Add miscellaneous indicators
    df["DR"] = ta.daily_return(df["Close"])
    df["DLR"] = ta.daily_log_return(df["Close"])

    # Fill in NaN values
    df.fillna(method="bfill", inplace=True)  # First try `bfill`
    df.fillna(value=0,
              inplace=True)  # Then replace the rest of the NANs with 0s

    return df