Featured Post

Customer focus is a data imperative

Age of information is really the age of confirmation and it is upon us. Gone are the days of naive customer focus termed as providing the b...

Wednesday, November 10, 2010

Pair trading application

When I downloaded the open source FIX engine I thought going through open source FIX ,Quantlib, and boost will get me up to speed on writing any numerical application. But compiling libraries and going through code was not really making me feel "accomplished". I wanted to brush up my C++ in a financial setting with my teeth clutched into the monster and its fangs ripping my sanity apart. I needed a project! So I posted a comment on GQR group in linked in and got response from a nice quant who wanted a pair trading algorithm developed. Well little I knew about the complexity of the project, till he sent me a 200 plus page book, a research paper and some instructions. I was excited to get a project. I was to make time series statistical calculations for statistical arbitrage. Although I believe that economic environment is/was? ripe for risk arbitrage as the chances of companies going bankrupt and emerging out of "crisis" as brand new organizations offer ample opportunities for remodeling capital structures.

I started with the book, the chapter one is .......by the end of 7 chapter, I was underwater.I started the project and I was hoping for a river of code to just flow through, but instead of monsoons and torrentials it was a trickle here and a drop there. Meanwhile I was also collecting all sort of available "free" C++ books, numerical methods in C++, design patterns, thinking in C++, Stroussup, Eckel, Scott Meyer, Erich Gamma to feel securely fastened as the programming part took off. I even downloaded the open source UML tool by Ameos to help design the class structure. The result of all this was a month and a half spent on reading material, writing snippets and "strategizing". I am not sure if any or all of that browsing, nibbling, sniffing, gnawing at pages helped but one night, I sat down and wrote the class structure and was on my way to at least getting the different time series calculations....
....The end result is a beta version completed few days ago... and from here on I will chronicle how the project will develop further....Next blog I will outline some of the C++ and the calculations for a stochastic time series parameters including C++ routines for covariance, variance, co-integration etc....and what a wonderful tool STL containers are...


The code is not commented, but it might be helpful for building something on top of it or taking snippets from it. If you can't down load, send an email to asharmairaj@yahoo.com. (I cannot post the PDF for Quantitative Methods and Analysis by GANAPATHY VIDYAMURTHY, but shoot me an email and I will send)

Example ticker files with trade data
============================
https://docs.google.com/leaf?id=0B_40SUf1ic7PNmRhZjhkNWQtMmZhZC00MDg4LThiOWEtMWEzNzYzMzUxMzgz&hl=en&authkey=CPPv7aoH
Executable
================
https://docs.google.com/leaf?id=0B_40SUf1ic7PNDQ3YmFiYjQtZjIzNy00NWM4LTlmYTUtZGE0N2MwYzJiODU0&hl=en&authkey=CJ-ktugB

Visual studio 2010 Project and files
==========================
https://docs.google.com/leaf?id=0B_40SUf1ic7PYzY3ZjQwMGItMDBmNi00Y2FhLThiNmItMDAwMWU0ZWE3MTMz&hl=en&authkey=CL_X_JwL

No comments:

Post a Comment