Showing posts with label introduction. Show all posts
Showing posts with label introduction. Show all posts

Sunday, January 4, 2009

Trading Robot Features (v 0.0 initial)

I will work out full features at a later time (after proof of concept works), but the initial idea of the trading robot's features are:

  1. Each position is tied to a specific trading strategy
  2. Position entries are done manually. Note a stock/option position can have one or more legs
  3. Position adjustments are done by the robot
  4. Position exits are done by the robot
  5. Adjustment rules can be customized with parameters and can be reused for different trading strategies
  6. Be able to do the following using IB API:
  • get current quote for stock, index, or option
  • get historic quote - high/low for the past x days
  • get current options info: bid, ask, delta, theta, iv, etc
  • place single and combination orders: limit, market, stop loss, contingent
  • set up alerts
  • detect execution of orders
  • cancel orders

Major components which can be run from a single workstation (Windows XP) are:

  1. IB Traders Work Station (TWS) software - This is the interface that does the actual trading.
  2. Database - To store strategy rules and trading records
  3. Trading Robot program - This program is implemented in JRuby just runs with no user interface. It accesses TWS and the database, issuing orders to TWS and updates the database.
  4. Trading Monitor web application - This program is implemented in Ruby on Rails and provides a view of what the trading robot is doing along with reports

Technologies

I use Interactive Brokers to do my trading because of their rock bottom commissions and speed of execution. Another plus with IB is that they make their proprietary application programming interface (API) available for free. These APIs are available in Excel DDE, Java, ActiveX, C++. Since I had done some work in Java a long time ago, I was interested in the Java API. Well, after looking at Java programming again, I'm not too enthusiastic about doing anything in Java. It's just too syntax intensive and complicated for a part time project.

Last year, I was introduced to Ruby as a programming language and was able to develop a couple of applications using one of its web application frameworks called Ruby On Rails. These small applications that I developed made me appreciate the beauty, simplicity, and power of Ruby language. So this is my programming language of choice for this project.

Having settled on a language, the next question is: Would it be possible to develop my trading robot in Ruby while calling IB's Java API? Well, anything in programming is possible, but would it be feasible? That is the better question. I've found JRuby, which is essentially Ruby implemented in Java. This will make it easy for my Ruby program to access IB's Java API. It will allow me to do my development in Ruby while accessing any Java classes and libraries. Theoretically this should work.

Note that the technologies I've mentioned are all open source. This is important, since the idea behind this project is to be able to develop and deploy it with no cost. Another advantage of using Java and Ruby is that it is supported on many platforms. While I'm working exclusively on MS Windows at this time, I would like to have the flexibility to deploy it on Linux in the future. When I incorporate a database system in the future, it will also be open source.

Introduction

Equity trading is one of my main passions in life. I find that it keeps me extremely motivated, thoughtful, honest, and humble. Since I work full time, it's difficult for me to monitor and adjust my trading positions during market hours. If only I had a computer program to do this job for me, life would be much easier. Trading strategies that I use are systematic (meaning all the steps are well defined), therefore it should be possible to let a program monitor and execute these trades for me. While there are programs and systems that currently do this, they tend to be pricey, geared towards institutions, and do not have the flexibility that I need.

By trade, I'm an Oracle developer. I have extensive experience in designing and developing systems. It is natural that I would want to write my own personal trading robot. This blog is a technical diary of my development process. I will not document my personal trading plan, but I will document the development of this trading robot. This trading system will be implemented in various technologies that I'm not an expert in, such as Java, JRuby, and Ruby. After some research, I found that there is little documentation relating to the integration of these technologies and how they all fit together. It is my goal to document this and related topics as I gain more knowledge. If readers find some of it helpful in developing their own system (which may or may not be related to trading), then I would be happy to have made a positive contribution to the world.