Add script for generating Turnaround Tuesday (or Monday) swing trading signals
This commit is contained in:
parent
99a7165ffb
commit
dc8e340294
16
strategies/turnaround.py
Normal file
16
strategies/turnaround.py
Normal file
@ -0,0 +1,16 @@
|
||||
from pandas import DataFrame, Series, to_datetime
|
||||
|
||||
def signals(data: DataFrame) -> Series:
|
||||
"""
|
||||
Generate long signals based on the day of the week and downward close conditions.
|
||||
|
||||
Returns a Series with 'L' for long signals and 'N' for no signal.
|
||||
"""
|
||||
date_series = to_datetime(data['Date'], errors = 'coerce')
|
||||
monday_or_tuesday = date_series.dt.dayofweek.isin([0, 1])
|
||||
lower_past_two_days = (data['Close'] < data['Close'].shift(1)) & (data['Close'].shift(1) < data['Close'].shift(2))
|
||||
|
||||
signals = Series('N', index=data.index)
|
||||
signals[monday_or_tuesday & lower_past_two_days] = 'L'
|
||||
|
||||
return signals
|
Loading…
Reference in New Issue
Block a user