Add script for generating short-term lows strategy signals

This commit is contained in:
moshferatu 2024-11-12 08:01:08 -08:00
parent f088539163
commit 11c1e7f06b

View File

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