Skip to content

Commit 045bb23

Browse files
author
Hartmut Bischoff
committed
Updating subclass FutureOption (Contract)
Now o=IB::FutureOption.new( symbol: "ZC", exchange: "ECBOT", trading_class: "OZC", expiry: "20210219", right: "C") initializes the subclass correctly
1 parent f17bad7 commit 045bb23

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

lib/ib/messages/incoming/abstract_message.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ def initialize source
3030
@created_at = Time.now
3131
if source.is_a?(Hash) # Source is a @data Hash
3232
@data = source
33-
@buffer =[] # initialize empty buffer, indicates a successfull initializing
33+
@buffer =[] # initialize empty buffer, indicates a successful initializing
3434
else
3535
@buffer = source
3636
### DEBUG DEBUG DEBUG RAW STREAM ###############
3737
# if uncommented, the raw-input from the tws is included in the logging
38-
# puts "BUFFER :> #{buffer.inspect} "
38+
## puts "BUFFER :> #{buffer.inspect} "
3939
### DEBUG DEBUG DEBUG RAW STREAM ###############
4040
@data = Hash.new
4141
self.load
4242
end
4343
end
4444

4545
def valid?
46-
@buffer.empty?
46+
@buffer.empty?
4747
end
4848

4949
## more recent messages omit the transmission of a version
50-
## thus just load the parameter-map
50+
## thus just load the parameter-map
5151
def simple_load
5252
load_map *self.class.data_map
5353
rescue IB::Error => e
@@ -87,22 +87,22 @@ def load_map(*map)
8787

8888
when Symbol # Normal map
8989
group, name, type, block =
90-
if instruction[2].nil? || instruction[2].is_a?(Proc) # lambda's are Proc's
90+
if instruction[2].nil? || instruction[2].is_a?(Proc) # lambda's are Proc's
9191
[nil] + instruction # No group, [ :name, :type, (:block) ]
9292
else
9393
instruction # [ :group, :name, :type, (:block)]
9494
end
9595
begin
9696
data = @buffer.__send__("read_#{type}", &block)
9797
rescue IB::LoadError, NoMethodError => e
98-
error "Reading #{self.class}: #{e.class}: #{e.message} --> Instruction: #{name}" , :reader, false
98+
error "Reading #{self.class}: #{e.class}: #{e.message} --> Instruction: #{name}" , :reader, false
9999
end
100100
# debug puts data.inspect
101101
if group
102102
@data[group] ||= {}
103103
@data[group][name] = data
104104
else
105-
@data[name] = data
105+
@data[name] = data
106106
end
107107
else
108108
error "Unrecognized instruction #{instruction}"

lib/ib/messages/outgoing/abstract_message.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def initialize data={}
2525
#
2626
def send_to socket
2727
### debugging of outgoing Messages
28-
# puts "------sendto ---------(debugging output in outgoing/abstract_message)"
29-
# puts socket.prepare_message( self.preprocess).inspect.split('\x00')[3..-1].inspect
30-
# puts "------sendto ---------"
28+
# puts "------sendto ---------(debugging output in outgoing/abstract_message)"
29+
# puts socket.prepare_message( self.preprocess).inspect.split('\x00')[3..-1].inspect
30+
# puts "------sendto ---------"
3131
socket.send_messages self.preprocess #.each {|data| socket.write_data data}
3232
end
3333

lib/models/ib/contract.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class Contract
395395
Subclasses = Hash.new(Contract)
396396
Subclasses[:bag] = IB::Bag
397397
Subclasses[:option] = IB::Option
398-
Subclasses[:future_option] = IB::FutureOption
398+
Subclasses[:futures_option] = IB::FutureOption
399399
Subclasses[:future] = IB::Future
400400
Subclasses[:stock] = IB::Stock
401401
Subclasses[:forex] = IB::Forex

lib/models/ib/option.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def to_human
7777
end # class Option
7878

7979
class FutureOption < Option
80-
80+
def default_attributes
81+
super.merge :sec_type => :futures_option
82+
end
8183
end
8284
end # module IB

0 commit comments

Comments
 (0)