Add 5-Period RSI strategy implementation

This commit is contained in:
moshferatu 2025-01-06 10:47:13 -08:00
parent 0a5c058fe0
commit 723317403d

View File

@ -0,0 +1,15 @@
import numpy as np
from pandas import DataFrame, Series
from indicators import rsi
def five_period_rsi(data: DataFrame) -> Series:
"""
Generate signals based on the 5-period RSI strategy.
Returns a Series with 'L' for long signals and 'N' otherwise.
"""
rsi_5 = rsi(data, period = 5)
rsi_below_35 = rsi_5 < 35
signals = np.where(rsi_below_35, 'L', 'N')
return Series(signals, index = data.index)