Sha256: c590a39b759b1653ce02282b4ef27bfca6e7bf73786864532465372ced41bee9

Contents?: true

Size: 753 Bytes

Versions: 10

Compression:

Stored size: 753 Bytes

Contents

#!/usr/bin/env ruby
#
# This script retrieves list of all Orders from TWS

require 'rubygems'
require 'bundler/setup'
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
require 'ib-ruby'

# Connect to IB as 0 (TWS) to retrieve all Orders, including TWS-generated ones
ib = IB::Connection.new :client_id => 0 #, :port => 7496 # TWS

# Subscribe to TWS alerts/errors and order-related messages
@counter = 0

ib.subscribe(:Alert, :OrderStatus, :OpenOrderEnd) { |msg| puts msg.to_human }

ib.subscribe(:OpenOrder) do |msg|
  @counter += 1
  puts "#{@counter}: #{msg.to_human}"
  #pp msg.order
end

ib.send_message :RequestAllOpenOrders

# Wait for IB to respond to our request
ib.wait_for :OpenOrderEnd
sleep 1 # Let printer do the job

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ib-ruby-0.8.4 bin/list_orders
ib-ruby-0.8.3 bin/list_orders
ib-ruby-0.8.1 bin/list_orders
ib-ruby-0.8.0 bin/list_orders
ib-ruby-0.7.12 bin/list_orders
ib-ruby-0.7.11 bin/list_orders
ib-ruby-0.7.10 bin/list_orders
ib-ruby-0.7.9 bin/list_orders
ib-ruby-0.7.8 bin/list_orders
ib-ruby-0.7.6 bin/list_orders