swing-trading-dashboard/strategies/short_term_lows.py

10 lines
391 B
Python
Raw Normal View History

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