def setup(self, df): self.df = df AddIndicator(self.df, "rsi", "rsi_" + str(self.rsi_len_1), self.rsi_len_1) AddIndicator(self.df, "rsi", "rsi_" + str(self.rsi_len_2), self.rsi_len_2) AddIndicator(self.df, "rsi", "rsi_" + str(self.rsi_len_3), self.rsi_len_3)
def setUp(self, df): self.df = df if self.indicators is not None: # Create all asked indicators for indicator in self.indicators: exclude_keys = set( ['indicator_name', 'col_name', 'indicator_function']) args = [ indicator[k] for k in set(list(indicator.keys())) - exclude_keys ] if 'indicator_function' in indicator.keys(): col_name = indicator['col_name'] indicator_function = indicator['indicator_function'] ret = indicator_function(self.df, *args) cols_dict = dict() i = 0 for cname in col_name: cols_dict[cname] = ret[i] i += 1 self.df = self.df.assign(**cols_dict) else: # Create a list of all arguments that are not the # indicator name or column name AddIndicator(self.df, indicator['indicator_name'], indicator['col_name'], *args)
def Maine(): exchange = Binance() symbol = 'BTCUSDT' df = exchange.getOHLCV(symbol, '1d') AddIndicator(df, 'sma', 'volma', 'volume', 10) signal = df.loc[df['volume'] > 2.4 * df['volma']] s_list = [ dict(name='S/R', points=[(row['time'], row['high']) if row['close'] > row['open'] else (row['time'], row['low']) for i, row in signal.iterrows()]) ] HA(df, ['open', 'high', 'low', 'close']) ha_df = df ha_df['open'] = df['HA_open'] ha_df['high'] = df['HA_high'] ha_df['low'] = df['HA_low'] ha_df['close'] = df['HA_close'] lines = [] last_time = df['time'][len(df) - 1] for s in s_list[0]['points']: line = go.layout.Shape( type="line", x0=s[0], y0=s[1], x1=last_time, y1=s[1], ) lines.append(line) PlotData( ha_df, show_plot=True, signals=s_list, plot_shapes=lines, plot_indicators=[dict(name='volma', title="Volume MA", yaxis='y2')])
def setup(self, df): self.df = df AddIndicator(self.df, "ott", ["var", "ott"], self.pds, self.percent)
def setup(self, df): self.df = df AddIndicator(self.df, "smoothrng", "smoothrng_"+str(self.per), self.per, self.mult)