Description Usage Arguments Details Value Note Author(s) See Also Examples
get a twsContract object
1 | getContract(x, verbose = TRUE, silent = FALSE, ...)
|
x |
can be an instrument, twsInstrument, name of an instrument or twsInstrument, or a numeric or character ‘conId’ |
verbose |
be verbose? |
silent |
silence warnings? |
... |
any additional arguments to pass to
|
If x
is a twsInstrument, or if there is a twsInstrument with the
same name as x
in the .instrument environment, it will return the
twsContract found in the $IB field of that object. If not, then if
x
is the name of a Symbol defined in the Symbol Lookup table
(see setSymbolLookup
) that has an "IBrokers" src,
and a twsContract object stored under "Contract", that twsContract will be returned.
Otherwise, x
will be passed to Contr_From_Instr
which will use what information it can to create a twsContract shell that can/will be
updated with reqContractDetails
If you want to force a request for contract details from IB (and ensure you are not
getting a local copy of the twsContract), use Contr_From_Instr
which will return the twsContract that reqContractDetails
returns
without altering any local copies. Alternatively, if you call rmContract
before calling getContract
, it will be forced to look it up
(by calling Contr_From_Instr
for you).
an object of class twsContract
To ensure you get the contract you're after, you should define your instruments before using this function.
Garrett See
conId
, rmContract
,
define_stocks
,
define_options
, define_futures
,
Contr_From_Instr
, twsInstrument
,
getInstrument
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
getContract("4082282") #uses reqContractDetails
getContract(4082282) #same
twsInstrument('SEE')
getContract("SEE") # == .instrument$SEE$IB
getContract("DIA") # will use reqContractDetails if "DIA" is not already defined
instr <- getInstrument("SEE")
getContract(instr)
getContract(instr$conId) # will connect to IB and reqContractDetails
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.