diff --git a/strategies/vix_above_moving_average.py b/strategies/vix_above_moving_average.py new file mode 100644 index 0000000..52a7972 --- /dev/null +++ b/strategies/vix_above_moving_average.py @@ -0,0 +1,23 @@ +from pandas import DataFrame, Series + +from daily_data import get_daily_data + +def signals(data: DataFrame) -> Series: + """ + Generate long signals based on the VIX Above Moving Average strategy. + + Returns a Series with 'L' for long signals and 'N' for no signal. + """ + ma_200 = data['Close'].rolling(window = 200).mean() + above_200_ma = data['Close'] > ma_200 + + 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_10 = vix_data['Close'].rolling(window = 10).mean() + vix_close_10_percent_above_ma = vix_data['Close'] >= (1.1 * vix_ma_10) + + signals = Series('N', index = data.index) + signals[above_200_ma & vix_close_10_percent_above_ma] = 'L' + return signals \ No newline at end of file