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.

106

10.4.5 Financial Data

Amazon Inc.

Let us begin by obtaining the stock price for Amazon (AMZN) using quantmod as in the

previous chapter:

> require(quantmod)

> getSymbols("AMZN")

> AMZN

..

..

2015-08-12 523.75 527.50 513.06 525.91 3962300 525.91

2015-08-13 527.37 534.66 525.49 529.66 2887800 529.66

2015-08-14 528.25 534.11 528.25 531.52 1983200 531.52

The first task is to always plot the price for a brief visual inspection. In this case we will be

using the daily closing prices. The plot is given in Figure 10.4.

> plot(Cl(AMZN))

You’ll notice that quantmod adds some formatting for us, namely the date, and a slightly

prettier chart than the usual R charts.

Figure 10.4: Daily Closing Price of AMZN.

We are now going to take the logarithmic returns of AMZN and then the first-order difference

of the series in order to convert the original price series from a non-stationary series to a

(potentially) stationary one.

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

Saved successfully!

Ooh no, something went wrong!