lib/ib/extensions/contract.rb in ib-extensions-1.1 vs lib/ib/extensions/contract.rb in ib-extensions-1.2
- old
+ new
@@ -1,35 +1,7 @@
+module IB
- def associate_ticdata
-
- tws= IB::Gateway.tws # get the initialized ib-ruby instance
- the_id = nil
- finalize= false
- # switch to delayed data
- tws.send_message :RequestMarketDataType, :market_data_type => :delayed
-
- s_id = tws.subscribe(:TickSnapshotEnd) { |msg| finalize = true if msg.ticker_id == the_id }
-
- sub_id = tws.subscribe(:TickPrice, :TickSize, :TickGeneric, :TickOption) do |msg|
- self.bars << msg.the_data if msg.ticker_id == the_id
- end
-
- # initialize »the_id« that is used to identify the received tick messages
- # by firing the market data request
- the_id = tws.send_message :RequestMarketData, contract: self , snapshot: true
-
- #keep the method-call running until the request finished
- #and cancel subscriptions to the message handler.
- Thread.new do
- i=0; loop{ i+=1; sleep 0.1; break if finalize || i > 1000 }
- tws.unsubscribe sub_id
- tws.unsubscribe s_id
- puts "#{symbol} data gathered"
- end # method returns the (running) thread
-
- end # def
-###################### private methods
-
+ class Contract
end # class