βοΈAvailable Strategies
Our Telegram bot offers a variety of pre-defined trading strategies suitable for different trading styles and market conditions.
def compute_rsi(data, period=14):
"""Compute the RSI for a given data set and RSI period."""
delta = data['close'].diff()
gain = (delta.where(delta > 0, 0)).fillna(0)
loss = (-delta.where(delta < 0, 0)).fillna(0)
avg_gain = gain.rolling(window=period).mean()
avg_loss = loss.rolling(window=period).mean()
rs = avg_gain / avg_loss
rsi = 100 - (100 / (1 + rs))
return rsi
def generate_rsi_signals(data, rsi):
"""Generate buy and sell signals based on RSI."""
data['buy_signal'] = rsi < 30 # RSI below 30 indicates oversold conditions
data['sell_signal'] = rsi > 70 # RSI above 70 indicates overbought conditions
return data
def get_current_rsi_trade_signal(df):
"""
Determine the current trade signal based on the RSI strategy.
Args:
df (pandas.DataFrame): The DataFrame containing the price data and RSI values.
Returns:
str: 'BUY' if buying conditions are met, 'SELL' if selling conditions are met,
or None if conditions for neither are met.
"""
if df.empty:
return None
current_rsi = df['rsi'].iloc[-1]
rsi_buy_threshold = 30
rsi_sell_threshold = 70
if current_rsi < rsi_buy_threshold:
return 'BUY'
elif current_rsi > rsi_sell_threshold:
return 'SELL'
else:
return NoneLast updated