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.

393

surprising since no statistically significant cointegrating relationship was found between ARNC

and UNG across the period studied, at least using the ADF test procedure.

In order to improve this strategy a more refined view of the economics of the aluminum

smelting process could be taken. For instance, while there is a clear need for electricity to carry

out the electrolysis process, this power can be derived from many sources, including hydroelectric,

coal, nuclear and, likely in the future, wind and solar.

In addition it is almost certain that Alcoa will be carrying out its own hedging against

commodity prices that it is exposed to, which would have a substantial impact on the performance

of the strategy. A more comprehensive portfolio including the price of aluminum, large aluminum

producers, and ETFs representing varying energy sources might be one avenue of further research.

27.7 Full Code

# coint_cadf.R

library("quantmod")

library("tseries")

## Obtain ARNC and UNG

getSymbols("ARNC", from="2014-11-11", to="2017-01-01")

getSymbols("UNG", from="2014-11-11", to="2017-01-01")

## Utilise the backwards-adjusted closing prices

aAdj = unclass(ARNC$ARNC.Adjusted)

bAdj = unclass(UNG$UNG.Adjusted)

## Plot the ETF backward-adjusted closing prices

plot(aAdj, type="l", xlim=c(0, length(aAdj)), ylim=c(0.0, 45.0),

xlab="November 11th 2014 to January 1st 2017",

ylab="Backward-Adjusted Prices in USD", col="blue")

par(new=T)

plot(bAdj, type="l", xlim=c(0, length(bAdj)),

ylim=c(0.0, 45.0), axes=F, xlab="", ylab="", col="red")

par(new=F)

## Plot a scatter graph of the ETF adjusted prices

plot(aAdj, bAdj, xlab="ARNC Backward-Adjusted Prices",

ylab="UNG Backward-Adjusted Prices")

## Carry out linear regression on the two price series

comb = lm(aAdj~bAdj)

## Now we perform the ADF test on the residuals,

## or "spread" on the model, using a single lag order

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

Saved successfully!

Ooh no, something went wrong!