Add 5-Period RSI strategy implementation
This commit is contained in:
parent
0a5c058fe0
commit
723317403d
15
strategies/five_period_rsi.py
Normal file
15
strategies/five_period_rsi.py
Normal 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)
|
Loading…
Reference in New Issue
Block a user