19 lines
528 B
Python
19 lines
528 B
Python
from numpy import where
|
|
from pandas import DataFrame, Series
|
|
|
|
from indicators import sma, rsi
|
|
|
|
def rsi_25_75(data: DataFrame) -> Series:
|
|
"""
|
|
Calculate signals for the RSI 25 / 75 strategy.
|
|
|
|
Returns a Series with 'L' for long signals and 'N' otherwise.
|
|
"""
|
|
ma_200 = sma(data, period = 200)
|
|
rsi_4 = rsi(data, period = 4)
|
|
|
|
above_ma_200 = data['Close'] > ma_200
|
|
rsi_below_25 = rsi_4 < 25
|
|
|
|
conditions = above_ma_200 & rsi_below_25
|
|
return Series(where(conditions, 'L', 'N'), index = data.index) |