Description Usage Arguments Details Value Note Examples
This function will add or overwrite the data stored in the specified slot of the specified instrument.
1 | instrument_attr(primary_id, attr, value, ...)
|
primary_id |
primary_id of the instrument that will be updated |
attr |
Name of the slot that will be added or changed |
value |
What to assign to the |
... |
arguments to pass to |
If the attr
you are trying to change is the
“primary_id,” the instrument will be renamed. (A
copy of the instrument will be stored by the name of
value
and the old instrument will be removed.) If
the attr
you are changing is “type”, the
instrument will be reclassed with that type. If
attr
is “src”, value
will be used in
a call to setSymbolLookup
. Other checks are in
place to make sure that “currency” remains a
currency
object and that
“multiplier” and “tick_size” can only be
changed to reasonable values.
If attr
is “identifiers” and value
is NULL
, identifiers
will be set to
list()
. If value
is not a list,
add.identifier
will be called with
value
. add.identifier
will convert
value
to a list and append it to the current
identifiers
called for side-effect
You can remove an attribute/level from an instrument by
calling this function with value=NULL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
currency("USD")
stock("SPY","USD")
instrument_attr("USD","description","U.S. Dollar")
instrument_attr("SPY", "description", "An ETF")
getInstrument("USD")
getInstrument("SPY")
#Call with value=NULL to remove an attribute
instrument_attr("SPY", "description", NULL)
getInstrument("SPY")
instrument_attr("SPY","primary_id","SPX") #move/rename it
instrument_attr("SPX","type","synthetic") #re-class
instrument_attr("SPX","src",list(src='yahoo',name='^GSPC')) #setSymbolLookup
getSymbols("SPX") #knows where to look because the last line setSymbolLookup
getInstrument("SPX")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.