extract_future: Extract root 'future' from 'future_series'

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Construct a future from a future_series

Usage

1
2
extract_future(x, future_id, assign_i = FALSE, overwrite = FALSE,
  identifiers = list(), ...)

Arguments

x

future_series, or name of future_series from which to extract future

future_id

Can be any string to use as primary_id of the newly created future. Alternatively, it can be “root”, “exchange_id”, or “marketName”. If future_id is missing, or if it is “root”, it will become the root as determined by a call to parse_id. If it is “exchange_id”, or “marketName” and either of those fields exist in the future_series, the value of that field will be used as the future_id

assign_i

should the future instrument be stored in the .instrument environment?

overwrite

TRUE/FALSE if an instrument already exists by the same name, should it be overwritten? (Default=FALSE)

identifiers

list of identifers to add to the future

...

any other parameters to pass through to instrument

Details

Use this if you have defined a future_series object using define_futures, or deleted the root future and you would like to define the root.

Value

a future object unless called with assign_i=TRUE in which case the future will be stored and only the primary_id will be returned.

Author(s)

Garrett See

See Also

instrument, future, future_series

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
s <- front_future("ES")
rm_futures("ES") #delete the root that front_future automatically created
extract_future(s)
extract_future(s, extra_field="custom") # can add any extra arbitrary fields

currency(c("USD", "AUD"))
define_futures("AUD", "GLOBEX", "201112", include_expired=1)
extract_future("AUD_Z1") # not assigned
extract_future("AUD_Z1", assign_i=TRUE) #root stored in "..AUD"
getInstrument("AUD") #Oh no, that's the curreny
getInstrument("AUD", type='future') #specify type to get the root

extract_future("AUD_Z1", future_id='X6A', assign_i=TRUE, identifiers=list(CME='6A'))
getInstrument("6A")

# The next line would replace "AUD" the currency with a future
# extract_future("AUD_Z1", future_id='AUD', assign_i=TRUE, identifiers=list(CME='6A'), overwrite=TRUE)

## End(Not run)

gsee/twsInstrument documentation built on May 17, 2019, 8:55 a.m.