swing-trading-dashboard/strategies/large_moves_down.py

10 lines
380 B
Python
Raw Normal View History

from pandas import DataFrame, Series
def signals(data: DataFrame) -> Series:
"""
Generate swing trading signals based the Large Moves (Down) strategy.
Returns a Series with 'L' for long signals and 'N' otherwise.
"""
percent_change = (data['Open'] - data['Close']) / data['Open']
return percent_change.apply(lambda change: 'L' if change >= 0.01 else 'N')