You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Richard Howell-Peak edited this page Sep 14, 2020
·
13 revisions
IB-Ruby aims to provide a ready-to-go solution for everyday aspects of serious trading of stocks and derivates through Interactive Brokers. Additional tools are covered in the wiki as well as best practice examples.
Setup describes how to setup the environment, to install IB-Ruby locally and start a project that has access to the TWS.
Console guides through first experiments with the software.
The basic format of your program will be to register message handlers for different data-feeds on the gateway object. Once that is set up you can subscribe and unsubscribe from those feeds.
PORT_NUMBER=4002# Set up the connection and call-backsib=IB::Connection.new(port: PORT_NUMBER)do | gw |
# Write a handler for this type of messagegw.subscribe(:AccountValue,:PortfolioValue,:AccountUpdateTime)do |msg|
putsmsg.to_human# Program logic goes here...endend# Now we can trigger the feed on or offib.send_message:RequestAccountData,:subscribe=>true# Wait, then unsubscribesleep30ib.send_message:RequestAccountData,:subscribe=>false# Wait for user to finishSTDIN.gets