diff --git a/lib/historical.js b/lib/historical.js index c3952c2..63951fa 100644 --- a/lib/historical.js +++ b/lib/historical.js @@ -71,6 +71,16 @@ function _sanitizeHistoricalOptions(options) { } } + if (_.isString(options.events)) { + if (!_.includes(['split', 'div', 'capital', 'history'], options.events)) { + throw new Error('"options.events" must be "split", "div", "capital", or "history".'); + } + } else { + if (!_.isUndefined(options.events) && !_.isNull(options.events)) { + throw new Error('"options.events" must be a string or undefined/null.'); + } + } + if (!options.from) { options.from = moment('1900-01-01'); } @@ -83,7 +93,9 @@ function _sanitizeHistoricalOptions(options) { options.period = '1d'; } - options.events = 'history'; + if (!options.events) { + options.events = 'history'; + } // Convert to yahoo v7 API switch (options.period) {