Create an instrument based on name alone
Given a name, this function will attempt to create an instrument of the appropriate type.
1 2 3
charater primary identifier of instrument to be created
character name of currency that instrument will be denominated it. Default=“USD”
numeric product multiplier
TRUE/FALSE. silence warnings?
What type of instrument to make if it is not clear from the primary_id. ("stock", "future", etc.) Default is NULL.
character string to pass to
TRUE/FALSE. Should the
other passthrough parameters
currency is not already defined, it will be defined (unless it is
not 3 uppercase characters). The default value for
“USD”. If you do not provide a value for
“USD” will be defined and used to create the instrument.
primary_id is 6 uppercase letters and
default_type is not
provided, it will be assumed that it is the primary_id of an
exchange_rate, in which case, the 1st and 2nd half of
primary_id will be defined as
currencys if not
the names of already defined
primary_id begins with a “^” it will be assumed that it
is a yahoo symbol and that the instrument is an index (synthetic), and the
‘src’ will be set to “yahoo”.
If it is not clear from the
primary_id what type of instrument to
create, an instrument of type
default_type will be created (which is
'NULL' by default). This will happen when
primary_id is that of a
bond. This may also happen if
primary_id is that of a
option_series but the
option cannot be found. In this case,
the instrument type would be
default_type, but a lot of things would
be filled in as if it were a valid series instrument (e.g. ‘expires’,
‘strike’, ‘suffix_id’, etc.)
Primarily called for its side-effect, but will return the name of the instrument that was created
This is not intended to be used to create instruments of type
bond although it may be updated in the future.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## Not run: instrument.auto("CL_H1.U1") getInstrument("CL_H1.U1") #guaranteed_spread instrument.auto("ES_H1.YM_H1") getInstrument("ES_H1.YM_H1") #synthetic currency(c("USD","EUR")) instrument.auto("EURUSD") getInstrument("EURUSD") #made an exchange_rate instrument.auto("VX_H11") #no root future defined yet! getInstrument("VX_H11") #couldn't find future, didnt make future_series future("VX","USD",1000,underlying_id=synthetic("SPX","USD")) #make the root instrument.auto("VX_H11") #and try again getInstrument("VX_H11") #made a future_series ## End(Not run)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.