From 916dd115c1ddf0f90a60f754c440719095057f9e Mon Sep 17 00:00:00 2001 From: moshferatu Date: Wed, 13 Nov 2024 10:53:58 -0800 Subject: [PATCH] Add script for generating swing trading signals based on Connors VIX Reversal 3 strategy --- strategies/vix_reversal_3.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 strategies/vix_reversal_3.py diff --git a/strategies/vix_reversal_3.py b/strategies/vix_reversal_3.py new file mode 100644 index 0000000..c304452 --- /dev/null +++ b/strategies/vix_reversal_3.py @@ -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 \ No newline at end of file