13.08.2022 Views

advanced-algorithmic-trading

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

143

> Box.test(resid(spfinal.arima), lag=20, type="Ljung-Box")

Box-Ljung test

data: resid(spfinal.arima)

X-squared = 13.6037, df = 20, p-value = 0.85

Since the p-value is greater than 0.05 we have evidence of a good model fit.

Why is it that in the previous chapter our Ljung-Box test for the S&P500 showed that the

ARMA(3,3) was a poor fit for the daily log returns?

Notice that I deliberately truncated the S&P500 data to start from 2013 onwards here, which

conveniently excludes the volatile periods around 2007-2008. Hence we have excluded a large

portion of the S&P500 where we had excessive volatility clustering. This impacts the serial

correlation of the series and hence has the effect of making the series seem "more stationary"

than it has been in the past.

This is a very important point. When analysing time series we need to be extremely careful

of conditionally heteroscedastic series, such as stock market indexes. In quantitative finance,

trying to determine periods of differing volatility is often known as "regime detection". It is one

of the harder tasks to achieve.

Let us now plot a forecast for the next 25 days of the S&P500 daily log returns as given in

Figure 11.6.

> plot(forecast(spfinal.arima, h=25))

Figure 11.6: 25-day forecast of S&P500 daily log returns

Now that we have the ability to fit and forecast models such as ARIMA we are very close to

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!