GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ib-ruby/ib-api: Lightweight Ruby interface to Interactive Brokers' TWS API

BranchesTags
Open more actions menu

Latest commit

 

History

245 Commits
245 Commits

Folders and files

NameName
Last commit message
Last commit date
bin
bin
 
 
conditions/ib
conditions/ib
 
 
lib
lib
 
 
models/ib
models/ib
 
 
plugins/ib
plugins/ib
 
 
spec
spec
 
 
symbols
symbols
 
 
.gitignore
.gitignore
 
 
.rspec
.rspec
 
 
.travis.yml
.travis.yml
 
 
CLAUDE.md
CLAUDE.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
Guardfile
Guardfile
 
 
LICENSE
LICENSE
 
 
LLM_GUIDE.md
LLM_GUIDE.md
 
 
README.md
README.md
 
 
Rakefile
Rakefile
 
 
VERSION
VERSION
 
 
api.gemspec
api.gemspec
 
 
changelog.md
changelog.md
 
 
t.txt
t.txt
 
 
update.md
update.md
 
 

Repository files navigation

ib-api

Ruby interface to Interactive Brokers' TWS API

Reimplementation of ib-ruby


VERSION 10

You have to switch from "require 'ib-extentions', 'ib-symbols'," etc. to "activate_plugin :name"

Whats new

  • Zeitwerk integration.
  • Plugin's to ease automations

Documentation: https://ib-ruby.github.io/ib-doc/


ib-api offers a modular access to the TWS-API-Interface of Interactive Brokers.


Install in the usual way

$ gem install ib-api

In its plain vanilla usage, it just exchanges messages with the TWS. Any response is stored in the received-array.

It needs just a few lines of code to place an order

require 'ib-api'
# connect with default parameters 
ib =  IB::Connection.new 

# define a contract to deal with
the_stock =  IB::Stock.new symbol: 'TAP'

# order 100 shares for 35 $ 
limit_order = IB::Order.new  limit_price: 35, order_type: 'LMT',  total_quantity: 100, action: :buy
ib.send_message :PlaceOrder,
        :order => limit_order,
        :contract => the_stock,
        :local_id => ib.next_local_id

# wait until the orderstate message returned
ib.wait_for :OrderStatus

# print the Orderstatus
puts ib.recieved[:OrderStatus].to_human

# => ["<OrderState: Submitted #17/1528367295 from 2000 filled 0.0/100.0 at 0.0/0.0 why_held >"]

Plugins

IB-API ships with simple plugins to facilitate automations

require 'ib-api'
# connect with default parameters 
ib =  IB::Connection.new do | c |
  c.activate_plugin "verify"
end

g =  IB::Stock.new symbol: 'GE'
puts g.verify.first.attributes
{:symbol=>"GE", :sec_type=>"STK", :last_trading_day=>"", :strike=>0.0, :right=>"", :exchange=>"SMART", :currency=>"USD", :local_symbol=>"GE", :trading_class=>"GE", :con_id=>498843743, :multiplier=>0, :primary_exchange=>"NYSE", }

Currently implemented plugins

  • connection-tools: ensure that a connection is established and active
  • verify: get contract details from the tws
  • symbols: use predefined symbols
  • managed-accounts: fetch and organize account- and portfoliovalues
  • advanced-account: perform account-based previewing, opening, modifying and closing of Positions
  • process-orders: account-based bookkeeping of orders
  • auto-adjust: properly adjust the orderprice to the next valid min-tick of the contract
  • market-price: fetch the current market-price of a contract
  • eod: retrieve EOD-Data for the given contract
  • greeks: read current option greeks
  • roll: easy rolling of futures and options
  • option-chain: build option-chains for given strikes and expiries
  • spread-prototypes: create limit, stop, market, etc. orders through prototypes
  • probability-of-expiring: calculate the probability of expiring for the option-contract

Minimal TWS-Version

ib-api is tested via the stable IB-Gateway (Version 10.33) and should work with any current tws-installation.

Tests

are invoked by

bundle exec guard
# or
bundle exec rake spec

Integration tests on order-placements are not included. To run the test suite its thus safe to use a real Account. You have to edit spec/spec.yml and replace the :account-Setting with your own AccountID, even if you connect to a single account.

Contributing

Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Code of Conduct

Everyone interacting in the Core project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

Lightweight Ruby interface to Interactive Brokers' TWS API

ib-ruby.github.io/ib-api/

Topics

tws-api

Resources

Readme
GPL-3.0 license

Code of conduct

Code of conduct
Activity
Custom properties

Stars

23 stars

Watchers

3 watching

Forks

13 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.