Module: IB::Messages
- Defined in:
- lib/ib/messages.rb,
lib/ib/messages/incoming.rb,
lib/ib/messages/outgoing.rb,
lib/ib/messages/incoming/alert.rb,
lib/ib/messages/incoming/ticks.rb,
lib/ib/messages/abstract_message.rb,
lib/ib/messages/incoming/open_order.rb,
lib/ib/messages/outgoing/place_order.rb,
lib/ib/messages/incoming/order_status.rb,
lib/ib/messages/incoming/scanner_data.rb,
lib/ib/messages/outgoing/bar_requests.rb,
lib/ib/messages/incoming/contract_data.rb,
lib/ib/messages/incoming/market_depths.rb,
lib/ib/messages/incoming/next_valid_id.rb,
lib/ib/messages/incoming/real_time_bar.rb,
lib/ib/messages/incoming/execution_data.rb,
lib/ib/messages/incoming/historical_data.rb,
lib/ib/messages/incoming/portfolio_value.rb,
lib/ib/messages/incoming/abstract_message.rb,
lib/ib/messages/outgoing/abstract_message.rb,
lib/ib/messages/incoming/delta_neutral_validation.rb
Defined Under Namespace
Modules: Incoming, Outgoing Classes: AbstractMessage
Constant Summary collapse
- CLIENT_VERSION =
This gem supports incoming/outgoing IB messages compatible with the following IB client/server versions:
59
- SERVER_VERSION =
59? Maximal client version implemented
62
Instance Method Summary collapse
-
#def_message(message_id_version, *data_map, &to_human) ⇒ Object
Macro that defines short message classes using a one-liner.
Instance Method Details
#def_message(message_id_version, *data_map, &to_human) ⇒ Object
Macro that defines short message classes using a one-liner.
First arg is either a [message_id, version] pair or just message_id (version 1)
data_map contains instructions for processing @data Hash. Format:
Incoming messages: [field, type] or [group, field, type]
Outgoing messages: field, [field, default] or [field, method, [args]]
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ib/messages/abstract_message.rb', line 59 def , *data_map, &to_human base = data_map.first.is_a?(Class) ? data_map.shift : self::AbstractMessage , version = # Define new message class = Class.new(base) do @message_id, @version = , version || 1 @data_map = data_map @data_map.each do |(name, _, type_args)| # Avoid redefining existing accessor methods unless instance_methods.include?(name.to_s) || instance_methods.include?(name.to_sym) if type_args.is_a?(Symbol) # This is Incoming with [group, field, type] attr_reader name else define_method(name) { @data[name] } end end end define_method(:to_human, &to_human) if to_human end # Add defined message class to Classes Hash keyed by its message_id self::Classes[] = end |