Original link:http://tecdat.cn/?p=23130 

Original source:Tuoduan numbers according to the public account of the tribe

 To

The objective of this article is to create a synthetic volatility index that 1) mirrors the VIX as much as possible when applied to the S&P 500; 2) Rely entirely on price as input, so it can be applied to any market index.

The solution described is to synthesize the volatility index. \> Mov(ATR(1)/C,20,S)

Now I’ll try the code.

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # load historical data #***************************************************************** tickers = 'SP=^GSPC,VIX=^VIX' # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # drawing data #***************************************************************** layout(1:3) plot(SP) plot.legend('SP',SP)

matplot(scale(temp)
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # test strategy #***************************************************************** vol= SMA( SP),1/ Cl), 20 ) high= vol > SMA(vol, 40) low= vol< SMA(vol, 40) plot(SP\[index\], type='l', plotX=F, x.highlight = highlight)

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # test strategy #***************************************************************** models = list() data$weight\[\] = NA run(data) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # report #***************************************************************** #performance(models, T)

 

This estimate is similar to other volatility estimates provided by the TTR package.

print(cor(, use='complete.obs',method='pearson'))

 


Most popular insight

1. Use LSTM and PyTorch for time series prediction in Python

2. Use LSTM to predict and analyze time series in Python

3. Use R language to analyze time series (ARIMA, exponential smoothing)

4. Multiple Copula-GARCH-model time series prediction in R language

5. R language Copulas and financial time series cases

6. Use R language random wave model SV to deal with random wave in time series

7. Tar threshold autoregression model of r language time series

8. R language K-shape time series clustering method to stock price time series clustering

9. Python3 uses arIMA model for time series prediction