from pandas import DataFrame, Series from daily_data import get_daily_data def signals(data: DataFrame) -> Series: """ Generate signals based on the HILO Index Lows strategy. Returns a Series with 'L' for long signals and 'N' for no signal. """ above_200_ma = data['Close'] > data['Close'].rolling(window = 200).mean() start_date = data['Date'].min() end_date = data['Date'].max() new_highs = get_daily_data(symbol = 'FINH.Z', start_date = start_date, end_date = end_date) new_lows = get_daily_data(symbol = 'FINL.Z', start_date = start_date, end_date = end_date) hilo_index = new_highs['Close'] - new_lows['Close'] hilo_5_day_low = hilo_index == hilo_index.rolling(window = 5).min() signals = Series('N', index = data.index) signals[above_200_ma & hilo_5_day_low] = 'L' return signals