Learn R Programming

FinancialInstrument (version 1.3.1)

CompareInstrumentFiles: Compare Instrument Files

Description

Compare the .instrument environments of two files

Usage

CompareInstrumentFiles(file1, file2, ...)

Arguments

file1

A file containing an instrument environment

file2

Another file containing an instrument environment. If not provided, file1 will be compared against the currently loaded instrument environment.

...

Arguments to pass to all.equal.instrument

Value

A list that contains the names of all instruments that were added, the names of all instruments that were removed, and the changes to all instruments that were updated (per all.equal.instrument).

Details

This will load two instrument files (created by saveInstruments) and find the differences between them. In addition to returning a list of difference that are found, it will produce messages indicating the number of instruments that were added, the number of instruments that were removed, and the number of instruments that are different.

See Also

saveInstruments, all.equal.instrument

Examples

Run this code
# NOT RUN {
#backup current .instrument environment
bak <- as.list(FinancialInstrument:::.instrument, all.names=TRUE) 
old.wd <- getwd()
tmpdir <- tempdir()
setwd(tmpdir)
rm_instruments(keep=FALSE)
# create some instruments and save
stock(c("SPY", "DIA", "GLD"), currency("USD"))
saveInstruments("MyInstruments1")
# make some changes
rm_stocks("GLD")
stock("QQQ", "USD")
instrument_attr("SPY", "description", "S&P ETF")
saveInstruments("MyInstruments2")
CompareInstrumentFiles("MyInstruments1", "MyInstruments2")
#Clean up
setwd(old.wd)
reloadInstruments(bak)
# }

Run the code above in your browser using DataLab