Add script for generating Connors VIX Reversal 1 swing trading signals
This commit is contained in:
parent
f92a9a3740
commit
e3f150213e
23
strategies/vix_reversal_1.py
Normal file
23
strategies/vix_reversal_1.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from pandas import DataFrame, Series
|
||||||
|
|
||||||
|
from ohlc import ohlc
|
||||||
|
|
||||||
|
def signals(data: DataFrame) -> Series:
|
||||||
|
"""
|
||||||
|
Generate long signals based on the VIX 15-day high 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 = ohlc(symbol='VIX.XO', start_date=start_date, end_date=end_date)
|
||||||
|
|
||||||
|
vix_15_day_high = vix_data['High'] == vix_data['High'].rolling(window = 15).max()
|
||||||
|
|
||||||
|
vix_close_below_open = vix_data['Close'] < vix_data['Open']
|
||||||
|
|
||||||
|
signals = Series('N', index = data.index)
|
||||||
|
signals[above_200_ma & vix_15_day_high & vix_close_below_open] = 'L'
|
||||||
|
return signals
|
Loading…
Reference in New Issue
Block a user