futures contract constructor

Share:

Description

Define one or many futures contracts for a given underlying.

Usage

1
2
3
4
5
define_futures.IB(symbols, exch, expiries = as.Date(Sys.time()),
  currency = "USD", include_expired = "1", ...)

define_futures(symbols, exch, expiries = as.Date(Sys.time()),
  currency = "USD", include_expired = "1", src = "IB", ...)

Arguments

symbols

chr name of underlying

exch

chr name of exchange (‘GLOBEX’,‘CFE’, ‘eCBOT’, etc)

expiries

vector of type chr. YYYYMM or YYYYMMDD

currency

denominating currency. default "USD"

include_expired

is the contract expired? ‘0’ for no, ‘1’ for yes.

src

currently only sQuoteIB

...

any other parameters to pass to twsFuture: ‘primary’, ‘currency’, ‘local’, ‘multiplier’, ‘conId’

Details

define_futures is currently just a wrapper that calls define_futures.IB

define_futures.IB loops through all of the symbols and expiries calling twsInstrument. The exchange has to be the same for all of the futures you are trying to define. If you want to define futures from different exchanges, you must make a separate call for each.

The name of the future contract will usually be the value of ‘local’ (retrieved with a call to reqContractDetails) with an underscore separating the root symbol and the suffix_id. If symbol is not found in ‘local’ (e.g. ‘VIX’ is not in ‘VXU1’) the suffix_id will be of format MMMYY (e.g. JUN11)

Value

names of instruments that were created. Called for side-effect

Author(s)

Garrett See

See Also

twsInstrument, twsFuture, future, future_series, instrument

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
define_futures("ES","GLOBEX",c("201109","201112"))
define_futures("ES","GLOBEX","201103",include_expired="1")

months <- c(paste("0",1:9,sep=""),paste(10:12))
define_futures("VIX","CFE",paste("2010",months,sep=""),include_expired="1")

define_futures("YM","eCBOT","201109")

define_futures(c("NKD","NQ"), "GLOBEX", "201109")

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.