From 11c1e7f06b9d847ed98e66800857e75a9d34a17f Mon Sep 17 00:00:00 2001 From: moshferatu Date: Tue, 12 Nov 2024 08:01:08 -0800 Subject: [PATCH] Add script for generating short-term lows strategy signals --- strategies/short_term_lows.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 strategies/short_term_lows.py diff --git a/strategies/short_term_lows.py b/strategies/short_term_lows.py new file mode 100644 index 0000000..cad0b6f --- /dev/null +++ b/strategies/short_term_lows.py @@ -0,0 +1,10 @@ +from pandas import DataFrame, Series + +def signals(data: DataFrame) -> Series: + """ + Generate signals for entering a long trade when the market makes a 10-day low. + + Returns a series with 'L' for long signals and 'N' otherwise. + """ + ten_day_low = data['Low'] == data['Low'].rolling(window = 10, min_periods = 10).min() + return ten_day_low.apply(lambda x: 'L' if x else 'N') \ No newline at end of file