Add script for generating High Volume Days strategy signals
This commit is contained in:
parent
78be11ee9d
commit
5ba183d06e
17
strategies/high_volume_days.py
Normal file
17
strategies/high_volume_days.py
Normal file
@ -0,0 +1,17 @@
|
||||
from pandas import DataFrame, Series
|
||||
|
||||
def signals(data: DataFrame) -> Series:
|
||||
"""
|
||||
Generate swing trading signals based on the High Volume Days strategy.
|
||||
|
||||
Returns a Series with 'L' for long signals and 'N' otherwise.
|
||||
"""
|
||||
data['200_MA'] = data['Close'].rolling(window = 200).mean()
|
||||
above_200_ma = data['Close'] > data['200_MA']
|
||||
|
||||
highest_volume = data['Total Volume'] == data['Total Volume'].rolling(window = 5).max()
|
||||
close_lower_than_open = data['Close'] < data['Open']
|
||||
|
||||
signal_condition = above_200_ma & highest_volume & close_lower_than_open
|
||||
signals = signal_condition.apply(lambda condition: 'L' if condition else 'N')
|
||||
return signals
|
Loading…
Reference in New Issue
Block a user