Class: IB::Messages::Incoming::OpenOrder
- Defined in:
- lib/ib/messages/incoming/open_order.rb
Instance Method Summary collapse
-
#client_id ⇒ Object
Accessors to make OpenOrder API-compatible with OrderStatus message.
- #contract ⇒ Object
-
#filled?(value) ⇒ Boolean
Check if given value was set by TWS to something vaguely “positive”.
- #load ⇒ Object
- #local_id ⇒ Object (also: #order_id)
-
#order ⇒ Object
Object accessors.
- #order_state ⇒ Object
- #parent_id ⇒ Object
- #perm_id ⇒ Object
- #status ⇒ Object
- #to_human ⇒ Object
- #underlying ⇒ Object (also: #under_comp)
Instance Method Details
#client_id ⇒ Object
Accessors to make OpenOrder API-compatible with OrderStatus message
77 78 79 |
# File 'lib/ib/messages/incoming/open_order.rb', line 77 def client_id order.client_id end |
#contract ⇒ Object
114 115 116 117 118 |
# File 'lib/ib/messages/incoming/open_order.rb', line 114 def contract @contract ||= IB::Contract.build( @data[:contract].merge(:underlying => ) ) end |
#filled?(value) ⇒ Boolean
Check if given value was set by TWS to something vaguely “positive”
214 215 216 217 218 219 220 221 222 223 |
# File 'lib/ib/messages/incoming/open_order.rb', line 214 def filled? value case value when String !value.empty? when Float, Integer value > 0 else !!value # to_bool end end |
#load ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/ib/messages/incoming/open_order.rb', line 126 def load super load_map [proc { | | filled?(@data[:order][:delta_neutral_order_type]) }, # As of client v.52, we may receive delta... params in openOrder [:order, :delta_neutral_con_id, :int], [:order, :delta_neutral_settling_firm, :string], [:order, :delta_neutral_clearing_account, :string], [:order, :delta_neutral_clearing_intent, :string]], [:order, :continuous_update, :int], [:order, :reference_price_type, :int], [:order, :trail_stop_price, :decimal_max], [:order, :trailing_percent, :decimal_max], [:order, :basis_points, :decimal_max], [:order, :basis_points_type, :int_max], [:contract, :legs_description, :string], # As of client v.55, we receive in OpenOrder for Combos: # Contract.orderComboLegs Array # Order.leg_prices Array [:contract, :legs, :array, proc do |_| IB::ComboLeg.new :con_id => socket.read_int, :ratio => socket.read_int, :action => socket.read_string, :exchange => socket.read_string, :open_close => socket.read_int, :short_sale_slot => socket.read_int, :designated_location => socket.read_string, :exempt_code => socket.read_int end], [:order, :leg_prices, :array, proc { |_| socket.read_decimal_max }], [:smart_combo_routing_params, :hash], [:order, :scale_init_level_size, :int_max], [:order, :scale_subs_level_size, :int_max], [:order, :scale_price_increment, :decimal_max], [proc { | | filled?(@data[:order][:scale_price_increment]) }, # As of client v.54, we may receive scale order fields [:order, :scale_price_adjust_value, :decimal_max], [:order, :scale_price_adjust_interval, :int_max], [:order, :scale_profit_offset, :decimal_max], [:order, :scale_auto_reset, :boolean], [:order, :scale_init_position, :int_max], [:order, :scale_init_fill_qty, :decimal_max], [:order, :scale_random_percent, :boolean] ], [:order, :hedge_type, :string], [proc { | | filled?(@data[:order][:hedge_type]) }, # As of client v.49/50, we can receive hedgeType, hedgeParam [:order, :hedge_param, :string] ], [:order, :opt_out_smart_routing, :boolean], [:order, :clearing_account, :string], [:order, :clearing_intent, :string], [:order, :not_held, :boolean], [:underlying_present, :boolean], [proc { | | filled?(@data[:underlying_present]) }, [:underlying, :con_id, :int], [:underlying, :delta, :decimal], [:underlying, :price, :decimal] ], # TODO: Test Order with algo_params, scale and legs! [:order, :algo_strategy, :string], [proc { | | filled?(@data[:order][:algo_strategy]) }, [:order, :algo_params, :hash] ], [:order, :what_if, :boolean], [:order_state, :status, :string], # IB uses weird String with Java Double.MAX_VALUE to indicate no value here [:order_state, :init_margin, :decimal_max], # :string], [:order_state, :maint_margin, :decimal_max], # :string], [:order_state, :equity_with_loan, :decimal_max], # :string], [:order_state, :commission, :decimal_max], # May be nil! [:order_state, :min_commission, :decimal_max], # May be nil! [:order_state, :max_commission, :decimal_max], # May be nil! [:order_state, :commission_currency, :string], [:order_state, :warning_text, :string] end |
#local_id ⇒ Object Also known as: order_id
89 90 91 |
# File 'lib/ib/messages/incoming/open_order.rb', line 89 def local_id order.local_id end |
#order ⇒ Object
Object accessors
101 102 103 |
# File 'lib/ib/messages/incoming/open_order.rb', line 101 def order @order ||= IB::Order.new @data[:order].merge(:order_state => order_state) end |
#order_state ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/ib/messages/incoming/open_order.rb', line 105 def order_state @order_state ||= IB::OrderState.new( @data[:order_state].merge( :local_id => @data[:order][:local_id], :perm_id => @data[:order][:perm_id], :parent_id => @data[:order][:parent_id], :client_id => @data[:order][:client_id])) end |
#parent_id ⇒ Object
81 82 83 |
# File 'lib/ib/messages/incoming/open_order.rb', line 81 def parent_id order.parent_id end |
#perm_id ⇒ Object
85 86 87 |
# File 'lib/ib/messages/incoming/open_order.rb', line 85 def perm_id order.perm_id end |
#status ⇒ Object
95 96 97 |
# File 'lib/ib/messages/incoming/open_order.rb', line 95 def status order.status end |
#to_human ⇒ Object
225 226 227 |
# File 'lib/ib/messages/incoming/open_order.rb', line 225 def to_human "<OpenOrder: #{contract.to_human} #{order.to_human}>" end |
#underlying ⇒ Object Also known as: under_comp
120 121 122 |
# File 'lib/ib/messages/incoming/open_order.rb', line 120 def @underlying = @data[:underlying_present] ? IB::Underlying.new(@data[:underlying]) : nil end |