Sha256: 559a2dd70999969fd0f4828c2bdececc403000f2e9ff26be14fd4c1f66124f93

Contents?: true

Size: 968 Bytes

Versions: 7

Compression:

Stored size: 968 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 'pathname'
LIB_DIR = (Pathname.new(__FILE__).dirname + '../lib/').realpath.to_s
$LOAD_PATH.unshift LIB_DIR unless $LOAD_PATH.include?(LIB_DIR)

require 'rubygems'
require 'bundler/setup'
require 'ib-ruby'

# First, connect to IB TWS.
ib = IB::Connection.new

# 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

7 entries across 7 versions & 1 rubygems

Version Path
ib-ruby-0.6.1 bin/account_info
ib-ruby-0.5.21 bin/account_info
ib-ruby-0.5.19 bin/account_info
ib-ruby-0.5.18 bin/account_info
ib-ruby-0.5.17 bin/account_info
ib-ruby-0.5.16 bin/account_info
ib-ruby-0.5.15 bin/account_info