From 8de56aae8e5d91faf32b17278ddb302f0b277bde Mon Sep 17 00:00:00 2001 From: moshferatu Date: Thu, 31 Oct 2024 00:16:10 -0700 Subject: [PATCH] Add script for generating swing trading signals based on Lower Lows strategy --- strategies/lower_lows.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 strategies/lower_lows.py diff --git a/strategies/lower_lows.py b/strategies/lower_lows.py new file mode 100644 index 0000000..75ff5cd --- /dev/null +++ b/strategies/lower_lows.py @@ -0,0 +1,11 @@ +from pandas import DataFrame, Series + +def signals(data: DataFrame) -> Series: + """ + Generate signals for entering a long trade when the market makes + a lower low for 2 consecutive days. + + Returns a Series with 'L' for long signals and 'N' otherwise. + """ + lower_low = data['Low'].shift(1) > data['Low'] + return (lower_low & lower_low.shift(1)).apply(lambda x: 'L' if x else 'N') \ No newline at end of file