Add script for generating swing trading signals based on Lower Lows strategy

This commit is contained in:
moshferatu 2024-10-31 00:16:10 -07:00
parent 4046a4b12c
commit 8de56aae8e

11
strategies/lower_lows.py Normal file
View File

@ -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')