Sha256: d400873978de4dc2d4a918e848a86aae7013f6e7797479f4c9cd9616e39ab1f9
Contents?: true
Size: 1003 Bytes
Versions: 3
Compression:
Stored size: 1003 Bytes
Contents
#!/usr/bin/env ruby # This script reproduces https://github.com/ib-ruby/ib-ruby/issues/12 require 'bundler/setup' require 'ib-api' contract = IB::Stock.new :symbol=> 'AAPL' # First, connect to IB Gateway. ib = IB::Connection.new :client_id => 1112 # id to identify your script # :port => 7497 # TWS connection (instead of default Gateway) # :received => false # Do not keep all received messages in memory ib.subscribe(:Alert) { |msg| puts msg.to_human } ib.subscribe(:MarketDataType) { |msg| puts msg.to_human } ib.subscribe(:TickGeneric, :TickString, :TickPrice, :TickSize) { |msg| puts msg.inspect } ib.send_message :RequestMarketDataType, :market_data_type => :delayed 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.." ib.send_message :CancelMarketData, id: 123 sleep 1 puts "Done."
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ib-api-972.2 | example/tick_data |
ib-api-972.1 | example/tick_data |
ib-api-972.0 | example/tick_data |