Learn R Programming

schwartz97 (version 0.0.6)

futures-data: Daily futures prices

Description

Futures prices, time to maturity, open interest, volume, underlying tickers, and last trade date of ten different commoditites: corn, wheat, soybean, soybean meal, soybean oil, lumber, live cattle, coffee, heating oil, copper.

There are, depending on the liquidity of the commodity, between 4 and 10 ‘clean’ closest to maturity futures price series.

Usage

data(futures)

Arguments

Format

A list containing ten commodities as lists: “corn”, “wheat”, “soybean”, “soybean.meal”, “soybean.oil”, “lumber”, “live.cattle”, “coffee”, “heating.oil”, “copper”. Each list contains six dimnamed matrices:
price
Daily futures prices.
ttm
The time to maturity of the futures contracts in units of days (see Details.)
oi
Open interest.
vol
Volume.
underl.tickers
Underlying tickers / contracts.
last.trade.dt
Last trade date as character in the ISO 8601 international standard format.
The i-th column of each matrix contains data for the i-th closest to maturity contract. The i-th column name is the ticker of the i-th generic futures.
Commodity # Contracts Exchange Start date
End date Corn 6 CBOT
1997-01-02 2010-04-07 Wheat 5
CBOT 1995-01-03 2010-04-07 Soybean
7 CBOT 1995-01-03 2010-04-07
Soybean meal 6 CBOT 2000-01-03
2010-04-07 Soybean oil 6 CBOT
1995-01-03 2010-04-07 Lumber 4
CME 1995-01-03 2010-04-07 Live cattle
6 CME 2004-07-01 2010-04-07
Coffee 5 ICE 1995-01-03
2010-04-07 Heating oil 10 NYMEX
1995-01-03 2010-03-31 Copper 8
COMEX 1996-01-02 2010-02-24 Commodity

Details

The elements of price and ttm have the following interpretation: price[i,j] denotes the futures price whose time to maturity was ttm[i,j] days when it was observed.

See Also

futuresplot, fit.schwartz2f.

Examples

Run this code

# data(futures)
# 
# ## Plot forward curves of lumber
# futuresplot(futures$lumber, type = "forward.curve")
# 
# ## Plot time to maturity of heating oil data
# futuresplot(futures$heating.oil, type = "ttm")
# 
# ## Make 'futures' weekly, take Wednesday data
# futures.w <- rapply(futures, function(x)x[format(as.Date(rownames(x)), "%w") == 3,],
#                     classes = "matrix", how = "list")
# 
# ## Make 'futures' monthly, take the 28th day of the month
# futures.m <- rapply(futures, function(x)x[format(as.Date(rownames(x)), "%d") == 28,],
#                     classes = "matrix", how = "list") 
# 
# ## Plot weekly lumber and monthly soybean data
# futuresplot(futures.w$lumber, type = "forward.curve", main = "Lumber") 
# futuresplot(futures.m$soybean, type = "forward.curve", main = "Soybean")
# 
# ## Convert to zoo-objects:
# require(zoo)
# futures.zoo <- rapply(futures, function(x)zoo(x, as.Date(rownames(x))),
#                       classes = "matrix", how = "list")
# 
# ## ...and plot it nicely using plot.zoo:
# plot(futures.zoo$heating.oil$ttm)
# plot(futures.zoo$wheat$vol)
# plot(futures.zoo$copper$oi)
# 
# ## Estimate soybean meal parameters (stop after 100 iterations).
# ## ttm (time-to-maturity) is divided by 260 as it is in unit of days and
# ## deltat = 1/52 because weekly price observations are used.
# soybean.meal.fit <- fit.schwartz2f(data = futures.w$soybean.meal$price,
#                                    ttm = futures.w$soybean.meal$ttm / 260,
#                                    deltat = 1 / 52, r = 0.04,
#                                    control = list(maxit = 100))
# soybean.meal.fit

Run the code above in your browser using DataLab