From 723317403d624de97c0ad6cba75fd7b9bb3ce2e9 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Mon, 6 Jan 2025 10:47:13 -0800 Subject: [PATCH] Add 5-Period RSI strategy implementation --- strategies/five_period_rsi.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 strategies/five_period_rsi.py diff --git a/strategies/five_period_rsi.py b/strategies/five_period_rsi.py new file mode 100644 index 0000000..cd44776 --- /dev/null +++ b/strategies/five_period_rsi.py @@ -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) \ No newline at end of file