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.

139

Figure 11.2: Correlogram of the residuals of the fitted ARIMA(1,1,1) model

Box-Ljung test

data: resid(x.arima)

X-squared = 19.0413, df = 20, p-value = 0.5191

We can see that the p-value is significantly larger than 0.05 and as such we can state that

there is strong evidence for discrete white noise being a good fit to the residuals. Thus the

ARIMA(1,1,1) model is a good fit as expected.

11.2.4 Financial Data and Prediction

In this section we are going to fit ARIMA models to Amazon, Inc. (AMZN) and the S&P500

US Equity Index (^GPSC, in Yahoo Finance). We will make use of the forecast library, written

by Rob J Hyndman[54].

We can go ahead and install the library in R:

> install.packages("forecast")

> library(forecast)

Now we can use quantmod to download the daily price series of Amazon from the start of

2013. Since we will have already taken the first order differences of the series, the ARIMA fit

carried out shortly will not require d > 0 for the integrated component:

> require(quantmod)

> getSymbols("AMZN", from="2013-01-01")

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

Saved successfully!

Ooh no, something went wrong!