quantmod is an R package that provides a framework for quantitative financial modeling and trading. It provides a rapid prototyping environment that makes modeling easier by removing the repetitive workflow issues surrounding data management and visualization.
The current release is available on CRAN, which you can install via:
install.packages("quantmod")To install the development version, you need to clone the repository and build from source, or run one of:
# lightweight remotes::install_github("joshuaulrich/quantmod") # or devtools::install_github("joshuaulrich/quantmod")
You may need tools to compile C, C++, or Fortran code. See the relevant appendix in the R Installation and Administration manual for your operating system:
- Windows
- MacOS (the R for Mac OS X Developer's Page might also be helpful)
- Unix-alike
It is possible to import data from a variety of sources with one quantmod
function: getSymbols(). For example:
> getSymbols("GOOG", src = "google") # from google finance [1] "YHOO" > getSymbols("YHOO", src = "yahoo") # from yahoo finance [1] "GOOG" > getSymbols("DEXJPUS", src = "FRED") # FX rates from FRED [1] "DEXJPUS"
Once you've imported the data, you can use chartSeries() to visualize it and
even add technical indicators from the TTR
package:
> getSymbols("AAPL") [1] "AAPL" > chartSeries(AAPL) > addMACD() > addBBands()
Ask your question on Stack Overflow or the R-SIG-Finance mailing list (you must subscribe to post).
- DataCamp course on importing and managing financial data
- DataCamp course on manipulating time series with xts & zoo
Please see the contributing guide.
Jeffrey Ryan, Joshua Ulrich