Sha256: 3aaf42f64c957e75779b24ca7b4ea3a1deb4d4adc349cbf3a666b9303479dc2e

Contents?: true

Size: 930 Bytes

Versions: 10

Compression:

Stored size: 930 Bytes

Contents

#!/usr/bin/env ruby
#
# This script connects to IB API, subscribes to account info and prints out
# messages received from IB (update every 3 minute or so)

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

# First, connect to IB TWS.
ib = IB::Connection.new :client_id => 1112 #, :port => 7496 # TWS

# Set log level
log.level = Logger::FATAL

# Subscribe to TWS alerts/errors and account-related messages
# that TWS sends in response to account data request
ib.subscribe(:Alert, :AccountValue,
             :PortfolioValue, :AccountUpdateTime) { |msg| puts msg.to_human }

ib.send_message :RequestAccountData, :subscribe => true

puts "\nSubscribing to IB account data"
puts "\n******** Press <Enter> to cancel... *********\n\n"
STDIN.gets
puts "Cancelling account data subscription.."

ib.send_message :RequestAccountData, :subscribe => false

Version data entries

10 entries across 10 versions & 1 rubygems

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