Initial commit of ConnorsRSI strategy
This commit is contained in:
parent
02bb7a4d67
commit
9aebe2f135
19
strategies/connors_rsi.py
Normal file
19
strategies/connors_rsi.py
Normal file
@ -0,0 +1,19 @@
|
||||
from numpy import where
|
||||
from pandas import DataFrame, Series
|
||||
|
||||
from indicators import sma, connors_rsi as crsi
|
||||
|
||||
def connors_rsi(data: DataFrame) -> Series:
|
||||
"""
|
||||
Calculate signals for the ConnorsRSI strategy.
|
||||
|
||||
Returns a Series with 'L' for long signals and 'N' otherwise.
|
||||
"""
|
||||
ma_200 = sma(data, period = 200)
|
||||
connors_rsi_values = crsi(data)
|
||||
|
||||
above_ma_200 = data['Close'] > ma_200
|
||||
connors_rsi_below_15 = connors_rsi_values < 15
|
||||
|
||||
conditions = above_ma_200 & connors_rsi_below_15
|
||||
return Series(where(conditions, 'L', 'N'), index = data.index)
|
Loading…
Reference in New Issue
Block a user