Sunday, August 19, 2012

AlgoTrader, I'm ready

By following the guide http://code.google.com/p/algo-trader/wiki/AlgoTraderQuickStartGuide , I got AlgoTrader binary run successfully. Though in Linux environment, I got to touch up the shell script, which is duplicated from Windows batch script.

I downloaded the source code according to the svn link in http://code.google.com/p/algo-trader/source/checkout . I made use of git-svn, so I can have the history in my local machine. In Eclipse, I installed the E-Git and J-Git plugins.

With the official documentation http://code.google.com/p/algo-trader/wiki/AlgoTraderDocumentation , I got my development environment setup. I also got the AlgoTrader "launchers" run in Eclipse. I spent some time skimmed through all the source code. Beautiful code, impressive!!

When I wanted to collect data (every 5 seconds) through Interactive Broker API, I got "duplicate record" error. Initially I thought Esper statement was propagating datetime with wrong precision. Later after I searched the word "duplicate" in https://groups.google.com/group/algo-trader , I found the thread "Duplicate entry error when persisting tick to DB". Andy Flury's replied "tick.setDateTime(date) in handlePersistTick sets the rounded Time".

Finally, I collected data every 5 seconds by doing the following modifications in com.algoTrader.service.MarketDataServiceImpl class's handlePersistTick(Tick tick) method:

            // get the current Date rounded to MINUTES
            //Date date = DateUtils.round(DateUtil.getCurrentEPTime(), Calendar.MINUTE);
            //tick.setDateTime(date);
            tick.setDateTime(DateUtil.getCurrentEPTime());


What's next? I guessed I got to spend sometime reading Esper Complex Event Processing's documentation at http://esper.codehaus.org/esper/documentation/documentation.html . Esper CEP is the heart of AlgoTrader, the soul of strategies building.

Tuesday, August 7, 2012

Paying for real-time market data

At Interactive Brokers, I got to pay USD 10 per month for real-time market data (US Securities & Commodities Non-Professional Bundle). Therefore, I must make full use of the money I'm paying for.

I decided to build my own historical database using IB's feeds. According to here http://www.interactivebrokers.com/en/p.php?f=marketData
All customers initially receive 100 concurrent lines of real-time market data (which can be displayed in TWS or via the API) and always have a minimum of 100 lines of data.

I think I can make use of at least 80 concurrent lines of real-time market data to build my historical database via the API. Whereas I can leave the remaining 20 concurrent lines of real-time market data for TWS.

Get ready for Algo Trader

I got my Interactive Broker new account approved. Yet pending for funding.

I'm about to start exploring algo-trader. I have read through the official wiki pages from https://code.google.com/p/algo-trader/w/list . These documentations gave me good foundation to play with the code.

Right before I start to run my first algo-trader strategy, I got further hints from a first time user in AlgoTrader google groups. https://groups.google.com/forum/?fromgroups#!topic/algo-trader/DLNCbxSNznw
... A very minor issue, but MarketDataStarter.launch tries to use the database AlgoTraderLight, but the included sql file, algotrader.sql, sets up the database with the name AlgoTrader.

I then ran into a slightly more frustrating issue that caused RMI to hang for a minute or so and then give an error about an ObjID already in use. It turned out the problem was that my hostname wasn't set in /etc/hosts, which screwed up RMI. Maybe it would be worth mentioning in the Wiki that Linux users should try pinging their hostname and make sure that it's set to a local IP address.

I was then able to able to run the Periodic strategy and place trades on IB. However, I noticed that transactions and position updates were not being recorded in the database. I needed to add "ib-trades" to the MODULES field in the BASE record of the strategy table. Perhaps it should be set by default or mentioned in the Wiki....

Wednesday, March 14, 2012

Demo account @ Interactive Broker

I do not have admin right @ my Windows XP company laptop. So, I downloaded Interactive Broker's TWS for Unix. http://www.interactivebrokers.com/en/control/systemstandalone.php?os=unix&ib_entity=llc

I got the TWS started by modifying the startup command to: java -cp jts.jar;hsqldb.jar;jcommon-1.0.12.jar;jfreechart-1.0.9.jar;jhall.jar;other.jar;rss.jar -Xmx512M -XX:MaxPermSize=128M jclient.LoginFrame . 

Login as user [edemo] with password [demouser].


Login successful !!

Friday, March 9, 2012

Startup - Quantitative Options Trading

I am planning to start up a small independent private Quantitative Trading part-time business focusing on Options. How small is it? Probably with just US$ 3,000 initial capital for trading and additional US$ 7,000 to fulfill minimum account opening requirements. Let's see how long can I sustained with this mini amount of money.

As far as trading is concerned, I'm most inspired by:
  1. Jeff Augen's series of small booklet focus on options trading
  2. Ernie P Chan's book on Quantitative Trading: How to Build Your Own Algorithmic Trading Business
  3. Cao Ren Cao's articles & books (HK financial columnist and independent investor)
  4. Jesse Livermore's books
  5. Alexander Elder's book, Trading for a Living
  6. Van K. Tharp's book, Trade Your Way to Financial Freedom
  7. Oliver L. Velez and Greg Capra's book, Tools and Tactics for the Master Day Trader: Battle-Tested Techniques for Day, Swing, and Position Traders
In order to start my business, I need to spend time learning two software tools:
  1. Interactive Broker's trading software, Trader Workstation, nick named TWS
  2. algo-trader, a GPL'ed open source Java Algorithmic Trading System based on Esper, InteractiveBrokers and FIX - http://code.google.com/p/algo-trader/
I cannot learn TWS until I open a brokerage account with Interactive Brokers. I choose IB due to low commission, international trading and API support for Algorithmic Trading. I guessed I will first spend more time dealing with algo-trader. algo-trader is available since August 2011, it is not a mature tool. So, I am prepared to dig into the source code and get something working. I expect I will contribute some code and patch to algo-trader when I'm developing and testing my trading strategies.

Running a private business, will I be lonely? To some extent, yes. Top traders/ investors make lone decision all the time. On the other hand, I may get interaction with active members in algo-trader. Perhaps as his reader, I could also interact with Ernie P Chan at his blog, http://epchan.blogspot.com/ .