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/account_value.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/outgoing/account_requests.rb,
lib/ib/messages/outgoing/request_tick_data.rb,
lib/ib/messages/outgoing/request_marketdata.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:
66
- SERVER_VERSION =
> API V 9.71
"v"+ MIN_CLIENT_VER.to_s + ".." + MAX_CLIENT_VER.to_s
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]]
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ib/messages/abstract_message.rb', line 68 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 @given_arguments =[] @data_map.each do |(name, _, type_args)| dont_process = name == :request_id # [ :request_id, :local_id, :id ].include? name.to_sym @given_arguments << name.to_sym # Avoid redefining existing accessor methods unless instance_methods.include?(name.to_s) || instance_methods.include?(name.to_sym) || dont_process 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 |