update_instruments.instrument: Update instruments with metadata from another instrument.

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Update instruments with metadata from another instrument.

Usage

1
2
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, Symbols can be an instrument or list of instruments.

source_id

The primary_id (or other identifier) of an instrument, or an instrument. The source_id instrument will be used to update the metadata of Symbols' instruments.

create.new

If FALSE (Default), only attributes that exist but have empty values will be updated. If TRUE, new attributes will be created if source_id has them, but the Symbols do not.

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

 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)

FinancialInstrument documentation built on May 2, 2019, 3:41 a.m.