lib/ib-ruby/connection.rb in ib-ruby-0.5.19 vs lib/ib-ruby/connection.rb in ib-ruby-0.5.21
- old
+ new
@@ -1,16 +1,8 @@
require 'ib-ruby/socket'
require 'ib-ruby/logger'
-# Add method to_ib to render datetime in IB format (zero padded "yyyymmdd HH:mm:ss")
-class Time
- def to_ib
- "#{self.year}#{sprintf("%02d", self.month)}#{sprintf("%02d", self.day)} " +
- "#{sprintf("%02d", self.hour)}:#{sprintf("%02d", self.min)}:#{sprintf("%02d", self.sec)}"
- end
-end # Time
-
module IB
# Encapsulates API connection to TWS or Gateway
class Connection
# Please note, we are realizing only the most current TWS protocol versions,
@@ -59,10 +51,10 @@
def connect
raise "Already connected!" if connected?
# TWS always sends NextValidID message at connect - save this id
self.subscribe(:NextValidID) do |msg|
- @next_order_id = msg.data[:id]
+ @next_order_id = msg.order_id
log.info "Got next valid order id: #{@next_order_id}."
end
@server[:socket] = IBSocket.open(@options[:host], @options[:port])