Description Usage Arguments Details Value Author(s) See Also Examples
Create a future instrument for the front-month contract as well as specs for the root. Looks up contract details of a futures contract from IB and creates a futures instrument. The contract root will also be defined if it hasn't been defined yet.
1 2 3 4 5 | front_future(roots, currency = "USD", exchange = NULL,
underlying_id = NULL, addIBslot = TRUE, src = "IB")
front_future.IB(roots, currency = "USD", exchange = NULL,
underlying_id = NULL, addIBslot = TRUE)
|
roots |
vector of chr strings; contract roots. |
currency |
name of currency; if more than one root, they all must have the same currency |
exchange |
optional character string name of exchange ("GLOBEX", "NYMEX", etc.) |
underlying_id |
name of underlying |
addIBslot |
should an IB slot be added to the instrument; i.e. do you want to create a twsInstrument. |
src |
currently only dQuoteIB is supported |
The contract details that IB gives are usually for the front month contract, but there is no guarantee that the contract will actually be the front contract. (perhaps default_future would be a better name for this function?)
This is not a very robust function. define_futures
is probably a
better alternative, but requires more user input.
If you find that front_future.IB
is defining something different than
what you wanted (e.g. futures on Colgate Palmolive instead of Light Sweet
Crude) try providing the underlying_id
Currently, front_future
is just a wrapper for front_future.IB
.
I.e. “IB” is the only functional value for src
using root
and currency
it will get the contract details of
the front month future with a call to reqContractDetails. Using that info,
it will create a future_series instrument, and a future instrument if it
doesn't exist yet.
called for side-effect. Returns the name of any instruments that were created.
Garrett See
define_futures, future, future_series, update_instruments.IB, Instr_From_Contr, option_series.yahoo
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
front_future('YM')
front_future('ES')
front_future('SPY')
#alternatively
#front_future(c("YM","ES","SPY"))
#or,
#unlist(lapply(c("YM","ES","SPY"), front_future))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.