an introduction to r for traders
DESCRIPTION
An Introduction to R for TradersTRANSCRIPT
![Page 1: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/1.jpg)
An Introduction to Rfor Traders
Ram VenkatDawn Analytics
![Page 2: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/2.jpg)
R environment• R is an open source environment for statistical
computing
• An Integrated environment for data manipulation, calculation and graphical output
• R is also a dynamic and object-oriented programming language
• Standard install consists of around 30 core packages that cover most common statistical and other tasks
• CRAN contains over 4000 contributed packages and it is growing
![Page 3: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/3.jpg)
R , RStudio installation • Both R and RStudio are available in
Windows, Mac, unix and Linux
• R installation instruction : http://cran.r-project.org/doc/manuals/R-admin.html
• Rstudio is a free open source IDE for R, we will be using Rstudio for this tutorial
• RStudio can be downloaded from http://rstudio.org/download/
![Page 4: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/4.jpg)
R packages and sample datasets
• Installing an R package:
e.g >install.packages(“quantmod “)• “quantmod” is package for trading and we
will be using this for this tutorial
• Using quantmod to load some basic data• Using in-built data sets of R
![Page 5: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/5.jpg)
R as an object-oriented language
• Everything is an Object in R
• A brief look at an R program
• Calling R programs in batch mode
• R functions and packages
http://www.r-bloggers.com/create-an-r-package-in-under-6-minutes/
• Calling R from other languages
• R Programming Model
• Parallel R
![Page 6: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/6.jpg)
R Objects and classes • Core Objects
– Vector
– List
– Functions
• Other Objects
Matrix
– Array
– Data Frames
– Factors
![Page 7: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/7.jpg)
Data inputs and Data Cleaning
• Through package interfaces
• From CSV
• From Databases• Excel interface• Data Cleaning facilities
![Page 8: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/8.jpg)
R Graphics• graphics, lattice and grid packages• graphics Package charts:
– barplot,dot chart,histogram,density plots,strp charts, quantile plots, scatter plots, image plots, contour plots, interaction plots, sunflower plots
• Lattice splits a chart into different panels or groups , making multiple plots on same page easy
![Page 9: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/9.jpg)
Statistical computing
• Data Analysis : Summary, Correlation, principal Component Analysis, Factor Analysis
• Time Series
• Probablity Distributions
• Statistical tests
• Regression Models
• Classification Models
• Clustering
![Page 10: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/10.jpg)
quantmod package
• “A rapid prototyping environment, where quant traders can quickly and cleanly explore and build trading models. “
• Quantmod example on data handling• Quantmod example on charting
• Quantmod example on modelling
• For more : www.quantmod.com/examples/
![Page 11: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/11.jpg)
Other packages of interest to Traders
• R-sig-finance is your best bet to keep track of the packages: https://stat.ethz.ch/pipermail/r-sig-finance/
• Other packages mentioned frequently : Rmetrics(fportfolio),portfolio, Rglpk_solve_LP (portfolio optimization)
• Broker-specific: Ibrokers (IB)
![Page 12: An Introduction to R for Traders](https://reader031.vdocuments.mx/reader031/viewer/2022020208/55cf99e0550346d0339f9bec/html5/thumbnails/12.jpg)
R Books and Tutorials • Book - “R in a Nutshell” by Joseph Adler (O'Reilly)
• cran-R “An introduction to R” http://cran.r-project.org/doc/manuals/R-intro.html
• Quck-R site : http://www.statmethods.net/ gives a discount on the book “R in Action” from Manning
• R and time-series: http://www.stat.pitt.edu/stoffer/tsa3/