Package Quantmod': R Topics Documented
Package Quantmod': R Topics Documented
Package Quantmod': R Topics Documented
R topics documented:
quantmod-package addADX . . . . . . addBBands . . . . addExpiry . . . . . addMA . . . . . . addMACD . . . . . addROC . . . . . . addRSI . . . . . . addSAR . . . . . . addSMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 . 4 . 5 . 6 . 7 . 8 . 9 . 10 . 11 . 12
2 addVo . . . . . . . . . addWPR . . . . . . . . adjustOHLC . . . . . . attachSymbols . . . . . buildData . . . . . . . buildModel . . . . . . chartSeries . . . . . . . chartTheme . . . . . . chart_Series . . . . . . chob-class . . . . . . . chobTA-class . . . . . create.binding . . . . . Delt . . . . . . . . . . ndPeaks . . . . . . . ttedModel . . . . . . getDividends . . . . . getFinancials . . . . . getFX . . . . . . . . . getMetals . . . . . . . getModelData . . . . . getOptionChain . . . . getQuote . . . . . . . . getSplits . . . . . . . . getSymbols . . . . . . getSymbols.csv . . . . getSymbols.FRED . . getSymbols.google . . getSymbols.MySQL . getSymbols.oanda . . . getSymbols.rda . . . . getSymbols.SQLite . . getSymbols.yahoo . . . has.OHLC . . . . . . . internal-quantmod . . . is.quantmod . . . . . . Lag . . . . . . . . . . modelData . . . . . . . modelSignal . . . . . . newTA . . . . . . . . . Next . . . . . . . . . . OHLC.Transformations options.expiry . . . . . periodReturn . . . . . quantmod-class . . . . quantmod.OHLC . . . saveChart . . . . . . . setSymbolLookup . . . setTA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
R topics documented: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 14 15 16 18 20 21 24 26 27 28 29 30 31 32 34 35 37 38 40 41 42 43 45 48 49 51 53 55 56 58 60 61 63 63 64 65 66 67 70 72 74 75 77 78 79 80 82
3 83 85 87 88 91
quantmod-package
Description Quantitative Financial Modelling and Trading Framework for R Details Package: Type: Version: Date: Depends: Suggests: LazyLoad: License: URL: URL: quantmod Package 0.3-8 2007-11-20 xts(>=0.0-15),Defaults DBI,RMySQL,TTR,fSeries,its yes GPL-3 http://www.quantmod.com http://quantmod.r-forge.r-project.org
The quantmod package for R is designed to assist the quantitative trader in the development, testing, and deployment of statistically based trading models. What quantmod IS A rapid prototyping environment, where quant traders can quickly and cleanly explore and build trading models. What quantmod is NOT A replacement for anything statistical. It has no new modelling routines or analysis tool to speak of. It does now offer charting not currently available elsewhere in R, but most everything else is more of a wrapper to what you already know and love about the langauge and packages you currently use. quantmod makes modelling easier by removing the repetitive workow issues surrounding data management, modelling interfaces, and performance analysis. Author(s) Jeffrey A. Ryan Maintainer: Jeffrey A. Ryan <[email protected]>
addADX
addADX
Description Add Directional Movement Index Usage addADX(n = 14, maType="EMA", wilder=TRUE) Arguments n maType wilder Details See ADX in TTR for specic details and references. Value An ADX indicator will be draw in a new window on the current chart. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan References see ADX in TTR written by Josh Ulrich See Also addTA Examples
## Not run: addADX() ## End(Not run)
periods to use for DX calculation moving average type should Welles Wilder EMA be used?
addBBands
addBBands
Description Add Bollinger Bands to current chart. Usage addBBands(n = 2 , sd = 2, maType = "SMA", draw = bands, on = -1) Arguments n maType sd draw on Details The primary addition to this function call over the TTR version is in the draw argument. bands will draw standard Bollinger Bands, percent will draw Bollinger %b and width will draw Bolinger Bands Width. The last two will be drawn in new gure regions. See bollingerBands in TTR for specic details as to implementation and references. Value Bollinger Bands will be drawn, or scheduled to be drawn, on the current chart. If draw is either percent or width a new gure will be added to the current TA gures charted. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan References See bollingerBands in TTR written by Josh Ulrich See Also addTA number of moving average periods type of moving average to be used number of standard deviations indicator to draw: bands, percent, or width which gure area of chart to apply to
6 Examples
## Not run: addBBands() ## End(Not run)
addExpiry
addExpiry
Description Apply options or futures expiration vertical bars to current chart. Usage addExpiry(type = "options", lty = "dotted") Arguments type lty Details See options.expiry and futures.expiry in quantmod for details and limitations. Value Expiration lines will be drawn at appropriate dates. A chibTA object will be returned silently. Author(s) Jeffrey A. Ryan See Also addTA Examples
## Not run: addExpiry() ## End(Not run)
addMA
addMA
Description Add one or more moving averages to a chart. Usage addSMA(n = 1 , on = 1, with.col = Cl, overlay = TRUE, col = "brown") addEMA(n = 1 , wilder = FALSE, ratio=NULL, on = 1, with.col = Cl, overlay = TRUE, col = "blue") addWMA(n = 1 , wts=1:n, on = 1, with.col = Cl, overlay = TRUE, col = "green") addDEMA(n = 1 , on = 1, with.col = Cl, overlay = TRUE, col = "pink") addEVWMA(n = 1 , on = 1, with.col = Cl, overlay = TRUE, col = "yellow") addZLEMA(n = 1 , ratio=NULL, on = 1, with.col = Cl, overlay = TRUE, col = "red") Arguments n wilder wts ratio on with.col overlay col Details see the appropriate base MA functions in TTR for more details and references. Value A moving average indicator will be draw on the current chart. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan periods to average over logical; use wilder? a vector of weights a smoothing/decay ratio apply to which gure (see below) using which column of data (see below) draw as overlay color of MA
8 References see MovingAverages in TTR written by Josh Ulrich See Also addTA Examples
## Not run: addSMA() addEMA() addWMA() addDEMA() addEVWMA() addZLEMA() ## End(Not run)
addMACD
addMACD
Description Add Moving Average Convergence Divergence indicator to chart. Usage addMACD(fast = 12, slow = 26, signal = 9, type = "EMA", histogram = TRUE, col) Arguments fast slow signal type histogram col Details See and MACD in TTR for specic details and implementation references. Value A MACD indicator will be draw in a new window on the current chart. A chobTA object will be returned silently. fast period slow period signal period type of MA to use. Single values will be replicated include histogram colors to use for lines (optional)
addROC Author(s) Jeffrey A. Ryan References see MACD in TTR written by Josh Ulrich See Also addTA Examples
## Not run: addMACD() ## End(Not run)
addROC
Description Add Rate Of Change indicator to chart. Usage addROC(n = 1, type = c("discrete", "continuous"), col = "red") Arguments n type col Details See ROC in TTR for specic details and references. Value A ROC indicator will be draw in a new window on the current chart. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan periods compounding type line color (optional)
10 References see ROC in TTR written by Josh Ulrich See Also addTA Examples
## Not run: addROC() ## End(Not run)
addRSI
addRSI
Description Add a Relative Strength Index indicator to chart. Usage addRSI(n = 14, maType = "EMA", wilder = TRUE) Arguments n maType wilder Details see RSI in TTR for specic details and references. Value An RSI indicator will be draw in a new window on the current chart. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan References see RSI in TTR written by Josh Ulrich periods type of MA to use use wilder (see EMA)
11
addSAR
Description Add Parabolic Stop and Reversal indicator overlay to chart. Usage addSAR(accel = c( . 2, Arguments accel col Details see SAR in TTR for specic details and references. Value A SAR overlay will be drawn on the current chart. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan References see SAR in TTR written by Josh Ulrich See Also addTA Accelleration factors - see SAR color of points (optional) .2), col = "blue")
12 Examples
## Not run: addSAR() ## End(Not run)
addSMI
addSMI
Description Add Stochastic Momentum Indicator to chart. Usage addSMI(n=13,slow=25,fast=2,signal=9,ma.type="EMA") Arguments n slow fast signal ma.type Details see SMI in TTR for specics and references. Value An SMI indicator will be draw in a new window on the current chart. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan References see SMI in TTR written by Josh Ulrich See Also addTA periods slow fast signal MA tyep to use, recycled as necessary
addVo Examples
## Not run: addSMI() ## End(Not run)
13
addVo
Description Add Volume of a series, if available, to the current chart. This is the default TA argument for all charting functions. Usage addVo(log.scale=FALSE) Arguments log.scale Details Add volume bars to current chart if data object contains appropriate volume column. log.scale will transform the series via standard R graphics mechanisms. Value Volume will be draw in a new window on the current chart. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan See Also addTA Examples
## Not run: addVo() ## End(Not run)
14
addWPR
addWPR
Description Add Williams percent R indiator to the current chart. Usage addWPR(n = 14) Arguments n Details see WPR in TTR for details and references. Value A Williams percent R indicator will be draw in a new window on the current chart. A chobTA object will be returned silently. Author(s) Jeffrey A. Ryan References see WPR in TTR written by Josh Ulrich See Also addTA Examples
## Not run: addWPR() ## End(Not run)
periods
adjustOHLC
15
adjustOHLC
Description Adjust all columns of an OHLC object for split and dividend. Usage adjustOHLC(x, adjust = c("split","dividend"), use.Adjusted = FALSE, ratio = NULL, symbol.name=deparse(substitute(x))) Arguments x adjust use.Adjusted ratio symbol.name Details This function calculates the adjusted Open, High, Low, and Close prices according to split and dividend information. There are three methods available to calculate the new OHLC object prices. By default, getSplits and getDividends are called to retrieve the respective information. These may dispatch to custom methods following the . methodology used by quantmod dispatch. See getSymbols for information related to extending quantmod. This information is passed to adjSplitDiv from the TTR package, and the resulting ratio calculations are used to adjust to observed historical prices. This is the most precise way to adjust a series. The second method works only on standard Yahoo! data containing an explicit Adjusted column. A nal method allows for one to pass a ratio into the function directly. All methods proceed as follows: New columns are derived by taking the ratio of adjusted value to original Close, and multiplying by the difference of the respective column and the original Close. This is then added to the modied Close column to arrive at the remaining adjusted Open, High, Low column values. If no adjustment is needed, the function returns the original data unaltered. Value An object of the original class, with prices adjusted for splits and dividends. An OHLC object adjust by split, dividend, or both (default) use the Adjusted column in Yahoo! data to adjust ratio to adjust with, bypassing internal calculations used if x is not named the same as the symbol adjusting
16 Warning
attachSymbols
Using use.Adjusted = TRUE will be less precise than the method that employs actual split and dividend information. This is due to loss of precision from Yahoo! using Adjusted columns of only two decimal places. The advantage is that this can be run ofine, and for short series or those with few adjustments the loss of precision will be small. The resulting precision loss will be from row observation to row observation, as the calculation will be exact for intraday values. Author(s) Jeffrey A. Ryan References Yahoo Finance http://finance.yahoo.com See Also getSymbols.yahoo getSplits getDividends Examples
## Not run: getSymbols("AAPL", from="199 - 1- 1", src="yahoo") head(AAPL) head(AAPL.a <- adjustOHLC(AAPL)) head(AAPL.uA <- adjustOHLC(AAPL, use.Adjusted=TRUE)) # intrada adjustments are precise across all methods # an example with Open to Close (OpCl) head(cbind(OpCl(AAPL),OpCl(AAPL.a),OpCl(AAPL.uA))) # Close to Close changes ma lose precision head(cbind(ClCl(AAPL),ClCl(AAPL.a),ClCl(AAPL.uA))) ## End(Not run)
attachSymbols
attachSymbols Usage attachSymbols(DB = DDB_Yahoo(), pos = 2, prefix = NULL, postfix = NULL, mem.cache = TRUE, file.cache = !mem.cache, cache.dir = tempdir()) flushSymbols(DB = DDB_Yahoo()) Arguments DB pos prefix postfix mem.cache file.cache cache.dir Details A DDB data base object position in search path to attach DB character to prex all symbols with character to postx all symbols with should objects be cached in memory should objects be cached in on disk directory to use for file.cache=TRUE
17
An experimental function to allow access to remote objects without requiring explicit calls to a loading function. attachSymbols requires a DDB object to dene where the data is to come from, as well as what symbols are loaded on-demand. attachSymbols calls the method referred to by the DDB object. In the default case this is DDB_Yahoo. See this function for specic details about the Yahoo implementation. The individual methods make use of getSymbols to load the data. This requires a corresponding getSymbols method. Internally, attachSymbols makes use of quantmods unexported create.bindings to dynamically create active bindings to each symbol listed in the DDB object. In turn, create.bindings uses one of two R methods to create the binding to the names required. This depends on the cache method requested. Immediately after a call to attachSymbols, a new environment is attached that contains the names of objects yet to be loaded. This is similar to the lazy-load mechanism in R, though extended to be both more general and easier to use. It is important to note that no data is loaded at this stage. What occurs instead is that these symbols now have active bindings using either delayedAssign (mem.cache) or makeActiveBinding (le.cache). During all future requests for the object(s) in question, the binding will be used to determine how this data is loaded into R. mem.cache will simply load the data from its corresponding source (as dened by the DDB object) and leave it in the environment specied in the original call. The effect
18
buildData of this is to allow lazy-loading of data from a variety of external sources (Yahoo in the default case). Once loaded, these are cached in Rs memory. Nothing further differentiates these from standard variables. This also means that the environment will grow as more symbols are loaded. If the file.cache option is set, the data is loaded from its source the rst time the symbol is referenced. The difference is that the data is then written to a temporary le and maintained there. Data is loaded and subsequently removed upon each request for the object. See makeActiveBinding for details of how this occurs at the R level. A primary advantage of using the le.cache option is the ability to maintain hundreds or thousands of objects in your current session without using memory, or explicitly loading and removing. The main downside of this approach is the that data must be loaded from disk each time, with the corresponding (if generally negligible) overhead of le access.
Note This function is new, and all aspects may change in the near future. Author(s) Jeffrey A. Ryan References Lukes stuff and Mark Brevington and Roger Peng See Also delayedAssign, makeActiveBinding Examples
## Not run: attachSymbols() SBUX QQQQ ls() ## End(Not run)
buildData
Description Create one data object from multiple sources, applying transformations via standard R formula mechanism. Usage buildData(formula, na.rm = TRUE, return.class = "zoo")
19
an object of class formula (or one that can be coerced to that class): a symbolic description of the desired output data object, with the dependent side corresponding to rst column, and the independent parameters of the formula assigned to the remaining columns. drop rows with missing values? one of "zoo","data.frame","ts","its","timeSeries"
na.rm return.class
Details Makes available for use outside the quantmod workow a dataset of appropriately transformed variables, using the same mechanism underlying specifyModel. Offers the ability to apply transformations to raw data using a common formula mechanism, without having to explicitly merge different data objects. Interally calls specifyModel followed by modelData, with the returned object being coerced to the desired return.class if possible, otherwise returns a zoo object. See getSymbols and specifyModel for more information regarding proper usage.
Examples
## Not run: buildData(Next(OpCl(DIA)) ~ Lag(TBILL) + I(Lag(OpHi(DIA))^2)) buildData(Next(OpCl(DIA)) ~ Lag(TBILL), na.rm=FALSE) buildData(Next(OpCl(DIA)) ~ Lag(TBILL), na.rm=FALSE, return.class="ts") ## End(Not run)
20
buildModel
buildModel
Description Construct and attach a tted model of type method to quantmod object. Usage buildModel(x, method, training.per, ...) Arguments x training.per method ... Details Currently available methods include: lm, glm, loess, step, ppr, rpart[rpart], tree[tree], randomForest[randomForest], mars[mda], polymars[polspline], lars[lars], rq[quantreg], lqs[MASS], rlm[MASS], svm[e1071], and nnet[nnet]. The training.per should match the undelying date format of the time-series data used in modelling. Any other style may not return what you expect. Additional methods wrappers can be created to allow for modelling using custom functions. The only requirements are for a wrapper function to be constructed taking parameters quantmod, training.data, and . . . . The function must return the tted model object and have a predict method available. It is possible to add predict methods if non exist by adding an S3 method for predictModel. The buildModel.skeleton function can be used for new methods. Value An object of class quantmod with tted model attached Note See buildModel.skeleton for information on adding additional methods Author(s) Jeffrey Ryan An object of class quantmod created with specifyModel or an R formula character vector representing dates in ISO 8601 format CCYY-MM-DD or CCYY-MM-DD HH:MM:SS of length 2 A character string naming the tting method. See details section for available methods, and how to create new methods. Additional arguments to method call
21
chartSeries
Description Charting tool to create standard nancial charts given a time series like object. Serves as the base function for future technical analysis additions. Possible chart styles include candles, matches (1 pixel candles), bars, and lines. Chart may have white or black background. reChart allows for dynamic changes to the chart without having to respecify the full chart parameters. Usage chartSeries(x, type = c("auto", "candlesticks", "matchsticks", "bars","line"), subset = NULL, show.grid = TRUE, name = NULL, time.scale = NULL, log.scale = FALSE, TA = addVo(), TAsep=;, line.type = "l", bar.type = "ohlc", theme = chartTheme("black"), layout = NA, major.ticks=auto, minor.ticks=TRUE, yrange=NULL, plot=TRUE, up.col,dn.col,color.vol = TRUE, multi.col = FALSE, ...) reChart(type = c("auto", "candlesticks", "matchsticks", "bars","line"), subset = NULL, show.grid = TRUE,
22 name = NULL, time.scale = NULL, line.type = "l", bar.type = "ohlc", theme = chartTheme("black"), major.ticks=auto, minor.ticks=TRUE, yrange=NULL, up.col,dn.col,color.vol = TRUE, multi.col = FALSE, ...) Arguments x type subset show.grid name time.scale log.scale TA TAsep line.type bar.type theme layout major.ticks minor.ticks yrange plot up.col dn.col color.vol multi.col ... Details an OHLC object - see details style of chart to draw xts style date subsetting argument display price grid lines? name of chart what is the timescale? automatically deduced (broken) should the y-axis be log-scaled? a vector of technical indicators and params, or character strings TA delimiter for TA strings type of line in line chart type of barchart - ohlc or hlc a chart.theme object if NULL bypass internal layout where should major ticks be drawn should minor ticks be draw? override y-scale should plot be drawn up bar/candle color down bar/candle color color code volume? 4 color candle pattern additional parameters
chartSeries
Currently displays standard style OHLC charts familiar in nancial applications, or line charts when not passes OHLC data. Works with objects having explicit time-series properties. Line charts are created with close data, or from single column time series. The subset argument can be used to specify a particular area of the series to view. The underlying series is left intact to allow for TA functions to use the full data set. Additionally, it is possible to use syntax borrowed from the first and last functions, e.g. last 4 months.
chartSeries
23
TA allows for the inclusion of a variety of chart overlays and tecnical indicators. A full list is available from addTA. The default TA argument is addVo() - which adds volume, if available, to the chart being drawn. theme requires an object of class chart.theme, created by a call to chartTheme. This function can be used to modify the look of the resulting chart. See chart.theme for details. line.type and bar.type allow further ne tuning of chart styles to user tastes. multi.col implements a color coding scheme used in some charting applications, and follows the following rules: grey => Op[t] < Cl[t] and Op[t] < Cl[t-1] white => Op[t] < Cl[t] and Op[t] > Cl[t-1] red => Op[t] > Cl[t] and Op[t] < Cl[t-1] black => Op[t] > Cl[t] and Op[t] > Cl[t-1] reChart takes any number of arguments from the original chart call and redraws the chart with the updated parameters. One item of note: if multiple color bars/candles are desired, it is necessary to respecify the theme argument. Additionally it is not possible to change TA parameters at present. This must be done with addTA/dropTA/swapTA/moveTA commands. Value Returns a standard chart plus volume, if available, suitably scaled. If plot=FALSE a chob object will be returned. Note Most details can be ne-tuned within the function, though the code does a reasonable job of scaling and labelling axes for the user. The current implementation maintains a record of actions carried out for any particular chart. This is used to recreate the original when adding new indicator. A list of applied TA actions is available with a call to listTA. This list can be assigned to a variable and used in new chart calls to recreate a set of technical indicators. It is also possible to force all future charts to use the same indicators by calling setTA. Additional motivation to add outlined candles to allow for scaling and advanced color coding is owed to Josh Ulrich, as are the base functions (from TTR) for the yet to be released technical analysis charting code. Many improvements in the current version were the result of conversations with Gabor Grothendieck. Many thanks to him. Author(s) Jeffrey A. Ryan References Josh Ulrich - TTR package and multi.col coding
chartTheme
chartTheme
Description Create a chart.theme object for use within chartSeries to manage desired chart colors. Usage chartTheme(theme = "black", ...) Arguments theme ... Details Used as an argument to the chartSeries family of functions, chartTheme allows for on-the-y modication of pre-specied chart themes. Users can modify a pre-built theme in-place, or copy the theme to a new variable for use in subsequent charting calls. Internally a chart.theme object is nothing more than a list of values organized by chart components. The primary purpose of this is to facilitate minor modication on the y, as well as provide a template for larger changes. Setting style arguments for TA calls via chartTheme requires the user to pass the styles as name=value pairs with a name containing the TA call in question. See examples for assistance. Current components that may be modied with appropriate values: name of base theme name=value pairs to modify
chartTheme fg.colforeground color bg.colbackground color grid.colgrid color borderborder color minor.tickminor tickmark color major.tickmajor tickmark color up.colup bar/candle color dn.coldown bar/candle color up.up.colup after up bar/candle color up.dn.colup after down bar/candle color dn.dn.coldown after down bar/candle color dn.up.coldown after up bar/candle color up.borderup bar/candle border color dn.borderdown bar/candle border color up.up.borderup after up bar/candle border color up.dn.borderup after down bar/candle border color dn.dn.borderdown after down bar/candle border color dn.up.borderdown after up bar/candle border color Value A chart.theme object Author(s) Jeffrey A. Ryan See Also chartSeries Examples
chartTheme() chartTheme(white) chartTheme(white,up.col=blue,dn.col=red) # A TA example chartTheme(addRSI.col=red) str(chartTheme())
25
26
chart_Series
chart_Series
Description These are experimental functions for a new version of chartSeries in quantmod. Interface, behavior, and functionality will change. Usage chart_Series(x, name = deparse(substitute(x)), type = "candlesticks", subset = "", TA = "", pars = chart_pars(), theme = chart_theme(), clev = ) Arguments x name type subset TA pars theme clev Details These functions, when complete, will revert back to the original chartSeries naming convention. Value Called for graphical side effects. Note Highly experimental (read: alpha) use with caution. Author(s) Jeffrey A. Ryan time series object name for chart one of: an ISO8601 style character string indicating date range a character string of semi-colon seperated TA calls. chart parameters chart theme color level (experimental). Indicates the degree of brightness 0 is darkest color.
chob-class
27
chob-class
Description Internal Objects for Tracking and Plotting Chart Changes Objects from the Class Objects are created internally through the charting functions chartSeries, barChart, lineChart, and candleChart. Slots device: Object of class "ANY" ~~ call: Object of class "call" ~~ xdata: Object of class "ANY" ~~ xsubset: Object of class "ANY" ~~ name: Object of class "character" ~~ type: Object of class "character" ~~ passed.args: Object of class "ANY" ~~ windows: Object of class "numeric" ~~ xrange: Object of class "numeric" ~~ yrange: Object of class "numeric" ~~ log.scale: Object of class "logical" ~~ length: Object of class "numeric" ~~ color.vol: Object of class "logical" ~~ multi.col: Object of class "logical" ~~ show.vol: Object of class "logical" ~~ show.grid: Object of class "logical" ~~ line.type: Object of class "character" ~~ bar.type: Object of class "character" ~~ xlab: Object of class "character" ~~ ylab: Object of class "character" ~~ spacing: Object of class "numeric" ~~ width: Object of class "numeric" ~~ bp: Object of class "numeric" ~~ x.labels: Object of class "character" ~~ colors: Object of class "ANY" ~~ layout: Object of class "ANY" ~~ time.scale: Object of class "ANY" ~~ major.ticks: Object of class "ANY" ~~ minor.ticks: Object of class "logical" ~~
28 Methods No methods dened with class "chob" in the signature. Author(s) Jeffrey A. Ryan See Also chartSeries, or chobTA for links to other classes Examples
showClass("chob")
chobTA-class
chobTA-class
Description Internal storage class for handling arbitrary TA objects Objects from the Class Objects of class chobTA are created and returned invisibly through calls to addTA-style functions. Slots call: Object of class "call" ~~ on: Object of class "ANY" ~~ new: Object of class "logical" ~~ TA.values: Object of class "ANY" ~~ name: Object of class "character" ~~ params: Object of class "ANY" ~~ Methods show signature(object = "chobTA"): ... Note It is of no external vaule to handle chobTA objects directly Author(s) Jeffrey A. Ryan
create.binding See Also addTA, ~~~ or chob for links to other classes Examples
showClass("chobTA")
29
create.binding
Description Internal function used in attachSymbols to create active bindings for symbols dened in a DDB object. Usage create.binding(s, lsym, rsym, gsrc, mem.cache = TRUE, file.cache = !mem.cache, cache.dir = tempdir(), envir,...) Arguments s lsym rsym gsrc mem.cache file.cache cache.dir envir ... Details Low level function to create bindings during initial demand-database construction. Value Called for its side effect of creating active bindings to symbols. symbol name function to convert to local name (legal R name) function to convert to remote name (source name) corresponds to src arg in getSymbols call cache to memory cache to disk directory to cache to/from environment name (character) arguments to pass to getSymbols call
30 Note
Delt
This is code used internally by attachSymbols. Users may modify this to accomodate different systems. The upstream functions neednt maintain consistency with this interface. Use as a guide or template. Author(s) Jeffrey A. Ryan References Mark, Roger, ?
Delt
Description Calculate the k-period percent difference within one series, or between two series. Primarily used to calculate the percent change from one period to another of a given series, or to calculate the percent difference between two series over the full series. Usage Delt(x1, x2 = NULL, k = Arguments x1 x2 k type Details When called with only x1, the one period percent change of the series is returned by default. Internally this happens by copying x1 to x2. A two period difference would be specied with k=2. If called with both x1 and x2, the difference between the two is returned. That is, k=0. A one period difference would be specied by k=1. k may also be a vector to calculate more than one period at a time. The results will then be an m x length(k) Log differences are used by default: Lag = log(x2(t)/x1(t-k)) Arithmetic differences are calculated: Lag = (x2(t) - x1(t-k))/x1(t-k) Value An matrix of length(x1) rows and length(k) columns. m x 1 vector m x 1 vector change over k-periods. default k=1 when x2 is NULL. type of difference. log or arithmetic (defauly). , type = c("arithmetic", "log"))
31
findPeaks
Description Functions to nd the peaks (tops) and valleys (bottoms) of a given series. Usage findPeaks(x, thresh= ) findValleys(x, thresh= ) Arguments x thresh Value A vector of integers corresponding to peaks/valleys. As a peak[valley] is dened as the highest[lowest] value in a series, the function can only dene it after a change in direction has occurred. This means that the function will always return the rst period after the peak/valley of the data, so as not to accidentally induce a look-ahead bias. Author(s) Jeffrey A. Ryan a time series or vector minimum peak/valley threshold
32 Examples
findPeaks(sin(1:1 )) p <- findPeaks(sin(seq(1,1 ,.1))) sin(seq(1,1 ,.1))[p] plot(sin(seq(1,1 ,.1))[p]) plot(sin(seq(1,1 ,.1)),type=l) points(p,sin(seq(1,1 ,.1))[p])
ttedModel
fittedModel
Description Extract and replace tted models from quantmod objects built with buildModel. All objects tted through methods specied in buildModel calls can be extracted for further analysis. Usage fittedModel(object)
## S3 method for class quantmod formula(x, ...) ## S3 method for class quantmod plot(x, ...) ## S3 method for class quantmod coefficients(object, ...) ## S3 method for class quantmod coef(object, ...) ## S3 method for class quantmod residuals(object, ...) ## S3 method for class quantmod resid(object, ...) ## S3 method for class quantmod fitted.values(object, ...) ## S3 method for class quantmod fitted(object, ...)
ttedModel ## S3 method for class quantmod anova(object, ...) ## S3 method for class quantmod logLik(object, ...) ## S3 method for class quantmod vcov(object, ...)
33
Details Most often used to extract the nal tted object of the modelling process, usually for further analysis with tools outside the quantmod package. Most common methods to apply to tted objects are available to the parent quantmod object. At present, one can call directly the following S3 methods on a built model as if calling directly on the tted object. See *Usage* section. It is also possible to add a tted model to an object. This may be of value when applying heuristic rule sets for trading approaches, or when ne tuning already t models by hand.
Value Returns an object matching that returned by a call to the method specied in buildModel.
Note The replacement function fittedModel<- is highly experimental, and may or may not continue into further releases. The tted model added must use the same names as appear in the quantmod objects dataset.
34 Examples
## Not run: x <- specifyModel(Next(OpCl(DIA)) ~ OpCl(VIX)) x.lm <- buildModel(x,method=lm,training.per=c(2 fittedModel(x.lm) coef(fittedModel(x.lm)) coef(x.lm) vcov(fittedModel(x.lm)) vcov(x.lm) ## End(Not run)
getDividends
1- 1- 1,2
1- 4- 1))
# same
# same
getDividends
Description Download, or download and append stock dividend data from Yahoo! Finance. Usage getDividends(Symbol, from = "197 - 1- 1", to = Sys.Date(), env = .GlobalEnv, src = "yahoo", auto.assign = FALSE, auto.update = FALSE, verbose = FALSE, ...) Arguments Symbol from to env src auto.assign auto.update verbose ... The Yahoo! stock symbol date from in CCYY-MM-DD format date to in CCYY-MM-DD format where to create object data source (only yahoo is valid at present) should results be loaded to env automatically add dividend to data object display status of retrieval currently unused
getFinancials Details
35
Eventually destined to be a wrapper function along the lines of getSymbols to different sources this currently only support Yahoo data. Value If auto.assign is TRUE, the symbol will be written to the environment specied in env with a .div appended to the name. If auto.update is TRUE and the object is of class xts, the dividends will be included as an attribute of the original object and be reassigned to the environment specied by env. All other cases will return the dividend data as an xts object. Note This function is very preliminary - and will most likely change signicantly in the future. Author(s) Jeffrey A. Ryan References Yahoo! Finance: http://finance.yahoo.com See Also getSymbols Examples
## Not run: getSymbols("MSFT") getDividends("MSFT") getDividends(MSFT) ## End(Not run)
getFinancials
Description Download Income Statement, Balance Sheet, and Cash Flow Statements from Google Finance.
36 Usage getFinancials(Symbol, env = .GlobalEnv, src = "google", auto.assign = TRUE, ...) viewFinancials(x, type=c(BS,IS,CF), period=c(A,Q), subset = NULL) Arguments Symbol env src auto.assign ... x type period subset Details
getFinancials
one or more valid google symbol, as a character vector or semi-colon delimited string where to create the object currently unused should results be loaded to the environment currently unused an object of class nancials type of statement to view period of statement to view xts style subset string
A utility to download nancial statements for publically traded companies. The data is directly from Google nance. All use of the data is under there Terms of Service, available at http://www. google.com/accounts/TOS. Individual statements can be accessed using standard R list extraction tools, or by using viewFinancials. viewFinancials allows for the use of date subsetting as available in the xts package, as well as the specication of the type of statement to view. BS for balance sheet, IS for income statement, and CF for cash ow statement. The period argument is used to identify which statements to view - (A) for annual and (Q) for quarterly. Value Six individual matricies organized in a list of class nancials: IS BS CF Note As with all free data, you may be getting exactly what you pay for. a list containing (Q)uarterly and (A)nnual Income Statements a list containing (Q)uarterly and (A)nnual Balance Sheets a list containing (Q)uarterly and (A)nnual Cash Flow Statements
getFX Author(s) Jeffrey A. Ryan References Google Finance BETA: http://finance.google.com/finance Examples
## Not run: getFinancials(JAVA) # returns JAVA.f to "env" getFin(AAPL) # returns AAPL.f to "env" viewFin(JAVA.f, "IS", "Q") viewFin(AAPL.f, "CF", "A") str(AAPL.f) ## End(Not run) # Quarterly Income Statement # Annual Cash Flows
37
getFX
Description Download exchange rates or metals prices from oanda. Usage getFX(Currencies, from = Sys.Date() - 5 , to = Sys.Date(), env = .GlobalEnv, verbose = FALSE, warning = TRUE, auto.assign = TRUE, ...) Arguments Currencies from to env verbose warning auto.assign ... Currency pairs expressed as CUR/CUR start date expressed in ISO CCYY-MM-DD format end date expressed in ISO CCYY-MM-DD format which environment should they be loaded into be verbose show warnings use auto.assign additional parameters to be passed to getSymbols.oanda method
38 Details
getMetals
A convenience wrapper to getSymbols(x,src=oanda). See getSymbols and getSymbls.oanda for more detail. Value The results of the call will be the data will be assigned automatically to the environment specied (global by default). Additionally a vector of downloaded symbol names will be returned. See getSymbols and getSymbols.oanda for more detail. Author(s) Jeffrey A. Ryan References Oanda.com http://www.oanda.com See Also getSymbols, getSymbols.oanda Examples
## Not run: getFX("USD/JPY") getFX("EUR/USD",from="2 ## End(Not run) 5- 1- 1")
getMetals
Description Download daily metals prices from oanda. Usage getMetals(Metals, from = Sys.Date() - 5 , to = Sys.Date(), base.currency="USD", env = .GlobalEnv, verbose = FALSE, warning = TRUE, auto.assign = TRUE, ...)
getMetals Arguments Metals from to base.currency env verbose warning auto.assign ... metals expressed in common name or symbol form start date expressed in ISO CCYY-MM-DD format end date expressed in ISO CCYY-MM-DD format which currency should the price be in which environment should they be loaded into be verbose show warnings use auto.assign additional parameters to be passed to getSymbols.oanda method
39
Details A convenience wrapper to getSymbols(x,src=oanda). The most useful aspect of getMetals is the ablity to specify the Metals in terms of underlying 3 character symbol or by name (e.g. XAU (gold) , XAG (silver), XPD (palladium), or XPT (platinum)). There are unique aspects of any continuously traded commodity, and it is recommended that the user visit http://www.oanda.com for details on specic pricing issues. See getSymbols and getSymbls.oanda for more detail. Value Data will be assigned automatically to the environment specied (global by default). If auto.assign is set to FALSE, the data from a single metal request will simply be returned from the function call. If auto.assign is used (the default) a vector of downloaded symbol names will be returned. See getSymbols and getSymbols.oanda for more detail. Author(s) Jeffrey A. Ryan References Oanda.com http://www.oanda.com See Also getSymbols, getSymbols.oanda
40 Examples
## Not run: getFX(c("gold","XPD")) getFX("plat",from="2 ## End(Not run) 5- 1- 1")
getModelData
getModelData
Description Update currently specied or built model with most recent data. Usage getModelData(x, na.rm = TRUE) Arguments x na.rm Details Primarily used within specify model calls, getModelData is used to retrieve the appropriate underlying variables, and apply model specied transformations automatically. It can be used to also update a current model in memory with the most recent data. Value Returns object of class quantmod.OHLC Author(s) Jeffrey Ryan See Also getSymbols load data specifyModel create model structure buildModel construct model modelData extract model dataset An object of class quantmod Boolean. Remove NA values. Defaults to TRUE
getOptionChain Examples
## Not run: my.model <- specifyModel(Next(OpCl(QQQQ)) ~ Lag(Cl(NDX), :5)) getModelData(my.model) ## End(Not run)
41
getOptionChain
Description Function to download option chain data from data providers. Usage getOptionChain(Symbols, Exp = NULL, src="yahoo", ...) Arguments Symbols Exp src ... Details This function is a wrapper to data-provider specic APIs. By default the data is sourced from yahoo. Value A named list containing two data.frames, one for calls and one for puts. If more than one expiration was requested, this two-element list will be contained within list of length length(Exp). Each element of this list will be named with the expiration month and year (for Yahoo sourced data). If Exp is set to NULL, all expirations will be returned. Not explicitly setting will only return the front month. Author(s) Jeffrey A. Ryan References http://finance.yahoo.com The name of the underlying symbol One or more expiration dates, or NULL. If Exp is missing, the default is to only return the front month contract. Source of data. Currently only yahoo is provided additional parameters
42 Examples
## Not run: AAPL.OPT <- getOptionChain("AAPL") AAPL.OPTS <- getOptionChain("AAPL", NULL) ## End(Not run)
getQuote
getQuote
Description Fetch current stock quote(s) from specied source. At present this only handle sourcing quotes from Yahoo Finance, but it will be extended to additional sources over time. Usage getQuote(Symbols, src = "yahoo", what = standardQuote(), ...) standardQuote(src="yahoo") yahooQF(names) yahooQuote.EOD Arguments Symbols src what names ... Value A maximum of 200 symbols may be requested per call to Yahoo!, and all requested will be returned in one data.frame object. If more that 200 symbols are requested, multiple 200 symbol calls will be made and the results will be returned as one data object. getQuote returns a data frame with rows matching the number of Symbols requested, and the columns matching the requested columns. The what argument allows for specic data to be requested from yahoo, using Yahoo!s formatting string. A list and interactive selection tool can be seen with yahooQF. standardQuote currently only applied to Yahoo! data, and returns an object of class quoteFormat, for use within the getQuote function. yahooQuote.EOD is a constant that returns OHLCV data character string of symbols, seperated by semi-colons source of data (only yahoo is implemented) what should be retrieved which data should be retrieved currently unused
43
getSplits
Description Download, or download and append stock split data from Yahoo! Finance. Usage getSplits(Symbol, from = "197 - 1- 1", to = Sys.Date(), env = .GlobalEnv, src = "yahoo", auto.assign = FALSE, auto.update = FALSE, verbose = FALSE, ...) Arguments Symbol from to env src The Yahoo! stock symbol date from in CCYY-MM-DD format date to in CCYY-MM-DD format where to create object data source (only yahoo is valid at present)
44 auto.assign auto.update verbose ... Details should results be loaded to env automatically add split to data object display status of retrieval currently unused
getSplits
Eventually destined to be a wrapper function along the lines of getSymbols to different sources this currently only support Yahoo data. Value If auto.assign is TRUE, the symbol will be written to the environment specied in env with a .div appended to the name. If auto.update is TRUE and the object is of class xts, the dividends will be included as an attribute of the original object and be reassigned to the environment specied by env. All other cases will return the split data as an xts object. NA is returned if there is no split data. Note This function is very preliminary - and will most likely change signicantly in the future. Author(s) Josh Ulrich References Yahoo! Finance: http://finance.yahoo.com See Also getSymbols, getDividends Examples
## Not run: getSymbols("MSFT") getSplits("MSFT") getSplits(MSFT) ## End(Not run)
getSymbols
45
getSymbols
Description Functions to load and manage Symbols in specied environment. Used by specifyModel to retrieve symbols specied in rst step of modelling procedure. Not a true S3 method, but methods for different data sources follow an S3-like naming convention. Additional methods can be added by simply adhering to the convention. Current src methods available are: yahoo, google, MySQL, FRED, csv, RData, and oanda. Data is loaded silently without user assignment by default. Usage getSymbols(Symbols = NULL, env = .GlobalEnv, reload.Symbols = FALSE, verbose = FALSE, warnings = TRUE, src = "yahoo", symbol.lookup = TRUE, auto.assign = TRUE, ...) loadSymbols(Symbols = NULL, env = .GlobalEnv, reload.Symbols = FALSE, verbose = FALSE, warnings = TRUE, src = "yahoo", symbol.lookup = TRUE, auto.assign = TRUE, ...) showSymbols(env=.GlobalEnv) removeSymbols(Symbols=NULL,env=.GlobalEnv) saveSymbols(Symbols = NULL, file.path=stop("must specify file.path"), env = .GlobalEnv) Arguments Symbols env a character vector specifying the names of each symbol to be loaded where to create objects. (new.env())
46 verbose warnings src symbol.lookup auto.assign file.path ... Details boolean to turn on status of retrieval. (FALSE) boolean to turn on warnings. (TRUE) character string specifying sourcing method. (yahoo) retrieve symbols sourcing method from external lookup (TRUE) should results be loaded to the environment character string of le location additional parameters
getSymbols
getSymbols is a wrapper to load data from different sources - be them local or remote. Data is fetched through one of the available getSymbols methods and saved in the env specied - the .GlobalEnv by default. Data is loaded in much the same way that load behaves. By default, it is assigned automatically to a variable in the specied environment, without the user explicitly assigning the returned data to a variable. The previous sentences point warrants repeating - getSymbols is called for its side effects, and does not return the data object loaded. The data is loaded silently by the function into a new environment by default - or the environment specied. This behavior can be overridden by setting auto.assign to FALSE, though it is not advised. Previous versions of getSymbols assigned each object into the users .GlobalEnv by name. This behavior is now supported by setting env=.GlobalEnv (the current transitional default), or by using the wrapper loadSymbols. Many thanks to Kurt Hornik and Achim Zeileis for suggesting this change. By default the variable chosen is an R-legal name derived from the symbol being loaded. It is possible, using setSymbolLookup to specify an alternate name if the default is not desired, see that function for details. The result of a call to getSymbols when auto.assign is set to TRUE (the default) is a new object or objects in the users specied environment - with the loaded symbol(s) names returned upon exit if that environment is the .GlobalEnv. By default, a new environment is returned which contains all the objects loaded into it. If auto.assign is set to FALSE the data will be returned from the call, and will require the user to assign the results himself. Most, if not all, documentation and functionality in quantmod assumes that auto.assign remains set to TRUE. Upon completion a list of loaded symbols is stored in the global environment under the name .getSymbols. Objects loaded by getSymbols with auto.assign=TRUE can be viewed with showSymbols and removed by a call to removeSymbols. Additional data loading methods can be created simply by following the S3-like naming convention where getSymbols.NAME is used for your function NAME. See getSymbols source code.
setDefaults(getSymbols) can be used to specify defaults for getSymbols arguments. setDefaults(getSymbols.MySQL) may be used for arguments specic to getSymbols.MySQL, etc. The sourcing of data is managed internally through a complex lookup procedure. If symbol.lookup is TRUE (the default), a check is made if any symbol has had its source specied by setSymbolLookup.
getSymbols
47
If not set, the process continues by checking to see if src has been specied by the user in the function call. If not, any src dened with setDefaults(getSymbols,src=) is used. Finally, if none of the other source rules apply the default getSymbols src method is used (yahoo). Value A call to getSymbols will load into the specied environment one object for each Symbol specied, with class dened by return.class. Presently this may be ts, its, zoo, xts, or timeSeries. If auto.assign is set to FALSE an object of type return.class will be returned. Note While it is possible to load symbols as classes other than zoo, quantmod requires most, if not all, data to be of class zoo or inherited from zoo - e.g. xts. The additional methods are meant mainly to be of use for those using the functionality outside of the quantmod workow. Author(s) Jeffrey A. Ryan See Also getModelData,specifyModel, setSymbolLookup, getSymbols.csv, getSymbols.RData, getSymbols.oanda, getSymbols.yahoo, getSymbols.google, getSymbols.FRED, getFX, getMetals, Examples
## Not run: setSymbolLookup(QQQQ=yahoo,SPY=MySQL) getSymbols(c(QQQQ,SPY)) # loads QQQQ from yahoo (set with setSymbolLookup) # loads SPY from MySQL (set with setSymbolLookup) getSymbols(F) # loads Ford market data from yahoo (the formal default) setDefaults(getSymbols,verbose=TRUE,src=MySQL) getSymbols(DIA) # loads symbol from MySQL database (set with setDefaults) getSymbols(F,src=yahoo,return.class=ts) # loads Ford as time series class ts
## End(Not run)
48
getSymbols.csv
getSymbols.csv
Description Downloads Symbols to specied env from local comma seperated le. This method is not to be called directly, instead a call to getSymbols(Symbols,src=csv) will in turn call this method. It is documented for the sole purpose of highlighting the arguments accepted, and to serve as a guide to creating additional getSymbols methods. Usage getSymbols.csv(Symbols, env, dir="", return.class = "xts", extension="csv", ...) Arguments Symbols env dir return.class extension ... Details Meant to be called internally by getSymbols (see also). One of a few currently dened methods for loading data for use with quantmod. Essentially a simple wrapper to the underlying R read.csv. Value A call to getSymbols.csv will load into the specied environment one object for each Symbol specied, with class dened by return.class. Presently this may be ts, its, zoo, xts, or timeSeries. Note This has yet to be tested on a windows platform. It should work though le seperators may be an issue. a character vector specifying the names of each symbol to be loaded where to create objects. (.GlobalEnv) directory of csv le class of returned object extension of csv le additional parameters
getSymbols.FRED Author(s) Jeffrey A. Ryan See Also getSymbols, read.csv, setSymbolLookup Examples
## Not run: # All 3 getSymbols calls return the same # MSFT to the global environment # The last example is what NOT to do! ## Method #1 getSymbols(MSFT,src=csv)
49
## Method #2 setDefaults(getSymbols,src=csv) # OR setSymbolLookup(MSFT=csv) getSymbols(MSFT) ######################################### ## NOT RECOMMENDED!!! ######################################### ## Method #3 getSymbols.csv(MSFT,verbose=TRUE,env=globalenv()) ## End(Not run)
getSymbols.FRED
Description R access to over 11,000 data series accessible via the St. Louis Federal Reserve Banks FRED system. Downloads Symbols to specied env from research.stlouisfed.org. This method is not to be called directly, instead a call to getSymbols(Symbols,src=FRED) will in turn call this method. It is documented for the sole purpose of highlighting the arguments accepted, and to serve as a guide to creating additional getSymbols methods.
50 Usage getSymbols.FRED(Symbols, env, return.class = "xts", ...) Arguments Symbols env return.class ... Details Meant to be called internally by getSymbols (see also).
getSymbols.FRED
a character vector specifying the names of each symbol to be loaded where to create objects. (.GlobalEnv) class of returned object additional parameters
One of many methods for loading data for use with quantmod. Essentially a simple wrapper to the underlying FRED data download site. Naming conventions must follow those as seen on the Federal Reserve Bank of St Louiss website for FRED. A lookup facility will hopefully be incorporated into quantmod in the near future. Value A call to getSymbols.FRED will load into the specied environment one object for each Symbol specied, with class dened by return.class. Presently this may be ts, its, zoo, xts, or timeSeries. Author(s) Jeffrey A. Ryan References St. Louis Fed: Economic Data - FRED http://research.stlouisfed.org/fred2/ See Also getSymbols, setSymbolLookup Examples
## Not run: # All 3 getSymbols calls return the same # CPI data to the global environment # The last example is what NOT to do! ## Method #1 getSymbols(CPIAUCNS,src=FRED)
getSymbols.google
51
## Method #2 setDefaults(getSymbols,src=FRED) # OR setSymbolLookup(CPIAUCNS=FRED) getSymbols(CPIAUCNS) ######################################### ## NOT RECOMMENDED!!! ######################################### ## Method #3 getSymbols.FRED(CPIAUCNS,env=globalenv()) ## End(Not run)
getSymbols.google
Description Downloads Symbols to specied env from nance.google.com. This method is not to be called directly, instead a call to getSymbols(Symbols,src=google) will in turn call this method. It is documented for the sole purpose of highlighting the arguments accepted, and to serve as a guide to creating additional getSymbols methods. Usage getSymbols.google(Symbols, env, return.class = xts, from = "2 7- 1- 1", to = Sys.Date(), ...) Arguments Symbols env return.class from to ... a character vector specifying the names of each symbol to be loaded where to create objects. (.GlobalEnv) class of returned object Retrieve no earlier than this date Retrieve though this date additional parameters
getSymbols.google
One of a few currently dened methods for loading data for use with quantmod. Essentially a simple wrapper to the underlying Google Finance site for historical data. A word of warning. Google is the home of BETA, and historic data is no exception. There is a BUG in practically all series that include the dates Dec 29,30, and 31 of 2003. The data will show the wrong date and corresponding prices. This essentially makes it useless, but if they ever apply a x the data is nice(r) than Yahoo, in so much as it is all split adjusted and there is forty years worth to be had. As long as you skip the holiday week of 2003. : ) Value A call to getSymbols.google will load into the specied environment one object for each Symbol specied, with class dened by return.class. Presently this may be ts, its, zoo, xts, or timeSeries. Note As mentioned in the details section, a serious aw exists within the google database/SQL. A caution is issued when retrieving data via this method if this particular error is encountered, but one can only wonder what else may be wrong. Caveat emptor. Author(s) Jeffrey A. Ryan References Google Finance: http://finance.google.com See Also getSymbols, setSymbolLookup Examples
## Not run: # All 3 getSymbols calls return the same # MSFT to the global environment # The last example is what NOT to do! ## Method #1 getSymbols(MSFT,src=google)
getSymbols.MySQL
getSymbols(MSFT) ######################################### ## NOT RECOMMENDED!!! ######################################### ## Method #3 getSymbols.google(MSFT,verbose=TRUE,env=globalenv()) ## End(Not run)
53
getSymbols.MySQL
Description Fetch data from MySQL database. As with other methods extending the getSymbols function, this should NOT be called directly. Its documentation is meant to highlight the formal arguments, as well as provide a reference for further user contributed data tools. Usage getSymbols.MySQL(Symbols, env, return.class = xts, db.fields = c("date", "o", "h", "l", "c", "v", "a"), field.names = NULL, user = NULL, password = NULL, dbname = NULL, ...) Arguments Symbols env return.class db.fields field.names user password dbname ... a character vector specifying the names of each symbol to be loaded where to create objects. (.GlobalEnv) desired class of returned object. Can be xts, zoo, data.frame, ts, or its. (zoo) character vector indicating names of elds to retrieve names to assign to returned columns username to access database password to access database database name currently not used
getSymbols.MySQL
One of a few currently dened methods for loading data for use with quantmod. Its use requires the packages DBI and MySQL, along with a running MySQL database with tables corresponding to the Symbol name. The purpose of this abstraction is to make transparent the source of the data, allowing instead the user to concentrate on the data itself. Value A call to getSymbols.MySQL will load into the specied environment one object for each Symbol specied, with class dened by return.class. Note The default conguration needs a table named for the Symbol specied (e.g. MSFT), with column names date,o,h,l,c,v,a. For table layout changes it is best to use setDefaults(getSymbols.MySQL,...) with the new db.elds values specied. Author(s) Jeffrey A. Ryan References MySQL AB http://www.mysql.com David A. James and Saikat DebRoy (2006). R Interface to the MySQL databse. www. omegahat.org R-SIG-DB. DBI: R Database Interface See Also getSymbols, setSymbolLookup Examples
## Not run: # All 3 getSymbols calls return the same # MSFT to the global environment # The last example is what NOT to do! setDefaults(getSymbols.MySQL,user=jdoe,password=secret, dbname=tradedata) ## Method #1 getSymbols(MSFT,src=MySQL)
## Method #2 setDefaults(getSymbols,src=MySQL)
getSymbols.oanda
# OR setSymbolLookup(MSFT=MySQL) getSymbols(MSFT) ######################################### ## NOT RECOMMENDED!!! ######################################### ## Method #3 getSymbols.MySQL(MSFT,env=globalenv()) ## End(Not run)
55
getSymbols.oanda
Description Access to 191 currency and metal prices, downloadable as more that 36000 currency pairs from Oanda.com. Downloads Symbols to specied env from www.oanda.com historical currency database. This method is not meant to be called directly, instead a call to getSymbols("x",src="oanda") will in turn call this method. It is documented for the sole purpose of highlighting the arguments accepted, and to serve as a guide to creating additional getSymbols methods. Usage getSymbols.oanda(Symbols, env, return.class = "xts", from = Sys.Date() - 499, to = Sys.Date(), ...) Arguments Symbols a character vector specifying the names of each symbol to be loaded - expressed as a currency pair. (e.g. U.S. Dollar to Euro rate would be expressed as a string USD/EUR. The naming convention follows from Oanda.com, and a table of possible values is available by calling oanda.currencies where to create objects. class of returned object Start of series expressed as "CCYY-MM-DD" Start of series expressed as "CCYY-MM-DD" additional parameters
getSymbols.rda
Oanda data is 7 day daily average price data, that is Monday through Sunday. There is a limit of 500 days per request, and getSymbols will fail with a warning that the limit has been exceeded. Value A call to getSymbols(Symbols,src="oanda") will load into the specied environment one object for each Symbol specied, with class dened by return.class. Presently this may be ts, its, zoo, xts, or timeSeries. Note Oanda rates are quoted as one unit of base currency to the equivelant amount of foreign currency. Author(s) Jeffrey A. Ryan References Oanda.com http://www.oanda.com See Also Currencies: getSymbols.FRED, getSymbols Examples
## Not run: getSymbols("USD/EUR",src="oanda") getSymbols("USD/EUR",src="oanda",from="2 ## End(Not run)
5- 1- 1")
getSymbols.rda
Description Downloads Symbols to specied env from local R data le. This method is not to be called directly, instead a call to getSymbols(Symbols,src=rda) will in turn call this method. It is documented for the sole purpose of highlighting the arguments accepted, and to serve as a guide to creating additional getSymbols methods.
getSymbols.rda Usage
57
getSymbols.rda(Symbols, env, dir="", return.class = "xts", extension="rda", col.names=c("Open","High","Low","Close","Volume","Adjusted"), ...) Arguments Symbols env dir return.class extension col.names ... Details Meant to be called internally by getSymbols (see also). One of a few currently dened methods for loading data for use with quantmod. Essentially a simple wrapper to the underlying R load. Value A call to getSymbols.csv will load into the specied environment one object for each Symbol specied, with class dened by return.class. Presently this may be ts, its, zoo, xts, data.frame, or timeSeries. Author(s) Jeffrey A. Ryan See Also getSymbols, load, setSymbolLookup Examples
## Not run: # All 3 getSymbols calls return the same # MSFT to the global environment # The last example is what NOT to do! ## Method #1 getSymbols(MSFT,src=rda)
a character vector specifying the names of each symbol to be loaded where to create objects. (.GlobalEnv) directory of rda/RData le class of returned object extension of R data le data column names additional parameters
58
getSymbols(MSFT,src=RData)
getSymbols.SQLite
## Method #2 setDefaults(getSymbols,src=rda) # OR setSymbolLookup(MSFT=rda) # OR setSymbolLookup(MSFT=list(src=rda)) getSymbols(MSFT) ######################################### ## NOT RECOMMENDED!!! ######################################### ## Method #3 getSymbols.rda(MSFT,verbose=TRUE,env=globalenv()) ## End(Not run)
getSymbols.SQLite
Description Fetch data from SQLite database. As with other methods extending getSymbols this function should NOT be called directly. Usage getSymbols.SQLite(Symbols, env, return.class = xts, db.fields = c("row_names", "Open", "High", "Low", "Close", "Volume", "Adjusted"), field.names = NULL, dbname = NULL, POSIX = TRUE, ...) Arguments Symbols a character vector specifying the names of each symbol to be loaded
getSymbols.SQLite env return.class db.fields field.names dbname POSIX ... Details Meant to be called internally by getSymbols (see also) where to create the objects desired class of returned object character vector naming elds to retrieve names to assign to returned columns database name are rownames numeric additional arguments
59
One of a few currently dened methods for loading data for use with quantmod. Its use requires the packages DBI and RSQLite, along with a SQLite database. The purpose of this abstraction is to make transparent the source of the data, allowing instead the user to concentrate on the data itself. Value A call to getSymbols.SQLite will load into the specied environment one object for each Symbol specied, with class dened by return.class. Note This function is experimental at best, and has not been thoroughly tested. Use with caution, and please report any bugs to the maintainer of quantmod. Author(s) Jeffrey A. Ryan References SQLite http://www.sqlite.org David A. James RSQLite: SQLite interface for R R-SIG-DB. DBI: R Database Interface See Also getSymbols Examples
## Not run: getSymbols("QQQQ",src="SQLite") ## End(Not run)
60
getSymbols.yahoo
getSymbols.yahoo
Description Downloads Symbols to specied env from nance.yahoo.com. This method is not to be called directly, instead a call to getSymbols(Symbols,src=yahoo) will in turn call this method. It is documented for the sole purpose of highlighting the arguments accepted, and to serve as a guide to creating additional getSymbols methods. Usage getSymbols.yahoo(Symbols, env, return.class = xts, index.class = Date, from = "2 7- 1- 1", to = Sys.Date(), ...) Arguments Symbols env return.class index.class from to ... Details Meant to be called internally by getSymbols (see also). One of a few currently dened methods for loading data for use with quantmod. Essentially a simple wrapper to the underlying Yahoo! nance sites historical data download. Value A call to getSymbols.yahoo will load into the specied environment one object for each Symbol specied, with class dened by return.class. Presently this may be ts, its, zoo, xts, or timeSeries. In the case of xts objects, the indexing will be by Date. This can be altered with the index.class argument. See indexClass for more information on changing index classes. a character vector specifying the names of each symbol to be loaded where to create objects. (.GlobalEnv) class of returned object class of returned object index (xts only) Retrieve data no earlier than this date. (2007-01-01) Retrieve data through this date (Sys.Date()) additional parameters
has.OHLC Author(s) Jeffrey A. Ryan References Yahoo Finance: http://finance.yahoo.com See Also getSymbols, setSymbolLookup Examples
## Not run: # All 3 getSymbols calls return the same # MSFT to the global environment # The last example is what NOT to do! ## Method #1 getSymbols(MSFT,src=yahoo)
61
## Method #2 setDefaults(getSymbols,src=yahoo) # OR setSymbolLookup(MSFT=yahoo) getSymbols(MSFT) ######################################### ## NOT RECOMMENDED!!! ######################################### ## Method #3 getSymbols.yahoo(MSFT,env=globalenv()) ## End(Not run)
has.OHLC
Description A set of functions to check for appropriate OHLC and HLC column names within a data object, as well as the availability and position of those columns.
62 Usage is.OHLC(x) has.OHLC(x, which = FALSE) is.OHLCV(x) has.OHLCV(x, which = FALSE) is.HLC(x) has.HLC(x, which = FALSE) has.Op(x, has.Hi(x, has.Lo(x, has.Cl(x, has.Vo(x, has.Ad(x, is.BBO(x) is.TBBO(x) has.Ask(x, which = has.Bid(x, which = has.Price(x, which has.Qty(x, which = has.Trade(x, which Arguments x which Details data object disply position of match FALSE) FALSE) = FALSE) FALSE) = FALSE) which which which which which which = = = = = = FALSE) FALSE) FALSE) FALSE) FALSE) FALSE)
has.OHLC
Mostly used internally by quantmod, they can be useful for checking whether an object can be used in OHLC requiring functions like Op, OpCl, etc. Columns names must contain the full description of data, that is, Open, High, Low, Close, Volume or Adjusted. Abbreviations will return FALSE (or NA when which=TRUE). See quantmod.OHLC for details of quantmod naming conventions. is.OHLC (and is.HLC, similarly) will only return TRUE is there are columns for Open, High, Low and Close. Additional columns will not affect the value. Value A logical value indicating success or failure by default. If which=TRUE, a numeric value representing the column position will be returned. is.OHLC and is.HLC return a single value of TRUE or FALSE.
63
## End(Not run)
internal-quantmod
Description To be documented...
is.quantmod
Description Test if object is of type quantmod or quantmodResults. Usage is.quantmod(x) is.quantmodResults(x) Arguments x Value Boolean TRUE or FALSE object to test
Lag
Lag
Description Create a lagged series from data, with NA used to ll. Usage Lag(x, k = 1) ## S3 method for class quantmod.OHLC Lag(x, k = 1) ## S3 method for class zoo Lag(x, k = 1) ## S3 method for class data.frame Lag(x, k = 1) ## S3 method for class numeric Lag(x, k = 1) Arguments x k Details Shift series k-periods down, prepending NAs to front of series. Specically designed to handle quantmod.OHLC and zoo series within the quantmod workow. If no S3 method is found, a call to lag in base is made. Value The original x prepended with k NAs and missing the trailing k values. The returned series maintains the number of obs. of the original. vector or series to be lagged periods to lag.
modelData Note
65
This function differs from lag by returning the original series modied, as opposed to simply changing the time series properties. It differs from the like named Lag in the Hmisc as it deals primarily with time-series like objects. It is important to realize that if there is no applicable method for Lag, the value returned will be from lag in base. That is, coerced to ts if necessary, and subsequently shifted. Author(s) Jeffrey A. Ryan See Also lag Examples
Stock.Close <- c(1 2.12,1 2.62,1 .12,1 3. ,1 3.87,1 3.12,1 5.12) Close.Dates <- as.Date(c(1 66 ,1 661,1 662,1 665,1 666,1 667,1 668),origin="197 - 1- 1") Stock.Close <- zoo(Stock.Close,Close.Dates) Lag(Stock.Close) #lag by 1 period Lag(Stock.Close,k=1) #same Lag(Stock.Close,k=1:3) #lag 1,2 and 3 periods
modelData
Description Extract from a quantmod object the dataset created for use in modelling. specifyModel creates a zoo object for use in subsequent workow stages ( buildModel,tradeModel) that combines all model inputs, from a variety of sources, into one model frame. modelData returns this object. Usage modelData(x, data.window = NULL, exclude.training = FALSE) Arguments x a quantmod object
data.window a character vector of subset start and end dates to return exclude.training remove training period
66 Details
modelSignal
When a model is created by specifyModel, it is attached to the returned object. One of the slots of this S4 class is model.data. Value an object of class zoo containing all transformations to data specied in specifyModel. Author(s) Jeffrey A. Ryan See Also specifyModel,getModelData Examples
## Not run: m <- specifyModel(Next(OpCl(SPY)) ~ Cl(SPY) + OpHi(SPY) + Lag(Cl(SPY))) modelData(m) ## End(Not run)
modelSignal
Description Extract model signal object from quantmodResults object as an object of class zoo. Usage modelSignal(x) Arguments x Details For use after a call to tradeModel to extract the generated signal of a given quantmod model. Normally this would not need to be called by the end user unless he was manually post processing the trade results. Value A zoo object indexed by signal dates. object of class quantmodResults
67
newTA
Description Functions to assist in the creation of indicators or content to be drawn on plots produced by chartSeries. Usage addTA(ta, order = NULL, on = NA, legend = "auto", yrange = NULL, ...) newTA(FUN, preFUN, postFUN, on = NA, yrange = NULL, legend.name, fdots = TRUE, cdots = TRUE, data.at = 1, ...) Arguments ta order legend FUN preFUN postFUN on yrange data to be plotted which should the columns (if > 1) be plotted what custom legend text should be added to the chart. Main lter function name - as a symbol Pre-lter transformation or extraction function Post-lter transformation or extraction function where to draw length 2 vector of y-axis range
68 legend.name fdots cdots data.at ... Details Both addTA and newTA can be used to dynamically add custom content to a displayed chart. optional legend heading, automatically derived otherwise should any . . . be included in the main lter call
newTA
should any . . . be included in the resultant function object. fdots=TRUE will override this to TRUE. which arguement to the main lter function is for data. any additonal graphical parameters/default to be included.
addTA takes a series of values, either in a form coercible to xts or of the same length as the charted series has rows, and displays the results in either a new TA sub-window, or over/underlayed on the main price chart. If the object can be coerced to xts, the time values present must only be within the original series time-range. Internally a merge of dates occurs and will allow for the plotting of discontinuous series. The order argument allows for multiple column data to be plotted in an order that makes the most visual sense. Specifying a legend will override the standard parsing of the addTA call to attempt a guess at a suitable title for the sub-chart. Specifying this will cause the standard last value to not be printed. The . . . arg to addTA is used to set graphical parameters interpretable by lines. newTA acts as more of a skeleton function, taking functions as arguments, as well as charting parameters, and returns a function that can be called in the same manner as the built-in TA tools, such as addRSI and addMACD. Essentially a dynamic code generator that allows for highly customizable chart tools with minimal (possibly zero) coding. It is also possible to modify the resultant code to further change behavior. To create a new TA function with newTA certain arguments must be specied. The FUN argument is a function symbol (or coercible to such) that is the primary lter to be used on the core-data of a chartSeries chart. This can be like most of the functions within the TTR package e.g. RSI or EMA. The resultant object of the function call will be equal to calling the function on the original data passed into the chartSeries function that created the chart. It should be coercible to a matrix object, of one or more columns of output. By default all columns of output will be added to the chart, unless suppressed by passing the appropriately positioned type=n as the . . . arg. Note that this will not suppress the labels added to the chart. The preFUN argument will be called on the main charts data prior to passing it to FUN. This must be a function symbol or a character string of the name function to be called. The postFUN argument will be called on the resultant data returned from the FUN lter. This is useful for extracting the relevant data from the returned lter data. Like preFUN it must be a function symbol or a character string of the name of the function to be called. The yrange argument is used to provide a custom scale to the y-axis. If NULL the min and max of the data to be plotted will be used for the y-axis range. The on is used to identify which subchart to add the graphic to. By default, on=NA will draw the series in a new subchart below the last indicator. Setting this to either a positive or negative value will allow for the series to be super-imposed on, or under, the (sub)chart specied, respectively. A value of 1 refers to the main chart, and at present is the only location supported.
newTA legend.name will change the main label for a new plot.
69
fdots and cdots enable inclusion or suppression of the . . . within the resulting TA codes call to FUN, or the argument list of the new TA function, respectively. In order to facilitate user-specied graphical parameters it is usually desireable to not impose articial limits on the end-user with constraints on types of parameters available. By default the new TA function will include the dots argument, and the internal FUN call will keep all arguments, including the dots. This may pose issues if the internal function then passes those . . . arguments to a function that cant handle them. The nal argument is data.at which is the position in the FUN argument list which expects the data to be passed in at. This default to the sensible rst position, though can be changed at the time of creation by setting this argument to the required value. While the above functions are usually sufcient to construct very pleasing graphical additions to a chart, it may be necessary to modify by-hand the code produced. This can be accomplished by dumping the function to a le, or using fix on it during an interactive session. Another item of note, with respect to newTA is the naming of the main legend label. Following addTA convention, the rst add is stripped from the function name, and the rest of the calls name is used as the label. This can be overridden by specifying legend.name in the construction of the new TA call, or by passing legend into the new TA function. Subtle differences exist, with the former being the preferred solution. While both functions can be used to build new indicators without any understanding of the internal chartSeries process, it may be benecial in more complex cases to have a knowledge of the multistep process involved in creating a chart via chartSeries. to be added... Value addTA will invisibly return an S4 object of class chobTA. If this function is called interactively, the chobTA object will be evaluated and added to the current chart. newTA will return a function object that can either be assigned or evaluated. Evaluating this function will follow the logic of any standard addTA-style call, returning invisibly a chobTA object, or adding to the chart. Note Both interfaces are meant to fascilitate custom chart additions. addTA is for adding any arbitrary series to a chart, where-as newTA works with the underlying series with the main chart object. The latter also acts as a dynamic TA skeleton generation tool to help develop reusable TA generation code for use on any chart. Author(s) Jeffrey A. Ryan See Also chartSeries, TA, chob, chobTA
70 Examples
## Not run: getSymbols(SBUX) barChart(SBUX) addTA(EMA(Cl(SBUX)), on=1, col=6) addTA(OpCl(SBUX), col=4, type=b, lwd=2) # create new EMA TA function newEMA <- newTA(EMA, Cl, on=1, col=7) newEMA() newEMA(on=NA, col=5) ## End(Not run)
Next
Next
Description Create a new series with all values advanced forward one period. The value of period 1, becomes the value at period 2, value at 2 becomes the original value at 3, etc. The opposite of Lag. NA is used to ll. Usage Next(x, k = 1) ## S3 method for class quantmod.OHLC Next(x,k=1) ## S3 method for class zoo Next(x,k=1) ## S3 method for class data.frame Next(x,k=1) ## S3 method for class numeric Next(x,k=1)
Next Details Shift series k-periods up, appending NAs to end of series. Specically designed to handle quantmod.OHLC and zoo series within the quantmod workow.
71
If no S3 method is found, a call to lag in base is made, with the indexing reversed to shift the time series forward. Value The original x appended with k NAs and missing the leading k values. The returned series maintains the number of obs. of the original. Unlike Lag, only one value for k is allowed. Note This functions purpose is to get the next value of the data you hope to forecast, e.g. a stocks closing value at t+1. Specically to be used within the quantmod framework of specifyModel, as a functional wrapper to the LHS of the model equation. It is not magic - and thus will not get tomorrows values. . . Author(s) Jeffrey A. Ryan See Also specifyModel, Lag Examples
Stock.Close <- c(1 2.12,1 2.62,1 .12,1 3. ,1 3.87,1 3.12,1 5.12) Close.Dates <- as.Date(c(1 66 ,1 661,1 662,1 665,1 666,1 667,1 668),origin="197 - 1- 1") Stock.Close <- zoo(Stock.Close,Close.Dates) Next(Stock.Close) Next(Stock.Close,k=1) #one period ahead #same
merge(Next(Stock.Close),Stock.Close) ## Not run: # a simple way to build a model of next days # IBM close, given todays. Technically both # methods are equal, though the former is seen # as more intuitive...ymmv specifyModel(Next(Cl(IBM)) ~ Cl(IBM)) specifyModel(Cl(IBM) ~ Lag(Cl(IBM))) ## End(Not run)
72
OHLC.Transformations
OHLC.Transformations
Description Extract (transformed) data from a suitable OHLC object. Column names must contain the complete description - either Open, High, Low, Close, Volume, or Adjusted - though may also contain additional characters. This is the default for objects returned from most getSymbols calls. In the case of functions consisting of combined Op, Hi, Lo, Cl (e.g. ClCl(x)) the one period transformation will be applied. For example, to return the Open to Close of a object it is possible to call OpCl(x). If multiple periods are desired a call to the function Delt is necessary. seriesLo and seriesHi will return the low and high, respectively, of a given series. seriesAccel, seriesDecel, seriesIncr, and seriesDecr, return a vector of logicals indicating if the series is accellerating, decellerating, increasing, or decreasing. This is managed by diff, which provides NA ll and suitable re-indexing. These are here to make trade rules easier to read. HLC extracts the High, Low, and Close columns. OHLC extracts the Open, High, Low, and Close columns. These functions are merely to speed the model specication process. All columns may also be extracted through standard R methods. Assignment will not work at present. Usage Op(x) Hi(x) Lo(x) Cl(x) Vo(x) Ad(x) seriesHi(x) seriesLo(x) seriesIncr(x, thresh= , diff.=1L) seriesDecr(x, thresh= , diff.=1L) OpCl(x) ClCl(x) HiCl(x) LoCl(x) LoHi(x) OpHi(x) OpLo(x) OpOp(x)
OHLC.Transformations
73
HLC(x) OHLC(x) Arguments x thresh diff. Details Internally, the code uses grep to locate the appropriate columns. Therefore it is necessary to use inputs with column names matching the requirements in the description section, though the exact naming convention is not as important. Value Returns an object of the same class as the original series, with the appropriately column names if applicable and/or possible. The only exceptions are for quantmod.OHLC objects which will be returned as zoo objects, and calls to seriesLo and seriesHi which may return a numeric value instead of the original object type. Author(s) Jeffrey A. Ryan See Also specifyModel Examples
## Not run: getSymbols(IBM,src=yahoo) Ad(IBM) Cl(IBM) ClCl(IBM) seriesHi(IBM) seriesHi(Lo(IBM)) removeSymbols(IBM) ## End(Not run)
A data object with columns containing data to be extracted. noise threshold (seriesIncr/seriesDecr) differencing (seriesIncr/seriesDecr)
74
options.expiry
options.expiry
Description Return the index of the contract expiration date. The third Friday of the month for options, the last third Friday of the quarter for futures. Usage options.expiry(x) futures.expiry(x) Arguments x Details Designed to be used within a charting context via addExpiry, the values returned are based on the description above. Exceptions, though rare, are not accounted for. Value A numeric vector of values to index on. Note There is currently no accounting for holidays that may interfere with the general rule. Additionally all efforts have been focused on US equity and futures markets. Author(s) Jeffrey A. Ryan References ~put references to the literature/web site here ~ See Also addExpiry a time-indexed zoo object
periodReturn Examples
## Not run: getSymbols("AAPL") options.expiry(AAPL) futures.expiry(AAPL) AAPL[options.expiry(AAPL)] ## End(Not run)
75
periodReturn
Description Given a set of prices, return periodic returns. Usage periodReturn(x, period=monthly, subset=NULL, type=arithmetic, leading=TRUE, ...) dailyReturn(x, subset=NULL, type=arithmetic, leading=TRUE, ...) weeklyReturn(x, subset=NULL, type=arithmetic, leading=TRUE, ...) monthlyReturn(x, subset=NULL, type=arithmetic, leading=TRUE, ...) quarterlyReturn(x, subset=NULL, type=arithmetic, leading=TRUE, ...) annualReturn(x, subset=NULL, type=arithmetic, leading=TRUE, ...) yearlyReturn(x, subset=NULL, type=arithmetic, leading=TRUE, ...) allReturns(x, subset=NULL, type=arithmetic, leading=TRUE) Arguments x period object of state prices, or an OHLC type object character string indicating time period. Valid entries are daily, weekly, monthly, quarterly, yearly. All are accessible from wrapper functions described below. Defaults to monthly returns (same as monthlyReturn)
76 subset type leading ... an xts/ISO8601 style subset string type of returns: arithmetic (discrete) or log (continuous) should incomplete leading period returns be returned passed along to to.period
periodReturn
Details periodReturn is the underlying function for wrappers: allReturns: calculate all available return periods dailyReturn: calculate daily returns weeklyReturn: calculate weekly returns monthlyReturn: calculate monthly returns quarterlyReturn: calculate quarterly returns annualReturn: calculate annual returns Value Returns object of the class that was originally passed in, with the possible exception of monthly and quarterly return indicies being changed to class yearmon and yearqtr where available. This can be overridden with the indexAt argument passed in the . . . to the to.period function. By default, if subset is NULL, the full dataset will be used. Note Attempts are made to re-convert the resultant series to its original class, if supported by the xts package. At present, objects inheriting from the ts class are returned as xts objects. This is to make the results more visually appealling and informative. All xts objects can be converted to class ts with as.ts if that is desirable. The rst and nal row of returned object will have the period return to last date, i.e. this week/month/quarter/year return to date even if the start/end is not the start/end of the period. Leading period calculations can be suppressed by setting leading=FALSE. Author(s) Jeffrey A. Ryan See Also getSymbols
quantmod-class Examples
## Not run: getSymbols(QQQQ,src=yahoo) allReturns(QQQQ) # returns all periods periodReturn(QQQQ,period=yearly,subset=2 periodReturn(QQQQ,period=yearly,subset=2 rm(QQQQ) ## End(Not run) 3::) # returns years 2 3) # returns year 2 3 3 to present
77
quantmod-class
Class "quantmod"
Description Objects of class quantmod help to manage the process of model building within the quantmod package. Created automatically by a call to specifyModel they carry information to be used by a variety of accessor functions and methods. Objects from the Class Objects can be created by calls of the form new("quantmod", ...). Normally objects are created as a result of a call to specifyModel. Slots model.id: Object of class "character" ~~ model.spec: Object of class "formula" ~~ model.formula: Object of class "formula" ~~ model.target: Object of class "character" ~~ model.inputs: Object of class "character" ~~ build.inputs: Object of class "character" ~~ symbols: Object of class "character" ~~ product: Object of class "character" ~~ price.levels: Object of class "zoo" ~~ training.data: Object of class "Date" ~~ build.date: Object of class "Date" ~~ fitted.model: Object of class "ANY" ~~ model.data: Object of class "zoo" ~~ quantmod.version: Object of class "numeric" ~~
78 Methods No methods dened with class "quantmod" in the signature. Author(s) Jeffrey A. Ryan Examples
showClass("quantmod")
quantmod.OHLC
quantmod.OHLC
Description Coerce an object with the apporpriate columns to class quantmod.OHLC, which extends zoo. Usage as.quantmod.OHLC(x, col.names = c("Open", "High", "Low", "Close", "Volume", "Adjusted"), name = NULL, ...) Arguments x col.names name ... Details quantmod.OHLC is actually just a renaming of an object of class zoo, with the convention of NAME.Open, NAME.High, ... for the column names. Additionally methods may be written to handle or check for the above conditions within other functions - as is the case within the quantmod package. Value An object of class c(quantmod.OHLC,zoo) Author(s) Jeffrey A. Ryan object of class zoo sufx for columns name to attach unique column sufxes to, defaults to the object name additional arguments (unused)
79
saveChart
Description Save selected chart to an external le. Usage saveChart(.type = "pdf", ..., dev = dev.cur()) Arguments .type ... dev Details This function wraps the base R function pdf, postscript, png, jpeg, and bitmap. The .type argument must specify which device driver is desired. The currently active device is used if dev is missing. The result is an exact copy (within the device limits) of the chart specied. The name of the resultant le is derived from the name of the chart, with the appropriate extension appended. (from .type). Specifying the appropriate device le/lename will override this name. The caller may specify any parameters that are valid for the device called. Internally, effort is made to match the dimensions of the device being used to create the output le. User supplied dimensions will override this internal calculation. Value A le in the current directory (default) matching the type of the output requested. Note As this uses do.call internally to create the new output device, any device that makes use of R conventions should be acceptable as a value for .type Author(s) Jeffrey A. Ryan type of export. See Details. arguments to pass to device which device should be exported
setSymbolLookup
setSymbolLookup
Description Create and manage Symbol defaults lookup table within R session for use in getSymbols calls. Usage setSymbolLookup(...) getSymbolLookup(Symbols=NULL) unsetSymbolLookup(Symbols,confirm=TRUE) saveSymbolLookup(file,dir="") loadSymbolLookup(file,dir="") Arguments ... Symbols confirm file dir name=value pairs for symbol defaults name of symbol(s) warn before deleting lookup table lename directory of lename
setSymbolLookup Details
81
Use of these functions allows the user to specify a set of default parameters for each Symbol to be loaded. Different sources (e.g. yahoo, MySQL, csv), can be specied for each Symbol of interest. The sources must be valid getSymbols methods - see getSymbols for details on which methods are available, as well as how to add additional methods. The argument list to setSymbolLookup is simply the unquoted name of the Symbol matched to the desired default source, or list of Symbol specic parameters.
For example, to signify that the stock data for Sun Microsystems (JAVA) should be downloaded from Yahoo! Finance, one would call setSymbolLookup(JAVA=yahoo) or setSymbolLookup(JAVA=list(src=yahoo) It is also possible to specify additional, possibly source specic, lookup details on a per symbol basis. These include an alternate naming convention (useful for sites like Yahoo! where certain non-traded symbols are prepended with a caret, or more correctly a curcumex accent. In that case one would specify setSymbolLookup(DJI=list(name="^DJI",src="yahoo"))) as well as passed parameters like dbname and password for database sources. See the specic getSymbols function related to the source in question for more details of each implementation. If a single named list is passed into the function without naming the list as a parameter, the names of this list will be presumed to be symbol names to be added to the current list of symbols. All changes are made to the current list, and will persist only until the end of the session. To always use the same defaults it is necessary to call setSymbolLookup with the appropriate parameters from a startup le (e.g. .Rprole) or to use saveSymbolLookup and loadSymbolLookup to save and restore lookup tables. To unset a specic Symbols defaults, simply assign NULL to the Symbol. Value Called for its side effects, the function changes the options value for the specied Symbol through a call to options(getSymbols.sources=...) Note Changes are NOT persistent across sessions, as the table is stored in the session options by default. This may change to allow for an easier to manage process, as for now it is designed to minimize the clutter created during a typical session. Author(s) Jeffrey A. Ryan See Also getSymbols, options,
82 Examples
setSymbolLookup(QQQQ=yahoo,DIA=MySQL) getSymbolLookup(QQQQ) getSymbolLookup(c(QQQQ,DIA)) ## Not run: ## Will download QQQQ from yahoo ## and load DIA from MySQL getSymbols(c(QQQQ,DIA)) ## End(Not run) ## Use something like this to always retrieve ## from the same source .First <- function() { require(quantmod,quietly=TRUE) quantmod::setSymbolLookup(JAVA="MySQL") } ## OR saveSymbolLookup() loadSymbolLookup()
setTA
setTA
Description Used to manage the TA arguments used inside chartSeries calls. Usage setTA(type = c("chartSeries", "barChart", "candleChart")) listTA(dev) Arguments type dev Details setTA and unsetTA provide a simple way to reuse the same TA arguments for multiple charts. By default all charting functions will be set to use the current charts defaults. the function to apply defaults TAs to the device to display TA arguments for
specifyModel
83
It is important to note that the current device will be used to extract the list of TA arguments to apply. This is done with a call to listTA internally, and followed by calls to setDefaults of the appropriate functions. An additional way to set default TA arguments for subsequent charts is via setDefaults. See the examples. Value Called for its side-effect of setting the default TA arguments to quantmods charting functions. Note Using setDefaults directly will require the vector of default TA calls to be wrapped in a call to substitute to prevent unintended evaluations; OR a call to listTA to get the present TA arguments. This last approach is what setTA wraps. Author(s) Jeffrey A. Ryan See Also chartSeries, addTA Examples
## Not run: listTA() setTA() # a longer way to accomplish the same setDefaults(chartSeries,TA=listTA()) setDefaults(barCart,TA=listTA()) setDefaults(candleChart,TA=listTA()) setDefaults(chartSeries,TA=substitute(c(addVo(),addBBands()))) ## End(Not run)
specifyModel
Description Create a single reusable model specication for subsequent buildModel calls. An object of class quantmod is created that can be then be reused with different modelling methods and parameters. No data frame is specied, as data is retrieved from potentially multiple environments, and internal calls to getSymbols.
specifyModel
an object of class formula (or one that can be coerced to that class): a symbolic description of the model to be tted. The details of model specifcation are given under Details. remove all incomplete rows.
na.rm Details
Models are specied through the standard formula mechanism. As nancial models may include a variety of nancial and economic indicators, each differing in source, frequency, and/or class, a single mechanism to specify sources is included within a call to specifyModel. See getModelData for details of how this process works. Currently, objects of class quantmod.OHLC, zoo, ts and its are supported within the model formula. All symbols are rst retrieved from the global environment, without inheritence. If an object is not found in the global environment, it is added to a list of objects to load through the getSymbols function. getSymbols retrieves each object specied by using information as to its location specied apriori via setDefaults or setSymbolLookup. Internally all data is coerced to zoo,data.frame, or numeric classes. Value Returns an object of class quantmod. Use modelData to extract full data set as zoo object. Note It is possible to include any supported series in the formula by simply specifying the objects symbol. See *Details* for a list of currently supported classes. Use getSymbols.skeleton to create additional methods of data sourcing, e.g. from a proprietary data format or currently unimplemented source (Bloomberg, Oracle). See getSymbols.MySQL and getSymbols.yahoo for examples of adding additional functionality Author(s) Jeffrey Ryan References quantmod.com http://www.quantmod.com See Also getModelData,getSymbols, buildModel,tradeModel,formula setSymbolLookup
TA Examples
## Not run: # if QQQQ is not in the Global environment, an attempt will be made # to retrieve it from the source specified with getSymbols.Default specifyModel(Next(OpCl(QQQQ)) ~ Lag(OpHi(QQQQ), :3) + Hi(DIA)) ## End(Not run)
85
TA
Description Functions to add technical indicators to a chart. Details The general mechanism to add technical analysis studies or overlays to a nancial chart created with chartSeries. Functionality marked with a * is via the TTR package. General TA charting tool functions: addTAadd data as custom indicator dropTAremove technical indicator moveTAmove a technical indicator swapTAswap two technical indicators Current technical indicators include: addADXadd Welles Wilders Directional Movement Indicator* addATRadd Average True Range * addAroonadd Aroon Indicator * addAroonOscadd Aroon Oscillator * addBBands:add Bollinger Bands * addCCIadd Commodity Channel Index * addCMFadd Chaiken Money Flow * addChADadd Chaiken Accumulation Distribution Line * addChVoladd Chaiken Volatility * addCMOadd Chande Momentum Oscillator * addDEMAadd Double Exponential Moving Average * addDPOadd Detrended Price Oscillator * addEMAadd Exponential Moving Average *
86 addEMVadd Arms Ease of Movement * addEnvelopeadd Moving Average Envelope addEVWMAadd Exponential Volume Weighted Moving Average * addExpiryadd options or futures expiration lines addKSTadd Know Sure Thing * addLinesadd line(s) addMACD:add Moving Average Convergence Divergence * addMFIadd Money Flow Index * addMomentumadd Momentum * addOBVadd On-Balance Volume * addPointsadd point(s) addROC:add Rate of Change * addRSIadd Relative Strength Indicator * addSARadd Parabolic SAR * addSMAadd Simple Moving Average * addSMIadd Stochastic Momentum Index * addTDIadd Trend Direction Index * addTRIXadd Triple Smoothed Exponential Oscillator * addVoadd Volume if available addVolatilityadd volatility * addWMAadd Weighted Moving Average * addWPRadd Williams Percent R * addZigZagadd Zig Zag * addZLEMAadd ZLEMA *
TA
See the individual functions for specic implementation and argument details. Details of the underlying TTR implementations can be found in TTR. The primary changes between the add*** version of an indicator and the TTR base function is the absense of the data argument in the former. Notable additions include on, with.col. Value Called for its side effects, an object to class chobTA will be returned invisibly. If called from the R command line the method will draw the appropriate indicator on the current chart. Note Calling any of the above methods from within a function or script will generally require them to be wrapped in a plot call as they rely on the context of the call to initiate the actual charting addition.
87
tradeModel
Description Simulated trading of tted quantmod object. Given a tted model, tradeModel calculates the signal generated over a given historical period, then applies specied trade.rule to calculate and return a tradeLog object. Additional methods can then be called to evaluate the performance of the models strategy. Usage tradeModel(x, signal.threshold = c( , ), leverage = 1, return.model = TRUE, plot.model = FALSE, trade.dates = NULL, exclude.training = TRUE, ret.type = c("weeks", "months", "quarters", "years"), ...) Arguments x a quantmod object from buildModel signal.threshold a numeric vector describing simple lower and upper thresholds before trade occurs leverage return.model plot.model amount of leverage to apply - currently a constant should the full model be returned? plot the model?
trade.dates specic trade interval - defaults to full dataset exclude.training exclude the period trained on? ret.type ... a table of period returns additional parameters needed by the underlying modelling function, if any
88 Details
zoomChart
Still highly experimental and changing. The purpose is to apply a newly contructed model from buildModel to a new dataset to investigate the models trading potential. At present all parameters are very basic. The near term changes include allowing for a trade.rule argument to allow for a dynamic trade rule given a set of signals. Additional the application of variable leverage and costs will become part of the nal structure. Any suggestions as to inclusions or alterations are appreciated and should be directed to the maintainer of the package. Value A quantmodResults object Author(s) Jeffrey A. Ryan See Also specifyModel buildModel Examples
## Not run: m <- specifyModel(Next(OpCl(QQQQ)) ~ Lag(OpHi(QQQQ))) m.built <- buildModel(m,method=rpart,training.per=c(2 tradeModel(m.built) tradeModel(m.built,leverage=2) ## End(Not run)
7- 1- 1,2
7- 4- 1))
zoomChart
Description Using xts style date subsetting, zoom into or out of the current chart. Usage zooom(n=1, eps=2) zoomChart(subset, yrange=NULL)
zoomChart Arguments n eps subset yrange Details the number of interactive view changes per call the distance between clicks to be considered a valid subset request a valid subset string override y-scale
89
These function allow for viewing of specic areas of a chart produced by chartSeries by simply specifying the dates of interest zooom is an interactive chart version of zoomChart which utilizes the standard R device interaction tool locator to estimate the subset desired. This estimate is then passed to zoomChart for actual redrawing. At present it is quite experimental in its interface and arguments. Its usage entails a call to zooom() followed by the selection of the leftmost and rightmost points desired in the newly zoomed chart. This selection is accomplished by the user left-clicking each extreme point. Two click are required to determine the level of zooming. Double clicking will reset the chart to the full data range. The arguments and internal working of this function are likely to change dramatically in future releases, though its use will likely remain. Standard format for the subset argument is the same as the subsetting for xts objects, which is how the data is stored internally for rendering. Calling zoomChart with no arguments (NULL) resets the chart to the original data. Examples include 2007 for all of the year 2007, 2007::2008 for years 2007 through 2008, ::2007 for all data from the beginning of the set to the end of 2007, 2007:: all data from the beginning of 2007 through the end of the data. For specics regarding the level of detail and internal interpretation please see [.xts Value This function is called for its side effect - notably changing the perspective of the current chart, and changing its formal subset level. The underlying data attached to the chart is left unchanged. Author(s) Jeffrey A. Ryan See Also chartSeries Examples
## Not run: data(sample_matrix) chartSeries(sample_matrix) zoomChart(2 7- 4::) zoomChart()
90
zooom() # interactive example ## End(Not run)
zoomChart
Index
Topic IO getQuote, 42 Topic aplot newTA, 67 saveChart, 79 TA, 85 Topic classes chob-class, 27 chobTA-class, 28 quantmod-class, 77 Topic datagen buildData, 18 Lag, 64 Next, 70 Topic datasets getModelData, 40 getSymbols.oanda, 55 Topic data getQuote, 42 getSymbols, 45 getSymbols.csv, 48 getSymbols.FRED, 49 getSymbols.google, 51 getSymbols.MySQL, 53 getSymbols.rda, 56 getSymbols.yahoo, 60 modelData, 65 quantmod.OHLC, 78 Topic device saveChart, 79 Topic dplot chart_Series, 26 newTA, 67 saveChart, 79 Topic hplot newTA, 67 Topic misc adjustOHLC, 15 attachSymbols, 16 91 create.binding, 29 findPeaks, 31 Lag, 64 Next, 70 Topic models buildModel, 20 fittedModel, 32 specifyModel, 83 tradeModel, 87 Topic package quantmod-package, 3 Topic ts Lag, 64 Topic utilities addADX, 4 addBBands, 5 addExpiry, 6 addMA, 7 addMACD, 8 addROC, 9 addRSI, 10 addSAR, 11 addSMI, 12 addVo, 13 addWPR, 14 chartSeries, 21 chartTheme, 24 Delt, 30 getDividends, 34 getFinancials, 35 getFX, 37 getMetals, 38 getOptionChain, 41 getSplits, 43 getSymbols.SQLite, 58 has.OHLC, 61 internal-quantmod, 63 is.quantmod, 63 modelData, 65
92 modelSignal, 66 OHLC.Transformations, 72 options.expiry, 74 periodReturn, 75 setSymbolLookup, 80 setTA, 82 zoomChart, 88 Ad (OHLC.Transformations), 72 add_axis (chart_Series), 26 add_BBands (chart_Series), 26 add_MACD (chart_Series), 26 add_RSI (chart_Series), 26 add_Series (chart_Series), 26 add_SMA (chart_Series), 26 add_SMI (chart_Series), 26 add_TA (chart_Series), 26 add_Vo (chart_Series), 26 addADX, 4 addAroon (TA), 85 addAroonOsc (TA), 85 addATR (TA), 85 addBBands, 5 addCCI (TA), 85 addChAD (TA), 85 addChVol (TA), 85 addCLV (TA), 85 addCMF (TA), 85 addCMO (TA), 85 addDEMA (addMA), 7 addDPO (TA), 85 addEMA (addMA), 7 addEMV (TA), 85 addEnvelope (TA), 85 addEVWMA (addMA), 7 addExpiry, 6, 74 addKST (TA), 85 addLines (TA), 85 addMA, 7 addMACD, 8 addMFI (TA), 85 addMomentum (TA), 85 addOBV (TA), 85 addPoints (TA), 85 addROC, 9 addRSI, 10 addSAR, 11 addShading (internal-quantmod), 63 addSMA (addMA), 7
INDEX addSMI, 12 addTA, 46, 814, 24, 29, 83 addTA (newTA), 67 addTDI (TA), 85 addTRIX (TA), 85 addVo, 13 addVolatility (TA), 85 addWMA (addMA), 7 addWPR, 14 addZigZag (TA), 85 addZLEMA (addMA), 7 adjustOHLC, 15 allReturns (periodReturn), 75 annualReturn (periodReturn), 75 anova.quantmod (fittedModel), 32 as.quantmod.OHLC (quantmod.OHLC), 78 attachSymbols, 16 axTicksByTime2 (chart_Series), 26 axTicksByValue (chart_Series), 26 barChart (chartSeries), 21 bitmap, 80 buildData, 18 buildModel, 20, 33, 40, 84, 88 candleChart (chartSeries), 21 chart_pars (chart_Series), 26 chart_Series, 26 chart_theme (chart_Series), 26 chartSeries, 21, 25, 28, 69, 83, 89 chartShading (internal-quantmod), 63 chartTA (newTA), 67 chartTheme, 24, 24 chob, 29, 69 chob-class, 27 chobTA, 28, 69 chobTA-class, 28 Cl (OHLC.Transformations), 72 ClCl (OHLC.Transformations), 72 coef.quantmod (fittedModel), 32 coefficients.quantmod (fittedModel), 32 create.binding, 29 current.chob (chartSeries), 21 dailyReturn (periodReturn), 75 Delt, 30 dropTA (TA), 85 findPeaks, 31
INDEX findValleys (findPeaks), 31 fitted.quantmod (fittedModel), 32 fitted.values.quantmod (fittedModel), 32 fittedModel, 32 fittedModel<- (fittedModel), 32 fittedModel<-,quantmod-method (quantmod-class), 77 fittedModel<--methods (quantmod-class), 77 flushSymbols (attachSymbols), 16 formula, 84 formula.quantmod (fittedModel), 32 futures.expiry (options.expiry), 74 getDividends, 16, 34, 44 getFin (getFinancials), 35 getFinancials, 35 getFX, 37, 47 getMetals, 38, 47 getModelData, 40, 47, 66, 84 getOptionChain, 41 getPrice (OHLC.Transformations), 72 getQuote, 42 getSplits, 16, 43 getSymbolLookup (setSymbolLookup), 80 getSymbols, 19, 24, 35, 3840, 43, 44, 45, 49, 50, 52, 54, 56, 57, 59, 61, 76, 79, 81, 84 getSymbols.csv, 47, 48 getSymbols.FRED, 47, 49, 56 getSymbols.google, 47, 51 getSymbols.MySQL, 53 getSymbols.mysql (getSymbols.MySQL), 53 getSymbols.oanda, 38, 39, 47, 55 getSymbols.rda, 56 getSymbols.RData, 47 getSymbols.RData (getSymbols.rda), 56 getSymbols.SQLite, 58 getSymbols.yahoo, 16, 47, 60 has.Ad (has.OHLC), 61 has.Ask (has.OHLC), 61 has.Bid (has.OHLC), 61 has.Cl (has.OHLC), 61 has.Hi (has.OHLC), 61 has.HLC (has.OHLC), 61 has.Lo (has.OHLC), 61 has.OHLC, 61 has.OHLCV (has.OHLC), 61 has.Op (has.OHLC), 61 has.Price (has.OHLC), 61 has.Qty (has.OHLC), 61 has.Trade (has.OHLC), 61 has.Vo (has.OHLC), 61 Hi (OHLC.Transformations), 72 HiCl (OHLC.Transformations), 72 HLC (OHLC.Transformations), 72 internal-quantmod, 63 is.BBO (has.OHLC), 61 is.HLC (has.OHLC), 61 is.OHLC (has.OHLC), 61 is.OHLCV (has.OHLC), 61 is.quantmod, 63 is.quantmodResults (is.quantmod), 63 is.TBBO (has.OHLC), 61 jpeg, 80
93
Lag, 64, 71 lag, 65 lineChart (chartSeries), 21 listTA (setTA), 82 Lo (OHLC.Transformations), 72 load, 57 loadSymbolLookup (setSymbolLookup), 80 loadSymbols (getSymbols), 45 LoCl (OHLC.Transformations), 72 logLik.quantmod (fittedModel), 32 LoHi (OHLC.Transformations), 72 matchChart (chartSeries), 21 modelData, 19, 40, 65 modelSignal, 66 monthlyReturn (periodReturn), 75 moveTA (TA), 85 new.replot (chart_Series), 26 newTA, 67 Next, 70 oanda.currencies (getSymbols.oanda), 55 OHLC (OHLC.Transformations), 72 OHLC.Transformations, 63, 72, 79 OHLCV (OHLC.Transformations), 72 Op (OHLC.Transformations), 72 OpCl, 31 OpCl (OHLC.Transformations), 72 OpHi (OHLC.Transformations), 72
94 OpLo (OHLC.Transformations), 72 OpOp, 31 OpOp (OHLC.Transformations), 72 options, 81 options.expiry, 74 pdf, 80 peak (findPeaks), 31 periodReturn, 75 plot.quantmod (fittedModel), 32 png, 80 postscript, 80 quantmod, 33 quantmod (quantmod-package), 3 quantmod-class, 77 quantmod-package, 3 quantmod.OHLC, 62, 63, 78 quantmodResults-class (quantmod-class), 77 quantmodReturn-class (quantmod-class), 77 quarterlyReturn (periodReturn), 75 read.csv, 49 reChart (chartSeries), 21 removeSymbols (getSymbols), 45 resid.quantmod (fittedModel), 32 residuals.quantmod (fittedModel), 32 saveChart, 79 saveSymbolLookup (setSymbolLookup), 80 saveSymbols (getSymbols), 45 seriesAccel (OHLC.Transformations), 72 seriesDecel (OHLC.Transformations), 72 seriesDecr (OHLC.Transformations), 72 seriesHi (OHLC.Transformations), 72 seriesIncr (OHLC.Transformations), 72 seriesLo (OHLC.Transformations), 72 setSymbolLookup, 47, 49, 50, 52, 54, 57, 61, 80, 84 setTA, 24, 82 show,chobTA-method (chobTA-class), 28 show,quantmod-method (quantmod-class), 77 show,quantmodResults-method (quantmod-class), 77 show,tradeLog-method (quantmod-class), 77
INDEX showSymbols (getSymbols), 45 specifyModel, 1921, 40, 45, 47, 64, 66, 71, 73, 83, 88 standardQuote (getQuote), 42 summary,quantmod-method (quantmod-class), 77 swapTA (TA), 85 TA, 69, 85 tradeLog-class (quantmod-class), 77 tradeModel, 21, 64, 67, 84, 87 unsetSymbolLookup (setSymbolLookup), 80 unsetTA (setTA), 82 valley (findPeaks), 31 vcov.quantmod (fittedModel), 32 viewFin (getFinancials), 35 viewFinancials (getFinancials), 35 Vo (OHLC.Transformations), 72 weeklyReturn (periodReturn), 75 yahooQF (getQuote), 42 yahooQuote.EOD (getQuote), 42 yearlyReturn (periodReturn), 75 zoom (zoomChart), 88 zoom_Chart (chart_Series), 26 zoomChart, 88 zooom (zoomChart), 88