update_instruments.instrument {FinancialInstrument} | R Documentation |
Update instruments with metadata from another instrument.
Description
Update instruments with metadata from another instrument.
Usage
update_instruments.instrument(Symbols, source_id, create.new = FALSE,
ignore = "identifiers", assign_i = TRUE)
Arguments
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 |
Details
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
.
Value
if isTRUE(assign_i)
a vector of primary_ids of the instruments
that were upated. Otherwise, a list of updated instrument objects.
Note
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.
Author(s)
Garrett See
See Also
update_instruments.yahoo
,
all.equal.instrument
Examples
## 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)