Tuesday, September 7, 2010

Project Status: Hold

I've been contacted by several people on the status of this project. Here's my response to the inquiry.

No, I'm not working on the project at this time. While testing the api, I came across too many unexpected/undocumented behavior in the API and weird data coming through IB's system. I think in order to have a fully functional trading system, I would have to spend quite a bit of time coming up with logic to correct and verify data that is coming through the API to make sure I'm not making trading decisions based on false data. And since this is the type of thing that you can't fully anticipate, I think this is a major problem to tackle (never mind the fact that IB is constantly updating their system, and there's no guarantee that the API won't be affected). I wanted to spend more time on defining/revising my trading rules, not on filtering and working around bad data coming through the system.

On auto trading, one other issue to consider is how the system will perform during market gyrations like the flash crash we had a few months ago. I noticed that bid-ask spread were huge, and I wasn't getting filled on any orders. So that's a consideration.

Maybe I'll pick up the project again if IB's API platform gets a little better, but for now, I have other things to concentrate on.

.. regarding the details of the problems/learning experience ..

I don't remember exact details, but there were issues of getting order status and how to properly cancel them if they didn't get filled in reasonable amt of time. There were also issues where if IB exits, and reconnect is made, it was hard to determine which orders were submitted/ pending / closed. Of course this is not an issue if you just submit one order at a time.

Wednesday, August 19, 2009

Ruby - Rails - PostgreSQL Issues

I encountered a couple of issues with the development stack. Luckily, I was able to solve them since they were documented on the web. By way of review, my development environment is as follows:
Operating System: Windows XP
Ruby: 1.8.6
Rails: 2.3.3
PostgreSQL: 8.4.0

A) The first error occured when starting WEBrick server. A pop up message displayed:
ruby.exe Ordinal Not Found
The ordinal 284 could not be located in the dynamic link library SSLEAY32.DLL

Searching the web led me to this post at Stackoverflow. My solution was to:

1) Rename libeay32.dll and ssleay32.dll in both ruby\bin folder and posgresql\lib folder to old_libeay32.dll and old_ssleay32.dll respectively. This way I don't lose these dlls in case my fix doesn't work.

2) Install Visual C++ 2008 Redistributables which can be obtained from Microsoft site. This is needed prior to installing OpenSSL below.

3) Install the latest OpenSSL from Shining Light Productions. I used "Win32 OpenSSL v0.9.8k Light".

4) Copy libeay32.dll and ssleay32.dll from OpenSSL folder to h ruby\bin and posgresql\lib folder.

5) Restart WEBrick server and the error should be gone.

B) The second error occured in the browser when Rails tried to connect to PostgreSQL. I tried to migrate a model using rake db:migrate. An error displayed:
Rake aborted!
undefined method 'quote_indent' for PGconn:class

Searching the web led me to this post at HighDot Forums. My solution was to:

1) Open Rails file config/initializers/new_rails_defaults.rb

2) Add the following code at the end of the file:

# Postgres "quote_indent for PGconn:class" fix from http://www.highdots.com/forums/ruby-rails-talk/quote_ident-283323.html
def PGconn.quote_ident(name)

After that, I did not experience any other issues with the development environment.

Sunday, August 16, 2009

Ruby & Ruby On Rails Installation Complete

While there are numerous write ups on this process (just Google "install ruby on rails"), I thought I'd include a brief description for blog completeness

1) Go to Ruby on Rails download page to Download and install Ruby. Enable RubyGems option. I used Windows 1.8.6-27 Release Candidate 2.

2) When finish, open a command prompt and install rails 2.3.3 :
>gem install rails

3) Install PostgrSQL driver:
>gem install postgres-pr

4) Create sample Rails application:
>rails c:\temp\railstest

That's all there is to it. For a quick tutorial, I suggest going to http://guides.rubyonrails.org/ .