Page 1 of 1
A pairs trading project I completed
Posted: November 27th, 2010, 10:51 pm
by FuzzyDuck
I'm not sure which forum to put this in, since software/code seems to be more of a technical computer science area, so I thought I'd try here.I'm a long time lurker and thought I'd see if I can contribute something. About 6 months ago I began work on a small project of my own to facilitate pairs trading via cointegration. I also used it as a challenge to learn Java as well as other bits and pieces. Anyways, I released a stripped down version which can be used as a really basic analysis tool, and hopefully you guys can give me some feedback on it or help correct any mistakes you may find.I've hosted it on a small blog I used to hold my CV/Resume and other little things i've found in my short time doing proprietary trading:
http://fuzzcode.blogspot.com/2010/11/pa ... html.Sadly I only have access to a windows machine with linux running in virtualbox. I've only tested this small application in windows xp/vista/7, so I'm doubtful it will work with any other OS. Edit:// Oh and if you're really interested, in the earlier section of the blog I posted a couple of basic videos of the version of the application I use for trading.
A pairs trading project I completed
Posted: November 28th, 2010, 10:54 am
by Cuchulainn
QuoteI only have access to a windows machine with linux running in virtualbox. I've only tested this small application in windows xp/vista/7, so I'm doubtful it will work with any other OS. Interesting project. What are the future goals of the project?In how far your design is portable to other OSs depends on how the software has been set up. Do you have some kind of architectural model for this application? My guess is you have 1) a tracking/acquistion system and 2) a management/decision support system on top of it. These should be loosely coupled.You seem to have a system that can be generalised/extended to a wider class of problems. Domain Architectures and design models do exist for such problems. I can elaborate if interested.//This is more suitable for the Software thread?
A pairs trading project I completed
Posted: November 28th, 2010, 12:42 pm
by Henderson
Very interesting project! Cuchulainn, what models would you recommend for handling that task? I started a very similar project in the past but put it on the back burner after hitting those issues....
A pairs trading project I completed
Posted: November 28th, 2010, 6:46 pm
by FuzzyDuck
I'm pretty new to software architecture so if you have any advice that'd be great. I wrote this little program in such a way that it's easily extensible, I have models in matlab for several other strategies i've been using in trading, and plan on moving them to Java and this application for automation. Sadly funding this effort is a problem, this is just a side project for now, and searching for a job is my main task.Forgive me for not knowing the correct terminology, but there are 4 main sections.1. There's a series of static classes which I have written to hold several fomulae. 2. There's a series of classes written to take data from whereever it may be and put it through the mathematical models and collect the results.3. There's the GUI designed to present the findings of 2 and request a new series of tests to be done by 2.4. The Interactive Brokers API wrapper and the link to a database to store stock data etc.There's also the automated trading part, but sadly this is pretty messy at the moment. It's pretty poorly designed, but since I wrote the code, I know what's going on. It's pretty much inextensible too.I see it as the 'hard work' is completed for the back office of the software. I have a JDBC database running through the data storing data I receive from IB, and some basic execution strategies in a wrapper which implements the interactive brokers API. All that's left is developing the fun stuff thankfully, which is why this is mostly worked on in my spare time.Regarding the OS issues. I have very little experience with portability, but I am aware of what is required in Java to make an application portable between the major OSs. I will debug this application out on my girlfriend's Mac at somepoint this week and see what needs to be done. Ninja Edit: Editted point number 3.
A pairs trading project I completed
Posted: November 29th, 2010, 4:43 am
by Cuchulainn
QuoteOriginally posted by: HendersonVery interesting project! Cuchulainn, what models would you recommend for handling that task? I started a very similar project in the past but put it on the back burner after hitting those issues....This is no trivial system to design. Some challenges imo are;1. The (many) algos, create them and are they good?2. How to architect and design the system so that it is efficient, portable3. Is the resulting trading strategy OK i.e. does it produce a good CAGR?Regarding point 2 I have an execution plan based on my Domain Architecture models (it's on my web site where I have written a book in 2004 on this topic). The five domain architectures presented are:Manufacturing (MAN) Resource Allocation Tracking (RAT) Management and Information Systems (MIS) Process Control and Real-Time (PCS) Interactive and Access Control Systems (ACS) To make a long story short, all the systems I have developed, cooperated on and project managed the last 30 years are special cases or instances of the above categories (or their combinations). In the current case (for example a pairs trading app just to keep it concrete) I would see it as an example of a RAT category. Knowing this, I can then use the RAT context subsystems to help design/'cookie-cut' the current app. In the first place, we have about 10 subsystems which have to designed using the algos in step 1 above. The RAT system needs to work with a MAN system for historical data and also to some higher MIS reporting system.What problems does this resolve? All subsystems can be independently designed by mapping to black box dlls with standard interfaces. This is a major advance on traditional OO classes which tend to become unmaintainable as their number increases. The classic mantra 'object model the world' is true but we should think in terms of objects just yet. In the 'new' way we hide bunches of classes behind standardised interfaces.So, loose coupling between the different engines is something good.QuoteForgive me for not knowing the correct terminology, but there are 4 main sections.1. There's a series of static classes which I have written to hold several fomulae. 2. There's a series of classes written to take data from whereever it may be and put it through the mathematical models and collect the results.3. There's the GUI designed to present the findings of 2 and request a new series of tests to be done by 2.4. The Interactive Brokers API wrapper and the link to a database to store stock data etc.These entities have their equivalents in a RAT trading system. The subsystems contain these classes but coupling is reduced because of interfaces, again. Like little areas of expertise.Hope this helps, Henderson. Are there other issues not addressed here?
A pairs trading project I completed
Posted: November 29th, 2010, 5:20 am
by Cuchulainn
QuoteThere's also the automated trading part, but sadly this is pretty messy at the moment. It's pretty poorly designed, but since I wrote the code, I know what's going on. It's pretty much inextensible too.FuzzyDuck,This is the major engine in you app? Personally, I would consider re-engineering this code to something more flexible (more and better regression, threshold analysis, portfolio opt) rather than OS portability.If you can describe the main activities in this subsystem then you can use them as input to a new flexible design. Once you understand the model problem the design and implementation become much easier.Have you considered Excel as the front-end (output) to your app? Excel is very popular, to state an obvious fact.
A pairs trading project I completed
Posted: November 29th, 2010, 9:32 am
by Henderson
that covers my question but now I have much more research to do. many thanks!
A pairs trading project I completed
Posted: November 29th, 2010, 9:38 am
by Cuchulainn
QuoteOriginally posted by: Hendersonthat covers my question but now I have much more research to do. many thanks!Your'e welcome. It's a huge project