forked from ib-ruby/ib-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix for https://github.com/ib-ruby/ib-ruby/issues/12
- Loading branch information
Showing
3 changed files
with
109 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/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" | ||
ib = IB::Connection.new | ||
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.." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters