def populate_indicators(self, dataframe: DataFrame) -> DataFrame: """ Adds several different TA indicators to the given DataFrame Performance Note: For the best performance be frugal on the number of indicators you are using. Let uncomment only the indicator you are using in your strategies or your hyperopt configuration, otherwise you will waste your memory and CPU usage. """ # Commodity Channel Index: values Oversold:<-100, Overbought:>100 dataframe['cci'] = ta.CCI(dataframe) # MFI dataframe['mfi'] = ta.MFI(dataframe) # CMO dataframe['cmo'] = ta.CMO(dataframe) return dataframe
def technical_index(self): df = self.max_min_price() df2 = self.institutional_investors() df['RSI'] = abstract.RSI(df) / 100 df['CMO'] =(abstract.CMO(df)+100) / (2 *100) df['MACD'] =(abstract.MACD(df)['macd']+abstract.MACD(df)['macd'].max()) / (2 *abstract.MACD(df)['macd'].max()) df['WILLR'] =(abstract.WILLR(df)+100) / (2 *100) df['WMA'] =abstract.WMA(df) / abstract.WMA(df).max() df['PPO'] =(abstract.PPO(df)+abstract.PPO(df).max()) / (2 *abstract.PPO(df).max()) df['EMA'] =abstract.EMA(df) / abstract.EMA(df).max() df['ROC'] =(abstract.ROC(df)+abstract.ROC(df).max()) / (2 *abstract.ROC(df).max()) df['SMA'] =abstract.SMA(df) / abstract.SMA(df).max() df['TEMA'] =abstract.TEMA(df) / abstract.TEMA(df).max() df['CCI'] =(abstract.CCI(df)+abstract.CCI(df).max()) / (2 *abstract.CCI(df).max()) df['investment_trust'] = (df2['investment_trust'] + df2['investment_trust'].max()) / (2*df2['investment_trust'].max()) df['foreign_investor'] = (df2['foreign_investor'] + df2['foreign_investor'].max()) / (2*df2['foreign_investor'].max()) df = df.drop(columns=['volume', 'open', 'high', 'low', 'close', 'close_max', 'close_min']) df = df.dropna() return df
def evaluate_cmo(self, period=20, prefix="cmo", impact_buy=1, impact_sell=1): """ evaluates the cmo :param dataframe: :param period: :param prefix: :return: """ self._weights(impact_buy, impact_sell) dataframe = self.dataframe name = f"{prefix}_{period}" dataframe[name] = ta.CMO(dataframe, timeperiod=period) dataframe.loc[((dataframe[name] < -50)), f"buy_{name}"] = 1 * impact_buy dataframe.loc[((dataframe[name] > 50)), f"sell_{name}"] = 1 * impact_sell
def evaluate_cmo(self, period=20, prefix="cmo", impact_buy=1, impact_sell=1): """ evaluates the osc :param dataframe: :param period: :param prefix: :return: """ self._weights(impact_buy, impact_sell) dataframe = self.dataframe name = '{}_{}'.format(prefix, period) dataframe[name] = ta.CMO(dataframe, timeperiod=period) dataframe.loc[((dataframe[name] < -50)), 'buy_{}'.format(name)] = (1 * impact_buy) dataframe.loc[((dataframe[name] > 50)), 'sell_{}'.format(name)] = (1 * impact_sell)
def __countCMO(self): self.cmo = ta.CMO(self.stock.inputs)
def CMO(self): cmo = abstract.CMO(self.company_stock, timeperiod=14) self.company_stock['CMO'] = cmo