Update: Extending Commodity time series

July 3, 2013
By

(This article was first published on Systematic Investor » R, and kindly contributed to R-bloggers)

I showed an example of Extending Commodity time series back in 2012. Since then, the web site that I used to get the Thomson Reuters/Jefferies CRB Index data is no longer working. But there are a few alternatives:

  • Thomson Reuters / Jefferies CRB Index.
    To get data, first select “TRJ/CRB Index-Total Return”, next click “See Chart”. There will be “Download to Spreadsheet” link beneath the chart.
  • TR/J CRB Global Commodity Equity Index
    To get data, first select “TR/J CRB Global Commodity Equity Index”, “Total Return”, check “All Dates”, next click “OK” to download the data.

There is a difference between these two series. I did not found a reason for the discrepancy, but truthfully, I did not look very hard. So I welcome any insights or feedback.

The Thomson Reuters / Jefferies CRB Index time series is better fit for the DBC and GSG etfs.

Now let’s plot the CRB index alternatives and DBC and GSG Commodity ETFs side by side to visual check the similarity.

###############################################################################
# Load Systematic Investor Toolbox (SIT)
# http://systematicinvestor.wordpress.com/systematic-investor-toolbox/
###############################################################################
setInternet2(TRUE)
con = gzcon(url('http://www.systematicportfolio.com/sit.gz', 'rb'))
    source(con)
close(con)
 
    #*****************************************************************
    # Load historical data
    #******************************************************************    
    load.packages('quantmod')		
    tickers = spl('GSG,DBC')
    data = new.env()
    getSymbols(tickers, src = 'yahoo', from = '1970-01-01', env = data, auto.assign = T)    
        for(i in ls(data)) data[[i]] = adjustOHLC(data[[i]], use.Adjusted=T)
     
    # "TRJ_CRB" file was downloaded from the http://www.jefferies.com/Commodities/2cc/389
    # for "TRJ/CRB Index-Total Return"
    temp = extract.table.from.webpage( join(readLines("TRJ_CRB")), 'EODValue' )
	temp = join( apply(temp, 1, join, ','), '\n' )
	data$CRB_1 = make.stock.xts( read.xts(temp, format='%m/%d/%y' ) )
	
    # "prfmdata.csv" file was downloaded from the http://www.crbequityindexes.com/indexdata-form.php
    # for "TR/J CRB Global Commodity Equity Index", "Total Return", "All Dates"
    data$CRB_2 = make.stock.xts( read.xts("prfmdata.csv", format='%m/%d/%Y' ) )
        	    
    bt.prep(data, align='remove.na')
	    
    #*****************************************************************
    # Compare
    #******************************************************************    	
    plota.matplot(scale.one(data$prices))

plot1

To leave a comment for the author, please follow the link and comment on their blog: Systematic Investor » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Mango solutions



RStudio homepage



Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training

datasociety

http://www.eoda.de





ODSC

ODSC

CRC R books series





Six Sigma Online Training









Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)