Add script for generating swing trading signals based on Connors VIX Reversal 3 strategy
This commit is contained in:
parent
428742371e
commit
916dd115c1
21
strategies/vix_reversal_3.py
Normal file
21
strategies/vix_reversal_3.py
Normal file
@ -0,0 +1,21 @@
|
||||
from pandas import DataFrame, Series
|
||||
|
||||
from daily_data import get_daily_data
|
||||
|
||||
def signals(data: DataFrame) -> Series:
|
||||
"""
|
||||
Generate long signals based on the Connors VIX Reversal 3 strategy.
|
||||
Returns a Series with 'L' for long signals and 'N' for no signal.
|
||||
"""
|
||||
start_date = data['Date'].min()
|
||||
end_date = data['Date'].max()
|
||||
vix_data = get_daily_data(symbol = 'VIX.XO', start_date = start_date, end_date = end_date)
|
||||
|
||||
vix_ma_50 = vix_data['Close'].rolling(window = 50).mean()
|
||||
|
||||
vix_low_above_50_ma = vix_data['Low'] > vix_ma_50
|
||||
vix_close_10_percent_above_ma = vix_data['Close'] >= (1.1 * vix_ma_50)
|
||||
|
||||
signals = Series('N', index = data.index)
|
||||
signals[vix_low_above_50_ma & vix_close_10_percent_above_ma] = 'L'
|
||||
return signals
|
Loading…
Reference in New Issue
Block a user