Tag Archives: packages

Which are the best graphical charting packages for R

Interesting uses for Quantmod R package

 

http://www.quantmod.com/examples/charting/

http://www.r-chart.com/2010/06/stock-analysis-using-r.html

http://www.r-chart.com/2010/06/analyze-gold-demand-and-investments.html

http://timelyportfolio.github.io/rCharts_time_series/history.html

http://www.packtpub.com/article/creating-time-series-charts-r

http://www.activeanalytics.co.uk/blog/plottinglivechartswithyahoofinancedataandggplot2inr

http://www.incrediblecharts.com/indicators/williams_percent_r.php

http://quant.stackexchange.com/questions/9465/library-for-interactive-financial-charts

http://www.r-bloggers.com/using-r-and-motion-charts-to-analyze-financial-data/
R Code demoed FinancialChartQuantmod

Is the smartest way to parallelize this ARIMA function within R? Only for Windows? Use quantstart and backtest R packages?

Is the smartest way to parallelize this ARIMA function within R? Only for Windows? Use quantstart and backtest R packages?

This came from https://stat.ethz.ch/pipermail/r-sig-finance/2011q2/008143.html

I don’t think this is the most intelligent way to parallelize this. Comment on what you think!

 

The easiest probably would be to use the multicore package (linux) on
one machine, but if you’re feeling ambitious, there’s also the
possibility of using doSNOW, but there’s some small idosyncracies that
will leave you (or at least it did for me) pulling your hair out trying
to figure out why certain things aren’t working.

If you’re on Windows only, another single box solution would be the
“doSMP” and “foreach” packages that were released by Revolution into CRAN.

here’s a short example of how I use it on Windows (I have a more
complicated multiple computer script buried somewhere using doSNOW on
linux32):

require(doSMP)
require(foreach)

clust <- startWorkers(4)
registerDoSMP(clust)

symbols = c(“SPX”,”DIA”,”QQQQ”)

# the function that you want to parallelize, gets exported to each
“node” — could insert your backtest code here
parallel.arima <- function(data) {
library(forecast)
library(quantmod)
tmp = get(data)
fit = auto.arima(ts(Cl(tmp)), approximation=TRUE, allowdrift=TRUE,
stepwise=TRUE)
}

res <- foreach(dat=symbols, .export=symbols) %dopar% parallel.arima(dat))

There’s more info on the r-sig-hpc list regarding some of the finer
details of the packages mentioned above. Standard disclaimer, this
probably isn’t the “best” way to do it but it should give you some idea
of where to start.

HTH,
C

On 06/24/2011 07:00 AM, benjamin sigel wrote:
> Hi, > > I would like to run multiple backtests with R on intraday data, using > “quantstrat” and “backtest package” and I was wondering what would be the > most time efficient hardware solution between these two: > > – 1 PC: *1 Quad-Core* (Intel® Core™ i5-2300, 2.8 GHz (up to 3.1 GHz with > Turbo Boost) /6GB installed DDR3 RAM (1066 MHz) + *16GB maximum RAM capacity > * > > OR > > – *2 PC’s Hooked-up:* 2 Dual-core (Intel® Core™ i3-550 Processor, 3.20 GHz, > 4 MB Smart Cache, 4GB DDR3 + *maximum expandable memory 16GB* *each* > > Many Thanks for your help, > > Ben

Warning! Certain R packages may run not on Windows with as RCPP may be dependency. Would like a complete list?

Warning! Certain R packages may run not on Windows with as RCPP may be dependency. Would like a complete list?

As I am new to R using a mixed environment of Windows and Linux like Ubuntu or CentOS, I am finding certain R packages will not install properly on Windows. As I I really like RStudio because of its simplicity to install R packages, I get some strange messages of certain packages that do not load properly due to the so-called current version of R cannot be installed. I am using 2.1.5 but may have found a solution.

What is the solution?

That same R package that gives you install problems on Windows may actually work within an Linux environment. As a result, it could be the R package maybe the result of using RCpp as a dependency. I have even seen certain R packages get built or compiled during the install process. It seems RCpp is used which needs a local version of GCC to build. GCC is a GNU C/C++ compiler for Linux or Unix.  As a result, if you are using Windows, you will most likely not have GCC installed on your Windows desktop.

What to do?
You really have two choices:

  1. Build a Linux virtual machine on a virtualization environment appliance like VMWare or free Oracle Sun Virtual Box. If you go for Virtual Box, everything is free. Nice! There is lots of opening YouTube videos on how to do this so I won’t go there. Also, don’t forget to install your GCC with an ‘appt-get install gcc’ or ‘yum install gcc’ depending your Linux flavor. Again, you can easily find loads of YouTube videos on how to do this.
  2. Your other choice is something I am not a fan of but nevertheless you should know about. If you are not a fan of Linux, you can always load MINGW onto Windows and then separately install GCC. Again, I have verified there are so many YouTube videos showing how to do this.

 

I know this could be a pain for some but this is why I really like RStudio which makes my R experience so much better.

 

I am also looking for anyone who has experienced any R packages that need to be locally compiled with GCC, can you please leave a comment on your experience and which R package? It makes everyone’s life so much easier if can be compiled into one area.

Thanks for that!

P.S. You may want to know about our upcoming presentations in R topics at my R/Matlab Meetup for Financial specialists!

 

Quality R packages that potential financial researchers and quant traders who model or build a strategy and algorithm

Quality R newbie packages that potential financial researchers and quant traders who model or build a strategy and algorithm

As a newbie to R, I thought it would be worthy to note a few quality R packages that seem to have more advanced some functionality that Matlab does not even give you. Here is my experience thus far:

RTAQ

This is a tough one to gauge as I have recently tried to get something working with this but will only work with New York Stock Exchange data. At first I thought you could easily download like in Yahoo Finance but I don’t think you can. It seems strange when there are two versions file of this trade and quote capture system.
xts

This seems to be a pretty popular way to convert market data into a time series data frame used throughout other financial R packages listed here.

quantstrat

Another sophisticated R package where you can combine with blotter is to apply different classic technical indicators to your market objects. You can apply indicators, signals, and rules using technical analysis indicators like MACD, RSI, and Bollinger Bands. You can even apply your own algorithm to these as well which leads into quant related type of modeling.

blotter

Another useful package for first round of testing within R. This can be at the core of many analytical trading systems with capabilities to capture end of day market data, set currency rate, and create portfolio, and accounts, and with sophisticated charting capabilities.
PerformanceAnalytics

This is easily one of the best R packages yet since it has some very decent charting capabilities you can find in popular trading platforms like Metatrader. You can easily add different type of charting lines to plots. It contains a great and easy way to extract different types of statistical and market data.

Other worthy R packages to mention include:

quantmod
lspm
PortfolioAnalytics

FinancialInstrument

TTR
signalextraction

I hope this helps those out new to the world of R

My Youtube video using free R-Studio for newbies and installing free R packages from CRAN or R-Forge

My Youtube video using free R-Studio for newbies and installing free R packages from CRAN or R-Forge

I have just posted a new video on the amazing combination of all these tools.

Why R-Studio?

There is no difference if you use are using Eclipse or Netbeans as an integrated development environment, I love this free tool R-Studio which should be added to your arsenal for any model prototyping or development. It can be used on any major operating system platform including Mac OSX, Linux, or Windows. It also has a server edition you can load up on a remote server for developing through a browser session including an Apple Ipad. Pretty neat compared to something like Matlab Mobile. This is the primary reason why I switched from Matlab to R.

The confusing difference between CRAN and R-Forge

As a newbie, I could not find the difference with these R package repositories. As a discovery on Stackexchange.com, it was simply explained CRAN contains your milestones releases of R packages. This basically means they are more stable and could be major releases as well. As some R packages have many developers to the package, you could get changes every few hours which may make the package unstable if there was a potentially bad change. As a result, the package administrator may release the milestone into CRAN

R-Studio and CRAN

As you will find in this video, I would feel more comfortable to stick with CRAN and so does R-Studio. This video shows you how ridiculously easy it is to install an R package from CRAN. As I will start depending on these R packages for my production environment,   I would have no choice but do this. I am a sure a large bank or hedge fund would feel these same way. You can still manually install R packages from R-Forge as well.

A Thanks Goes To….

Thanks to this R community for developing these pretty amazing tools and packages. Best part is the documentation is definitely adequate to get me started fairly quickly with confidence as well. I am sure they spend a pretty huge amount of selfless time to get these tools to the point where they are.

[youtube_sc url=”http://www.youtube.com/watch?v=TSxS0x4PLPg” playlist=”r, r-studio, cran, r-forge” title=”Using%20free%20R-Studio%20for%20newbies%20and%20installing%20free%20R%20packages%20from%20CRAN%20or%20R-Forge”]

 

 

‘World’s best quant’ Peter Carr reveals his toolchain of R packages for his research

IMPORTANT NOTE: This should make reference to Peter Carl not Carr

‘World’s best quant’ Peter Carr reveals his toolchain of R packages for his research

This looks like to be the toolchain that one of the world’s best quant uses for R;

quantmod
indexes
RTAQ
xts

Example R Packages
TTR
signalextraction

quantstrat
quantmod
lspm
PortfolioAnalytics
blotter
FinancialInstrument
PerformanceAnalytics

Do look at page 2 of this PDF. One R package he mentions a lot is blotter. Also, do note his mention of “USE AT YOUR OWN RISK”. This is quite the confidence builder on R.

PDF is here: http://www.rinfinance.com/agenda/2010/PeterCarl.pdf

Crucial and many helpful R packages and research papers for finance and HFT with quant model, algo, and strategy example

Crucial and many helpful R packages and research papers for finance and HFT with quant  model, algo, and strategy example

Note none of these have NOT been verified or validated yet but don’t mind me, I feel like a kid in a candy factory with these!

With Interactive Brokers and R:

http://blog.fosstrading.com/2010/05/introducing-ibrokers-and-jeff-ryan.html

http://cran.r-project.org/web/packages/IBrokers/vignettes/RealTime.pdf

Implied volatility:

http://www.r-bloggers.com/the-only-thing-smiling-today-is-volatility/

For volatility forecasting using GARCH

http://www.r-bloggers.com/trading-using-garch-volatility-forecast/

Time series analysis and computational finance Cointegration test

www.stat.ucl.ac.be/ISdidactique/Rhelp/library/tseries/html/00Index.html
urca R package with Conintegration
http://cran.r-project.org/web/packages/urca/index.html

http://global-4-lvs-colossus.opera-mini.net/hs36-13/15877/1/-1/cran.r-project.org/urca.pdf

Limit Order Book R package

http://r-forge.r-project.org/R/?group_id=790  <– not in CRAN but does not seem to have a download link
Engle Granger coefficient test

http://cran.r-project.org/web/packages/tsDyn/tsDyn.pdf
CRAN – Package crawl random walk theory

http://cran.r-project.org/web/packages/crawl/index.html

Time series analysis in r (includes autocorrelation p17)

http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/sommer03/ts_r_intro.pdf
Ljung box test in r (includes times series)

Ljung Box part of this: http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/sommer03/ts_r_intro.pdf

http://cran.r-project.org/doc/contrib/Ricci-refcard-ts.pdf

Auto regressive estimation model
http://cran.r-project.org/web/packages/cts/vignettes/kf.pdf

Auto regressive is part of http://quantlabs.net/r-blog/2012/05/excellent-tutorial-on-using-urca-r-package-for-var-cointegration-statistical-tests-non-stationary-processes-benchmarks-and-estimating-models/
R time series pair trading Engle and Granger cointegartion
http://cran.r-project.org/web/packages/PairTrading/PairTrading.pdf
Volatility models
http://cran.r-project.org/web/packages/realized/realized.pdf
Brownian Motion
http://cran.r-project.org/web/packages/sde/sde.pdf
Non parametric regression estimation
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-nonparametric-regression.pdf
Time based arbitrage opportunities
http://www.r-bloggers.com/time-based-arbitrage-opportunities-in-tick-data/

Bid Ask spread with tick data rtaq R package
http://cran.r-project.org/web/packages/RTAQ/RTAQ.pdf
Tick data bid ask spread
http://cran.r-project.org/web/packages/FinTS/FinTS.pdf
High frequency data analysis in r with taq data base
http://faculty.washington.edu/ezivot/research/hfanalysis.pdf
Probability of observing k arrivals

http://cran.r-project.org/web/packages/HMM/HMM.pdf
Note Amihud reference of cran in the following research paper:

http://poseidon01.ssrn.com/delivery.php?ID=595118123002081089030087126071081068052035058029030050009002086102005018011112069076118021122027111056019097028001082100025005051092069006116118100098122075080031073081071095115105007093083028120122&EXT=pdf
Info and market impact

http://www.econ.kuleuven.be/public/n09022/RTAQ_vignette.pdf
Most profitable hedge fund strategy in r

http://www.r-bloggers.com/most-profitable-hedge-fund-style/
Econometric Analysis of Financial Market Data

http://www.math.uncc.edu/~zcai/FE-notes.pdf

PCA in R

http://www.r-bloggers.com/principal-component-analysis-use-extended-to-financial-economics-part-2/
Statistical arbitrage in r

http://www.r-bloggers.com/most-profitable-hedge-fund-style/

Dynamic modeling of mean-reverting spreads for statistical arbitrage

http://imperial.academia.edu/GiovanniMontana/Papers/1104540/Dynamic_modeling_of_mean-reverting_spreads_for_statistical_arbitrage

CAPM n r (note PerformanceAnalytics R package may be just as effective)
http://cran.r-project.org/web/packages/BLCOP/vignettes/BLCOP.pdf
Package RTAQ liquidity arbitrage

http://cran.r-project.org/web/packages/RTAQ/index.html

Crucial and many helpful R packages and research papers for finance and high frequency trading with a quant  model, algo, and strategy example

Note none of these have NOT been verified or validated yet but don’t mind me, I feel like a kid in a candy factory with these!

With Interactive Brokers and R:

http://blog.fosstrading.com/2010/05/introducing-ibrokers-and-jeff-ryan.html

http://cran.r-project.org/web/packages/IBrokers/vignettes/RealTime.pdf

Implied volatility:

http://www.r-bloggers.com/the-only-thing-smiling-today-is-volatility/

Time series analysis and computational finance Cointegration test

www.stat.ucl.ac.be/ISdidactique/Rhelp/library/tseries/html/00Index.html
urca R package with Conintegration
http://cran.r-project.org/web/packages/urca/index.html

http://global-4-lvs-colossus.opera-mini.net/hs36-13/15877/1/-1/cran.r-project.org/urca.pdf

Limit Order Book R package

http://r-forge.r-project.org/R/?group_id=790
Engle Granger coefficient test

http://cran.r-project.org/web/packages/tsDyn/tsDyn.pdf
CRAN – Package crawl random walk theory

http://cran.r-project.org/web/packages/crawl/index.html

Time series analysis in r (includes autocorrelation p17)

http://www.statoek.wiso.uni-goettingen.de/veranstaltungen/zeitreihen/sommer03/ts_r_intro.pdf
Ljung box test in r (includes times series)

http://cran.r-project.org/doc/contrib/Ricci-refcard-ts.pdf
Auto regressive estimation model
http://cran.r-project.org/web/packages/cts/vignettes/kf.pdf
R time series pair trading Engle and Granger cointegartion
http://cran.r-project.org/web/packages/PairTrading/PairTrading.pdf
Volatility models
http://cran.r-project.org/web/packages/realized/realized.pdf
Brownian Motion
http://cran.r-project.org/web/packages/sde/sde.pdf
Non parametric regression estimation
http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-nonparametric-regression.pdf
Time based arbitrage opportunities
http://www.r-bloggers.com/time-based-arbitrage-opportunities-in-tick-data/

Bid Ask spread with tick data rtaq R package
http://cran.r-project.org/web/packages/RTAQ/RTAQ.pdf
Tick data bid ask spread
http://cran.r-project.org/web/packages/FinTS/FinTS.pdf
High frequency data analysis in r with taq data base
http://faculty.washington.edu/ezivot/research/hfanalysis.pdf
Probability of observing k arrivals

http://cran.r-project.org/web/packages/HMM/HMM.pdf
Note Amihud reference of cran in the following research paper:

http://poseidon01.ssrn.com/delivery.php?ID=595118123002081089030087126071081068052035058029030050009002086102005018011112069076118021122027111056019097028001082100025005051092069006116118100098122075080031073081071095115105007093083028120122&EXT=pdf
Info and market impact

http://www.econ.kuleuven.be/public/n09022/RTAQ_vignette.pdf
Most profitable hedge fund strategy in r

http://www.r-bloggers.com/most-profitable-hedge-fund-style/
Econometric Analysis of Financial Market Data

http://www.math.uncc.edu/~zcai/FE-notes.pdf

PCA in R

http://www.r-bloggers.com/principal-component-analysis-use-extended-to-financial-economics-part-2/
Statistical arbitrage in r

http://www.r-bloggers.com/most-profitable-hedge-fund-style/

Dynamic modeling of mean-reverting spreads for statistical arbitrage

http://imperial.academia.edu/GiovanniMontana/Papers/1104540/Dynamic_modeling_of_mean-reverting_spreads_for_statistical_arbitrage

CAPM n r (note PerformanceAnalytics R package may be just as effective)
http://cran.r-project.org/web/packages/BLCOP/vignettes/BLCOP.pdf
Package RTAQ liquidity arbitrage

http://cran.r-project.org/web/packages/RTAQ/index.html

The mother load of R packages for financial trading, quant, and potential high frequency trading (HFT) needs

The mother load of R packages for financial trading, quant, and potential high frequency trading (HFT) needs

So there seems to be this endless supply of what look to be a decent list of R finance packages. Some of these include quant based ones. This is my first day researching so I cannot vouch for any of these yet. I do know some R packages can be duds but I am not sure if these ones will be either but are part of CRAN which says positive things. Here we go:

Extreme value analysis:

http://cran.r-project.org/web/packages/evir/evir.pdf

Refer to p 39 for parameter use in Gvt:

http://www.stat.colostate.edu/graybillconference2009/Workshop%20Files/ShortCourseGraybill.pdf

 

 

Potential fat tail analysis which lead to the ones below:

http://braverock.com/brian/R/PerformanceAnalytics/html/Return.Geltner.html

PerformanceAnalytics package is quite amazing and easy to use for the amount of analysis it has: i.e. VaR

http://r.789695.n4.nabble.com/Value-at-risk-td3516991.html

Overview and demo of PerformanceAnalytics (PA):

http://cran.r-project.org/web/packages/PerformanceAnalytics/vignettes/PerformanceAnalyticsChartsPresentation-Meielisalp-2007.pdf

http://www.rinfinance.com/RinFinance2009/presentations/PA%20Workshop%20Chi%20RFinance%202009-04.pdf

How read profitable data and convert to PA package

http://quant.stackexchange.com/questions/1536/use-trades-as-input-for-performanceanalytics

How to back test strategies with PA:

http://blog.fosstrading.com/2011/03/how-to-backtest-strategy-in-r.html

A technical package:

http://cran.r-project.org/web/packages/TTR/index.html

TradeAnalytics packages which includes quantstrat:

 

 

http://cran.r-project.org/web/packages/TTR/index.html

Intro to quantstrat:

http://blog.fosstrading.com/2011/08/introduction-to-quantstrat.html

General list of R packages for quant trading:

http://blog.fosstrading.com/2011/08/introduction-to-quantstrat.html

The motherload of all financial trading packages in CRAN:

http://cran.wustl.edu/web/views/Finance.html

I feel like a kid a candy factory with all this. Makes me wonder how Matlab is going to keep up. Wow! Thanks to all contributors above for all these. Now I have to start digging and play with everything. I will also keep reporting through this blog for those interested.