Sha256: f9bf35a9169c536adcd61d957313e37e0ec05af7fc8f126b7f12b0af9c0f7b36
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
#!/usr/bin/env ruby # This script reproduces https://github.com/ib-ruby/ib-ruby/issues/12 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' contract = IB::Models::Contract.new :symbol=> 'AAPL', :exchange=> "Smart", :currency=> "USD", :sec_type=> IB::SECURITY_TYPES[:stock], :description=> "Some stock" # First, connect to IB TWS. Arbitrary :client_id is used to identify your script ib = IB::Connection.new :client_id => 1112 #, :port => 7496 # TWS ib.subscribe(:Alert) { |msg| puts msg.to_human } ib.subscribe(:TickGeneric, :TickString, :TickPrice, :TickSize) { |msg| puts msg.inspect } ib.send_message :RequestMarketData, :id => 123, :contract => contract puts "\nSubscribed to market data" puts "\n******** Press <Enter> to cancel... *********\n\n" gets puts "Cancelling market data subscription.."
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ib-ruby-0.7.3 | bin/tick_data |
ib-ruby-0.7.2 | bin/tick_data |