Quote from leveragize:
You are my hero! I have recently started doing this myself. I am creating a layer of abstraction around the data feed and the order processing just in case I want to switch broker. I am trying to keep everything lightweight. The overall architecture is quite
similar to yours.
I may be using an embedded database like HSQLDB, but I have not decided yet.
Is back-testing integrated into your framework, or is it separate?
hi Lev,
Well it is still a work in progress. The Java code is functional for forward testing and live trading at this point, but I still have a lot of work to do to make it a complete system. You correctly point out two parts of my framework that is still not quite completed, unified, or optimized yet.
For the database part, I have chosen mySQL just because I am new to database admin and I thought mySQL was the easiest to learn and get up to speed with. But I have heard that it may not be the optimal choice for trading applications (e.g., I have read some people preferring postgreSQL). But it is a huge improvement over flat files. The performance is quite good as long as the database is indexed and partitioned right.
The other part is the back-testing part. Here, I have chosen not to build it into my Java framework, but rather, I wrote a separate Python class library to do backtesting and plotting (e.g., PL curves, daily entries and exits, etc). Originally I was using the R statistical package to do all my back testing, but there was another thing that I badly needed in my system, and that is the ability to monitor my system while I was away from my machine. So I set up a webserver and I wrote a python matplotlib class library in conjunction with a set of web pages written with Google Web Toolkit to display my running forward tests (and live runs) while away. While I was doing that, I shifted all my back testing to Python as well using Numpy and matplotlib charting so that I am now using my web interface even while I'm working on my machine. This python library has a database class that queries the same mySQL database that my Java framework updates.
The only reason my Java framework deals with the database at all is because I run my Java forward test consistently every single day -- so I built in an automated downloader in the Java code to download that day's historical data after market close automatically. So I don't ever have to deal with downloading again. I also have a windows cron job that runs and cleans up the data and runs my most recent back test algorithm on that day. This allows me to compare the forward test (from IB TWS paper trading), and my back test. I can visualize every trade, the time and the price of execution, and that way I can make sure that my back tests are an accurate reflection of my forward tests (e.g., slippage and commission). By the way I also went live several times purely for software testing purposes, and I have been quite impressed with how well the performance matches up with the paper account.
So my system is not one monolithic package in Java, but has various components in Java, Python, and a webserver to monitor performance of both back tests and forward tests.
How about you? Are you writing everything in Java?