Description Usage Arguments Details Value Note Author(s) See Also Examples
Update instruments with metadata from another instrument.
1 2 3 | update_instruments.instrument(Symbols, source_id,
create.new = FALSE, ignore = "identifiers",
assign_i = TRUE)
|
Symbols |
charcter vector of primary_ids or other
instrument identifiers. of instruments to be updated.
Alternatively, |
source_id |
The primary_id (or other identifier) of
an instrument, or an instrument. The |
create.new |
If FALSE (Default), only attributes
that exist but have empty values will be updated. If
TRUE, new attributes will be created if |
ignore |
vector of names of instrument attributes that should not be copied to the updated instruments. |
assign_i |
TRUE/FALSE. If TRUE, the updated instruments will be assigned back into the instrument environment. If FALSE, a list of updated instruments will be returned |
By default, only attributes that have a value of
""
will be given a new value.
If create.new
is TRUE
, then if there are
attributes in source_id
that are not in the
Symbols
' instrument, those attributes will be
copied to the updated instruments unless they are in
ignore
.
if isTRUE(assign_i)
a vector of primary_ids of the
instruments that were upated. Otherwise, a list of
updated instrument objects.
one way to overwrite attributes of one instrument with
those of another is to first set equal to ""
those
attributes that you want to overwrite, then use
update_instruments.instrument
to copy the
attributes.
Garrett See
update_instruments.yahoo
,
all.equal.instrument
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
#rm_instruments()
currency("USD")
synthetic("SPX", "USD", identifiers=list(yahoo="GSPC"),
tick_size=0.01,
liquidHours="T08:30:00/T15:00:00",
extraField='something else',
assign_i=TRUE)
stock("SPY", "USD", liquidHours="", assign_i=TRUE)
all.equal(getInstrument("SPX"), getInstrument("SPY"))
getInstrument("SPY")
## update SPY metadata based on the metadata of SPX
## Only attributes that == "" are updated by default
update_instruments.instrument("SPY", "SPX", assign_i=FALSE) #liquidHours
update_instruments.instrument("SPY", "SPX", create.new=TRUE,
ignore=c("identifiers", "type"),
assign_i=FALSE)
# Although you probably do NOT want to, this will
# copy everything new -- including identifiers and type!
update_instruments.instrument("SPY", "SPX", create.new=TRUE, ignore=NULL,
assign_i=FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.