quantmod

 

quantmod – Quantitive Financial Modelling Framework

 

finance in r getSymbol quantmod get finance data get data google yahoo bitcoin

 

getSymbols(Symbols, env, reload.Symbols, verbose, warnings, src, symbol.lookup, auto.assign,…) loadSymbols(Symbols, env, reload.Symbols, verbose, warnings, src, symbol.lookup, auto.assign,…)

 

  • Symbols: names of each symbol to be loaded (char)
  • env: where to create objects Setting env=NULL is equal to auto.assign=FALSE
  • reload.Symbols: boolean to reload current symbols in specified environment. (FALSE)
  • verbose: boolean to turn on status of retrieval. (FALSE)
  • warnings: boolean to turn on warnings. (TRUE)
  • src: sourcing method, ‘yahoo’, ‘Goog’ (char)
  • symbol.lookup: retrieve symbol’s sourcing method from external lookup (TRUE)
  • auto.assign: should results be loaded to env If FALSE, return results instead.

 

Quandl::Quandl() Retrieves data from Quandl dataset endpoint and formats
Quandle(code, type, transform, collapse, order, meta , force_irregularity)
type = c(“raw”, “ts”, “zoo”, “xts”, “timeSeries”)
transform = c(“”, “diff”, “rdiff”, “normalize”, “cumul”, “rdiff_from”)
collapse = c(“”, “daily”, “weekly”, “monthly”, “quarterly”, “annual”)
order = c(“desc”, “asc”)

 

manipulatiing finance data in r transform finance time data in r rdiff-form normalize

 

r quantmode package importing and manipulating finance data in r for time series technical analysis i r

 

  • getDividends
    • Symbol
    • from
    • to
    • env
    • src
    • auto.assign
    • auto.update
    • verbose
    • aplit.adjust
  • getFinancials: get financial statements
  • getFX: get Exchange rates
  • getMetals: daily Metals Prices
  • getModelData
  • getOptionChain
  • getQuote
  • getSplits
  • getSymbols: Load and manage Data from Multiple Sources
    • Symbols = NULL
    • env = parent.frame()
    • reload.Symbols = FALSE
    • verbose = FALSE
    • warnings = TRUE
    • src = “yahoo”
    • symbol.lookup = TRUE
    • auto.assign = getOption(‘getSymbols.auto.assign’,TRUE),
  • getSymbols.av: Download OHLC Data from Alpha Vantage
  • getSymbols.csv
  • getSymbols.FRED
  • getSymbols.google
  • getSymbols.MySQL
  • getSymbols.oanda
  • getSymbols.rda
  • getSymbols.SQLite
  • getSymbols.yahoo
  • getSymbols.yahooj: Yahoo Japan Finance

 

  • Delt: Calculate precent change
    • x1: m x l vector
    • x2: m x l vector
    • k = 0: change over k-periods, default k = 1 when x2 is NULL
    • type: type of difference, log or arthimetic
    • Delt(Stock.Open)
    • Delt(Stock.Open, type = “arithmetic”)
    • Delt(Stock.Open, type = “log”)
    • Delt(Stock.Open, Stock.Close, k = 0:2)
  • findPeaks: Find Peaks and Valleys In a Series
    • x: a time series or vector
    • thresh= 0: min peak/valley threshhold
  • getDividents
    • Symbol
    • from
    • to
    • env
    • src
  • Lag
  • adjustOHLC
  • has.OHLC
  • OHLC.Transformations
  • quantmod.OHLC
  • attachSymbols
  • buildData
  • buildModel

https://cran.r-project.org/web/packages/quantmod/quantmod.pdf

 


Charting in quantmod

  • chartSeries: Create Financial Charts
    • x: an OHLC object
    • type = c(“auto”, “candlesticks”, “matchsticks”, “bars”,”line”)
    • subset = “201705/”: xts style date subsetting argument
    • show.grid = TRUE: display price grid lines
    • name = NULL: name of chart
    • time.scale = NULL
    • log.scale = FALSE
    • TA = ‘addVo()’: vector/s of technical indicators and params or char strings
    • TAsep=’;’: TA delimiter for TA strings
    • line.type = “l”:
    • bar.type = “ohlc”: barchart ohlc or hlc
    • theme = chartTheme(“black”)
    • layout = NA: if NULL bypass internal layout
    • major.ticks=’auto’: where should major ticks be drawn
    • minor.ticks=TRUE: should minor ticks be drawn
    • yrange=NULL: override y-scale
    • plot=TRUE: should plot be drawn
    • up.col = “green”: up bar/candle color
    • dn.col = “red”: down bar/candle color
    • color.vol = TRUE: color code volume?
    • multi.col = FALSE: 4 color candle pattern
  • reChart: takes any nr of arguments from original chart and redraws with updated param
  • chartTheme: Create a Chart Theme
    • theme = “black”: name of base theme
    • 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
  • chart_Series: Experimental Charting Version 2
    • Experimental functions for new version, Interface, behavior, func
    • name
    • type
    • subset
    • TA
    • pars
    • theme
    • clev = 0: color level
  • chob-class: A Chart Object Class
  • chobTA-class: A Technical Analysis Chart Object

 

 

  • addTA
    • data to bo plotted
  • addADX: Add Directional Movement Index
    • n = 14: periods to use for DX calculation
    • maType = “EMA”: moving average type
    • wilder = TRUE: should Wells Wilder EMA be used?
  • addBBands: Add Bollinger Bands to Chart
    • n = 20: nr of moving average periods
    • sd = 2: nr of sd
    • maType = “SMA”: type of moving average
    • draw = ‘bands’: bands, precent ot width
    • on = -1: which figure are of chart to apply to
  • addCCI: Add Commodity Channel Index
    • n = 20: periods to use DX calc
    • maType
    • c = 0.015: constant to apply to the mean deviation
  • addExpiry: Add Contract Expiration Bars to Chart
    • type = “options”: options or futures expiration
    • lty = “dotted”: type of lines to draw
  • addMA: Add Moving Average to Chart
    • addSMA
    • addEMA
    • addWMA
    • addDEMA
    • addVWMA
    • addZLEMA
    • n = 10: periods to average over
    • wilder: logical; use wilder?
    • wts = 1: vector of weights
    • ratio: smoothing/decay ratio
    • on = 1: apply to which figure
    • with.col = Cl: using which column Cl, Op, Lo…
    • overlay = TRUE: dray as overlay
    • col = “brown” color of MA
  • addMACD: Add Moving Average Covergence Divergence to Chart
    • fast = 12: fast period
    • slow = 25: slow period
    • signal = 9: signal period
    • type = “EMA”: type of MA
    • historgram = TRUE: include histogram
    • col: colors to use for lines
  • addROC: Add Rate of Change to Chart
    • n = 1
    • type = c(“discrete”, “continuous”): compounding type
    • col = “red”
  • addRSI: Add Relative Strength Index to Chart
    • n = 15
    • maType: type of MA to use
    • wilder
  • addSAR: Add Parabolic Stop and Reversal to Chart
    • accel = c(0.02, 0.2): accelleration factors
    • col
  • addSMI: Add Stochastic Momentum Indicator to Chart
    • n = 15: periods
    • slow = 25
    • fast = 2
    • signal = 10
    • type = “EMA”: MA type to use, recycled as necessary
  • addVo: Add volume to Chart
    • log.scale = FALSE: use log-scale for volume
  • addWPR: Add William’s Percent R to Chart
    • n