Monthly Archives: May 2012

Excellent tutorial on pair trading in R on how to Estimate parameters for back test, Create trading signal,, Back-test performance

Excellent tutorial on pair trading in R on how to Estimate parameters for back test, Create trading signal,, Back-test performance
This is an excellent tutorial that shows R’s pair trading capabilities with the PairTrading package.
It includes benefits how to do:
Estimate parameters for back test
Create trading signal
Back-test performance
http://www.r-bloggers.com/pair-trading-strategy-how-to-use-pairtrading-package/

How to do computation finance with R for newbies

How to do computation finance with R for newbies

This is a really good tutorial for R newbies.

http://www.rmi.nus.edu.sg/csf/webpages/Authors/firstdraft/Nolan_draft_1.pdf

Do note that three R functions are at the end of the document. This includes get.stock.data, get.stock.price, and get.portfolio.returns

Give it a whirl but nothing new here for advanced users

 

Want to connect your R script to Interactive Brokers? Here is how

Want to connect your R script to Interactive Brokers? Here is how

Just refer to these links:

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

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

I cannot vouch for these R packages since I cannot test without an Interactive Brokers account. Ho hum. Can anyone spare an extra $10 thousand?

Performance Analytics has Display relative performance, Calculate Downside Risk, Show relative return risk, Compare distributions

Performance Analytics has Display relative performance, Calculate Downside Risk, Show relative return risk, Compare distributions

If you try out this R package and tutorial:

http://cran.r-project.org/web/packages/PerformanceAnalytics/vignettes/PA-charts.pdf

You will find this a very impressive package. Even Matlab could not do any of this functionality so easily. What is even more impressive is this is all for free. How much would Mathworks charge for this?

This is the entire table of content list of what is can do easily with one table function call:

3.1 Create performance charts . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3.2 Create a monthly returns table . . . . . . . . . . . . . . . . . . . . . . . . 9

3.3 Calculate monthly statistics . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3.4 Compare distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.5 Show relative return and risk . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.6 Examine performance consistency . . . . . . . . . . . . . . . . . . . . . . . 16

3.7 Display relative performance . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.8 Measure relative performance to a benchmark . . . . . . . . . . . . . . . . 16

3.9 Calculate Downside Risk . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

 

How to use Principal component analysis for financial within R

How to use Principal component analysis for financial within R
These two links will help you understand what PCA is within R
http://www.r-bloggers.com/principal-component-analysis-use-extended-to-financial-economics-part-1/
http://www.r-bloggers.com/principal-component-analysis-use-extended-to-financial-economics-part-2/

For part 1 to create data, use http://www.nseindia.com/content/indices/ind_cnx500.htm, click Daily Return values and select period. Download as a CSV to be named Returns_CNX_500.csv. It appears to load fine.  You will also need to create a matrix called return1 before executing the code.

For part 2, you need to download MIBOR.CSV from http://dl.dropbox.com/u/20480592/MIBOR.csv

Other than that, the code in part 2 does work!

Complete financial econemtrics university course with best intro to R including math principles

Complete financial econemtrics university course with best intro to R including math principles

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

An R intro from the same professor with math principles  (one of the best I have seen)

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

If you are new to R and wanting to learn quant,  I would start with the link above

How to measure Liquidity measure Aggregation and volatility, Inferred trade direction from market data in R

How to measure Liquidity measure Aggregation and volatility, Inferred trade direction from market data in R

From http://www.econ.kuleuven.be/public/n09022/RTAQ_vignette.pdf

This appears to work ok but this RTAQ package is impressing me each time

High frequency market data in R with realized volatility, spread, trade direction, bid/ask spread, calendar patterns with tick pattern

High frequency market data in R with realized volatility, spread, trade direction, bid/ask spread, calendar patterns with tick pattern

This is a pretty good tutorial PDF:

http://faculty.washington.edu/ezivot/research/hfanalysis.pdf

Get the data from: http://faculty.washington.edu/ezivot/splus.htm

This is hinted at the bottom of page2.Ensure to load the RTAQ R package from CRAN for use to load the data. Note that the TAQLoad has changed since this PDF so you will need to change the call.

This also contains some great metrics where you can instantly capture things llike realized volatility, spread, trade direction, bid/ask spread, calendar patterns with tick pattern

All I can say is wow!

‘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