Ruby Implementation of the Interactive Brokers TWS API


License
LGPL-2.1
Install
gem install ib-ruby -v 0.9.2

Documentation

ib-ruby

by

Arvicco

url

github.com/arvicco/ib-ruby

This is a fork of github.com/wdevauld/ib-ruby by Wes Devauld, that is in turn forked from github.com/pjlegato/ib-ruby by Paul Legato.

DESCRIPTION:

Ruby Implementation of the Interactive Broker' Trader Work Station (TWS) API v.965.

FEATURES/PROBLEMS:

  • This is a BETA release, and should not be used for live trading. Any features contained within are AS-IS and may not work in all conditions

  • This code is not sanctioned or supported by Interactive Brokers

REQUIREMENTS:

Interactive Broker's TWS or Gateway installed and configured to allow API connections on localhost.

INSTALL:

From Gem

$ sudo gem install ib-ruby

From Source

$ git clone http://github.com/arvicco/ib-ruby
$ cd ib-ruby; rake gem:install

SYNOPSIS:

First, start up Interactive Broker's Trader Work Station or Gateway. Make sure it is configured to allow API connections on localhost.

>> require 'ib-ruby'
>> ib = IB::Connection.new
>> ib.subscribe(:Alert, :AccountValue) { |msg| puts msg.to_human }
>> ib.send_message :RequestAccountData, :subscribe => true

Essentially, all interaction of your code and TWS can be described as exchange of messages. You subscribe to message type(s) you're interested in using IB::Connection#subscribe and request data from TWS using IB::Connection#send_message. The code blocks (or procs) given to #subscribe will be executed when a message of requested type is received, with the received message as its argument.

Use sample scripts in /bin folder as an example of how common tasks can be achieved using ib-ruby.

See /lib/ib-ruby/messages for a full list of TWS incoming/outgoing messages and their attributes. Original TWS docs and code samples can be found in /misc folder.

LICENSE:

Copyright © 2011 Arvicco. See LICENSE for details.