16 lines
433 B
Python
16 lines
433 B
Python
from numpy import where
|
|
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 = where(rsi_below_35, 'L', 'N')
|
|
return Series(signals, index = data.index) |