updateContract: update the IB attribute of a 'twsInstrument'

Description Usage Arguments Details Value Author(s) Examples

View source: R/updateContract.R

Description

If a Contract is no longer valid, this will request the new contract

Usage

1
updateContract(x, add.identifier = TRUE, type = "instrument", ...)

Arguments

x

character primary_id of an instrument

add.identifier

logical. If the conId has changed, should a “old.conId” identifier be added to the instrument?

type

type of instrument being updated. Passed to getInstrument. Only used if more than two or more instruments have primary_ids that are the same except for leading dots.

...

arguments to pass to update_instruments.IB.

Details

Interactive Brokers occationally changes the conId that is associated with a given instrument (for example, after a split, they change the conId). This function will check to make sure that the Contract that getContract finds is still valid. If not, it will request the new Contract and store it in the IB attribute of the instrument.

This is a very simple function

Value

character name of instrument

Author(s)

Garrett See

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
#backup instrument envir
ibak <- as.list(FinancialInstrument:::.instrument, all.names=TRUE)
rm_instruments()
define_stocks("SPY")
contr <- getContract("SPY")
contr$conId <- "0000000"
instrument_attr("SPY", "IB", contr)
getContract("SPY") #bad conId
updateContract("SPY")
getInstrument("SPY") #updated
## Restore previous instrument environment
rm_instruments(keep=FALSE)
loadInstruments(ibak)

## End(Not run)

twsInstrument documentation built on May 2, 2019, 5:24 p.m.