-
Notifications
You must be signed in to change notification settings - Fork 61
Setup Ruby and Install the Program
The Ruby language is not a Mainstream-Computer-Language. It may be installed on your system, but is then most probably present in a not suitable version. Refer to the official documentation.
We recommend to use rvm to install ruby in user-space. Please follow the install notes and install ruby-version 2.5.
$ \curl -sSL https://get.rvm.io | bash -s stable
$ rvm install 2.5.1
Next Bundle has to be installed. Its a gem, which is available through
$ gem install bundler
Its time to clone IB-Ruby and to install it.
$ mkdir ~/workspace && cd ~/workspace
$ git clone https://github.com/ib-ruby/ib-ruby.git
$ cd ib-ruby
$ bundle install
$ bundle update
Assuming a running TWS or Gateway, everything is in place to discover all features in the console
IB-Ruby is a Ruby-Gem and intended to support ruby projects.
Setup an new project:
$ mkdir ~/workspace/trading_project && cd ~/workspace/trading_project
$ git init # Version Control
$ cp ../ib-ruby/.gitignore . # use the same directives than ib-ruby
$ bundle init # create Gemfile
Edit Gemfile and add the following
$ vi Gemfile
gem "ib-ruby", path: "../ib-ruby/"
and finally
$ bundle install
Now, every script using
require 'bundler/setup'
require 'ib-ruby'
## or
require 'ib-gateway'
can address the services of IB-Ruby
This is easiest demonstrated by copying an example-file to the (lib-directory of the) project
$ mkdir lib && cd lib
$ cp ../../ib-ruby/example/account_positions account_positions.rb
$ ruby account_positions.rb
# TWS Warning 2104: Market data farm connection is OK:usfarm
#(...)
#<PositionValue: DU167348 -> <Stock: DBB USD> ( Amount -1.0) : Market-Price 17.6295 >
- Setup Ruby and Install the Program
- Console
- Gateway
- Watchlists
- Immutable Objects
- Flex Queries
- Messages
- Account
- Orders
- Contracts
- Case Studies