Thursday, December 6, 2012

Technologies

Before we start the development, let's define the technologies and platforms that will be used.

First things first, we will use Interactive Brokers (IB) as our trading platform of choice, and we will connect to it via its extensive API. If you want to follow along, you may need to open (at least, a demo) account with IB. Most recent IB API v. 967 will be used.

Ruby will be our development language because it allows for concise, expressive and beautiful code that is easy to understand and therefore maintain. More specifically, I suggest to use JVM-based JRuby 1.7.1 implementation. If you prefer other Ruby implementations, it's OK as well, but I would really recommend giving JRuby a try. It is known for its stability, performance and, most importantly, superior cross-platform support. So, it can be used on many different operating system, such as Windows, Mac OSX and different flavors of Linux, with equal ease. 

You can read this post for additional motivation behind IB API/JRuby combination. One important difference to System Trader's approach, though: instead of working with original IB Java API via bridge, we will be using a pure-Ruby IB-RUBY library. This will allow us to switch easily between different Ruby implementations, as well as take advantage of a more concise and Ruby-like syntax that the library provides. Syntax may seem like insignificant detail, but in fact it is a big deal. As our project makes progress, you will see how hundreds of lines of verbose Java code can be easily replaced by a single line of Ruby code with a little help of IB-Ruby.

Database is the heart of any serious application, our robot is no different - open source PostgreSQL 9.2.2 is our database of choice. 

When it comes to making a nice user interface, we'll build ours on top of Ruby on Rails. The GUI will be flexible, HTML-based and also remotely accessible if needed. The last is important for me as I'm only part-time at "my trading desk" and would like an opportunity to monitor and manage my trading robot remotely.

For my development environment, I'll use SublimeText2, a powerful and lightning-fast programmer editor I'm in love with. You may prefer something like Textmate or even opt for convenience of full-blown IDE such as RubyMine or Aptana - it's up to you.

I understand that you may be unfamiliar with the technologies and platforms mentioned here. Along the way, I'll try to do my best to introduce them and document how you can install and start using them. 


Introduction

Trading robots are all the rage nowadays. Almost every institutional trader or hedge fund uses them daily. The trading robots are helping institutions to automate their daily routines, manage their portfolios, achieve better executions, implement sophisticated trading strategies, find and exploit market inefficiencies. Proprietary code of these trading robots is a highly guarded secret that the institutions protect at all costs. 

Can an individual/retail investor, with limited resources, computer power and programming skills create his own trading robot? Is it possible to train a robot to perform your daily chores, execute your trading strategies, monitor your portfolio/positions and alert you of exceptions while you're away? What if you're a part-time trader, is it possible for you to more effectively combine your full time job with trading with a help of a trading robot?

As an individual trader, I use a number of strategies to trade stocks, ETFs, futures, currencies and options. I enjoy developing, testing and executing trading strategies, but trading-related activities take a lot of time and sometimes require a lot of repetitive manual steps. Also, I have a day job, so it is difficult for me to monitor my portfolio and execute my trading strategies during market hours. My intention is to create a computer program that will automate my trading-related activities as much as possible, as well as execute my trading strategies while I'm away. Trading strategies that I use are systematic (that is, all the steps are well defined), so it should be possible to let a program monitor and execute these trades for me. 

My plan is to combine the power of Ruby, an expressive and easy-to-use programming language, with the flexibility of Interactive Brokers API (the best trading API available to retail investors) to build a trading robot that would make my life easier and help me to achieve my goals. 

While I was searching the web for inspiration, I came across this blog documenting a project very similar to what I have in mind. Unfortunately, it is currently on hold, and the technologies described are a bit out-of-date, but it's still a good start. As an initial phase of my development, I want to reproduce the steps of System Trader's project using the most up-to-date technologies and instruments. I will further build upon it to create a fully functional trading robot. My development will be documented in this blog, so subscribe to it and stay tuned. I will also appreciate your comments with questions and ideas to help my development.