File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 44require 'ib/logger'
55require 'ib/messages'
66
7+ module TechnicalAnalysis
8+ module Signals
9+ end
10+ end
11+
712module IB
813 # Encapsulates API connection to TWS or Gateway
914 class Connection
@@ -100,7 +105,7 @@ def initialize host: '127.0.0.1',
100105 def update_next_order_id
101106 i , finish = 0 , false
102107 sub = self . subscribe ( :NextValidID ) { finish = true }
103- connected? ? self . send_message ( :RequestIds ) : open ( )
108+ connected? ? self . send_message ( :RequestIds ) : open ( )
104109 Timeout ::timeout ( 1 , IB ::TransmissionError , "Could not get NextValidId" ) do
105110 loop { sleep 0.1 ; break if finish }
106111 end
@@ -186,7 +191,13 @@ def subscribe *args, &block
186191 when what . is_a? ( Class ) && what < Messages ::Incoming ::AbstractMessage
187192 [ what ]
188193 when what . is_a? ( Symbol )
189- [ Messages ::Incoming . const_get ( what ) ]
194+ if Messages ::Incoming . const_defined? ( what )
195+ [ Messages ::Incoming . const_get ( what ) ]
196+ elsif TechnicalAnalysis ::Signals . const_defined? ( what )
197+ [ TechnicalAnalysis ::Signals . const_get? ( what ) ]
198+ else
199+ error "#{ what } is no IB::Messages or TechnicalAnalyis::Signals class"
200+ end
190201 when what . is_a? ( Regexp )
191202 Messages ::Incoming ::Classes . values . find_all { |klass | klass . to_s =~ what }
192203 else
You can’t perform that action at this time.
0 commit comments