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