Infrastructure for defining meta-data and relationships for financial instruments.
Requires quantmod >= 0.4-3 and no longer using the Defaults package (which is now archived on CRAN) for importDefaults() in getSymbols.FI.
getSymbols.FI() allows the user to set default values by checking for options(). For example, the default value for from= is now getOption("getSymbols.FI.from", "2010-01-01"). So, if you do not set the "getSymbols.FI.from" option, the value will be what it always has been ("2010-01-01"), but if you did set a value (e.g. options(getSymbols.FI.from="2014-01-01")), then that value will be used.
::: calls to unexported functions from quantmod.
saveInstruments() gains a "compress" argument to allow for different compression than the default ("gzip")
instrument() and most of its wrappers gain an "overwrite" argument. The default is TRUE to match previous behavior -- if you try to create an instrument that already exists, the old one will be replaced by the new definition. If overwrite=FALSE is used, there will be an error if you try to define an instrument that has a primary_id that is already in use. Thanks to Charlie Friedemann for the suggestion and discussions.
load.instruments() gains an overwrite argument that is passed through to the instrument() wrapper functions. Therefore, load.instruments() no longer checks to see if an instrument already exists. Thanks to Charlie Friedemann for the patch.
load.instruments() gains an "identifier_cols" argument that can be used to pass the names of columns that are to be used as identifiers instead of as normal instrument attributes. Thanks to Charlie Friedemann for the patch.
loadInstruments() can now load unnamed lists of instruments because it now uses the primary_ids directly instead of the names of the list/environment
setSymbolLookup.FI was appending the Symbol to the directory, and getSymbols.FI was only adding the Symbol to the file path if the end of the path was not the same as the Symbol. That meant that getSymbols.FI could not be used to get data for a Symbol that was the same as the base directory. getSymbols.FI now always appends the Symbol to the file path and setSymbolLookup.FI does not append it to the base_dir. Test added.
In redenominate, if the object was a defined instrument, the currency in the instrument object would be used even if the user passed a different currency in the old_base argument.
sort_ids() only worked in some locales when an instrument is not defined. It now converts the month (returned by parse_id()) to numeric (with MC2N()) and uses the "%m" format in the as.Date call instead of using the month name with the (locale-specific) "%b" format. Thanks to Alexis Petit for the patch.
when instrument() wrappers were called with vectors of symbols and
assign_i=FALSE, the symbols were being returned instead of the instrument
objects. Now, when
length(primary_id) > 1, a
named list of instruments will be returned. Named lists of instruments are
easy to work with since they can be passed directly to (re)loadInstruments(),
or coerced to an environment with as.environment()
sort.instrument() method to sort the components of an instrument
CompareInstrumentFiles() allows passing it only 1 argument in which case it will compare the currently loaded instrument environment against it.
If an instrument has a string like "2012-09", "2012/09", or "201209" in the "expires" attribute, sort_id() will treat that instrument as expiring on the first day of that month (2012-09-01). Thanks to Jan Humme for reporting.
import xts to prevent xts functions from being masked.
ls_instruments_by() checks for NA to avoid an error.
force evaluation of arguments to CompareInstrumentEnvironment()
option_series.yahoo() checks the results of the call to quantmod::getOptionChain() and only uses rows that contain the ticker Symbol (sometimes in the off-hours, yahoo includes a bad row)
update_instruments.morningstar is slightly more robust. It no longer depends on the relevant table being the 4th on the page; instead it uses the table with the most rows.
Replace paste0() calls with paste() so that R 2.15 in not required.
If use_identifier is not NA in a call to getSymbols.FI, and the instrument cannot be found, there is a more informative error message.
minor updates to docs: typo fixes, updated seealso sections