saveInstruments {FinancialInstrument}R Documentation

Save and Load all instrument definitions

Description

Saves (loads) the .instrument environment to (from) disk.

Usage

saveInstruments(file_name = "MyInstruments", dir = "", compress = "gzip")

loadInstruments(file_name = "MyInstruments", dir = "")

reloadInstruments(file_name = "MyInstruments", dir = "")

Arguments

file_name

name of file. e.g. “MyInstruments.RData”. As an experimental feature, a list or environment can be passed to file_name.

dir

Directory of file (defaults to current working directory. ie. "")

compress

argument passed to save, default is "gzip"

Details

After you have defined some instruments, you can use saveInstruments to save the entire .instrument environment to disk.

loadInstruments will read a file that contains instruments and add those instrument definitions to your .instrument environment. reloadInstruments will remove all instruments in the current .instrument environment before loading instruments from disk.

The file_name should have a file extension of “RData”, “rda”, “R”, or “txt”. If the file_name does not end with one of those, “.RData” will be appended to the file_name

If the file extension is “R” or “txt”, saveInstruments will create a text file of R code that can be sourced to load instruments back into the .instrument environment.

Value

Called for side-effect

Author(s)

Garrett See

See Also

save, load load.instrument define_stocks, define_futures, define_options (option_series.yahoo)

Examples

## Not run: 
stock("SPY", currency("USD"), 1)
tmpdir <- tempdir()
saveInstruments("MyInstruments.RData", dir=tmpdir)
rm_instruments(keep.currencies=FALSE)
loadInstruments("MyInstruments.RData", dir=tmpdir)
# write .R file that can be sourced
saveInstruments("MyInstruments.R", dir=tmpdir)
rm_instruments(keep.currencies=FALSE)
loadInstruments("MyInstruments.R", dir=tmpdir)
#source(file=paste(tmpdir, "MyInstruments.R", sep="/")) # same
unlink(tmpdir, recursive=TRUE)     

## End(Not run)

[Package FinancialInstrument version 1.3.1 Index]