R source code for Oil CL Spread Percentage Change Chart

(Last Updated On: April 5, 2014)

R source code for Oil CL Spread Percentage Change Chart

This generous contribution came from the NYC Conatact so thanks him big time! Chart is at end


R packages I use: utils, stats, methods, graphics, grDevices, datasets

R code for the new chart

CL1 = read.csv(‘http://www.quandl.com/api/v1/datasets/CHRIS/CME_CL1.csv?&auth_token=EFqKm1HWP2FJZNzJywN9&trim_start=1983-03-31&trim_end=2014-04-03&sort_order=desc’, colClasses=c(‘Date’=’Date’))

CL2 = read.csv(‘http://www.quandl.com/api/v1/datasets/CHRIS/CME_CL2.csv?&auth_token=EFqKm1HWP2FJZNzJywN9&trim_start=1983-03-30&trim_end=2014-04-03&sort_order=desc’, colClasses=c(‘Date’=’Date’))
CL_Spread <- CL1[“Date”]

CL_Spread[“Settle”] = CL1[“Settle”] – CL2[“Settle”]

N <- nrow(CL_Spread)
for (i in 1:N)
CL_Spread[i, “PrecentChange”] = round(((CL_Spread[i,”Settle”] – CL_Spread[i+1,”Settle”])/CL_Spread[i+1,”Settle”])*100,digits=2)

rdate <- as.Date(CL_Spread$Date,”%yy-%m-%d”)
plot(CL_Spread$PrecentChange~rdate, type=”l”,col=”blue”,axes=F)

Join my FREE newsletter to see what other contributions come my way 

CL Spread Percentage Change Chart


NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.


Check NEW site on stock forex and ETF analysis and automation

Scroll to Top