This repository was archived by the owner on Aug 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Home
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-backs
ib = IB::Connection.new( port: PORT_NUMBER ) do | gw |
# Write a handler for this type of message
gw.subscribe(:AccountValue, :PortfolioValue, :AccountUpdateTime) do |msg|
puts msg.to_human
# Program logic goes here...
end
end
# Now we can trigger the feed on or off
ib.send_message :RequestAccountData, :subscribe => true
# Wait, then unsubscribe
sleep 30
ib.send_message :RequestAccountData, :subscribe => false
# Wait for user to finish
STDIN.getsIts Work in progress.
- Setup Ruby and Install the Program
- Console
- Gateway
- Watchlists
- Immutable Objects
- Flex Queries
- Messages
- Account
- Orders
- Contracts
- Case Studies