Add script for generating down days in a row trading signals
This commit is contained in:
parent
e8eceb2c59
commit
89029dd7a5
11
strategies/down_days_in_a_row.py
Normal file
11
strategies/down_days_in_a_row.py
Normal file
@ -0,0 +1,11 @@
|
||||
from pandas import DataFrame, Series
|
||||
|
||||
def signals(data: DataFrame) -> Series:
|
||||
"""
|
||||
Generate signals for entering a long trade when the market's
|
||||
close price is lower for 3 consecutive days.
|
||||
|
||||
Returns a Series with 'L' for long signals and 'N' otherwise.
|
||||
"""
|
||||
lower_close = data['Close'] < data['Close'].shift(1)
|
||||
return (lower_close & lower_close.shift(1) & lower_close.shift(2)).apply(lambda x: 'L' if x else 'N')
|
Loading…
Reference in New Issue
Block a user