ib-ruby 0.5.21 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +8 -0
- data/README.md +46 -27
- data/TODO +13 -2
- data/VERSION +1 -1
- data/bin/generic_data.rb +26 -0
- data/bin/place_order +1 -1
- data/lib/ib-ruby/connection.rb +126 -65
- data/lib/ib-ruby/messages/incoming.rb +3 -3
- data/lib/ib-ruby/models/bar.rb +11 -11
- data/lib/ib-ruby/models/combo_leg.rb +23 -29
- data/lib/ib-ruby/models/contract/bag.rb +34 -2
- data/lib/ib-ruby/models/contract/option.rb +2 -2
- data/lib/ib-ruby/models/contract.rb +151 -197
- data/lib/ib-ruby/models/execution.rb +27 -45
- data/lib/ib-ruby/models/model.rb +10 -4
- data/lib/ib-ruby/models/model_properties.rb +63 -0
- data/lib/ib-ruby/models/order.rb +274 -320
- data/lib/ib-ruby/symbols/stocks.rb +11 -5
- data/spec/account_helper.rb +80 -0
- data/spec/ib-ruby/connection_spec.rb +195 -52
- data/spec/ib-ruby/messages/incoming_spec.rb +4 -4
- data/spec/ib-ruby/models/combo_leg_spec.rb +1 -0
- data/spec/ib-ruby/models/contract_spec.rb +1 -1
- data/spec/ib-ruby/models/execution_spec.rb +73 -0
- data/spec/integration/account_info_spec.rb +12 -59
- data/spec/integration/contract_info_spec.rb +23 -37
- data/spec/integration/depth_data_spec.rb +4 -4
- data/spec/integration/historic_data_spec.rb +15 -27
- data/spec/integration/market_data_spec.rb +74 -61
- data/spec/integration/option_data_spec.rb +5 -48
- data/spec/integration/orders/execution_spec.rb +26 -31
- data/spec/integration/orders/open_order +2 -0
- data/spec/integration/orders/placement_spec.rb +28 -28
- data/spec/integration/orders/valid_ids_spec.rb +11 -11
- data/spec/integration_helper.rb +46 -32
- data/spec/message_helper.rb +4 -38
- data/spec/spec_helper.rb +2 -3
- metadata +9 -2
data/lib/ib-ruby/models/order.rb
CHANGED
@@ -46,326 +46,280 @@ module IB
|
|
46
46
|
Max_Value = 99999999
|
47
47
|
|
48
48
|
# Main order fields
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
# ALGO ORDERS ONLY
|
255
|
-
:algo_strategy, # String
|
256
|
-
:algo_params, # public Vector<TagValue> m_algoParams; ?!
|
257
|
-
|
258
|
-
# WTF?!
|
259
|
-
:what_if, # bool: Use to request pre-trade commissions and margin
|
260
|
-
# information. If set to true, margin and commissions data is received
|
261
|
-
# back via the OrderState() object for the openOrder() callback.
|
262
|
-
:not_held # public boolean m_notHeld; // Not Held
|
49
|
+
prop :order_id, # int: Order id associated with client (volatile).
|
50
|
+
:client_id, # int: The id of the client that placed this order.
|
51
|
+
:perm_id, # int: TWS permanent id, remains the same over TWS sessions.
|
52
|
+
:action, # String: Identifies the side: BUY/SELL/SSHORT
|
53
|
+
:total_quantity, # int: The order quantity.
|
54
|
+
|
55
|
+
:order_type, # String: Identifies the order type. Valid values are:
|
56
|
+
# Limit Risk:
|
57
|
+
# MTL Market-to-Limit
|
58
|
+
# MKT PRT Market with Protection
|
59
|
+
# QUOTE Request for Quote
|
60
|
+
# STP Stop
|
61
|
+
# STP LMT Stop Limit
|
62
|
+
# TRAIL Trailing Stop
|
63
|
+
# TRAIL LIMIT Trailing Stop Limit
|
64
|
+
# TRAIL LIT Trailing Limit if Touched
|
65
|
+
# TRAIL MIT Trailing Market If Touched
|
66
|
+
# Speed of Execution:
|
67
|
+
# MKT Market
|
68
|
+
# MIT Market-if-Touched
|
69
|
+
# MOC Market-on-Close MKTCLSL ?
|
70
|
+
# MOO Market-on-Open
|
71
|
+
# PEG MKT Pegged-to-Market
|
72
|
+
# REL Relative
|
73
|
+
# Price Improvement:
|
74
|
+
# BOX TOP Box Top
|
75
|
+
# LOC Limit-on-Close LMTCLS ?
|
76
|
+
# LOO Limit-on-Open
|
77
|
+
# LIT Limit if Touched
|
78
|
+
# PEG MID Pegged-to-Midpoint
|
79
|
+
# VWAP VWAP-Guaranteed
|
80
|
+
# Advanced Trading:
|
81
|
+
# OCA One-Cancels-All
|
82
|
+
# VOL Volatility
|
83
|
+
# SCALE Scale
|
84
|
+
# Other (no abbreviation):
|
85
|
+
# Bracket
|
86
|
+
# At Auction
|
87
|
+
# Discretionary
|
88
|
+
# Sweep-to-Fill
|
89
|
+
# Price Improvement Auction
|
90
|
+
# Block
|
91
|
+
# Hidden
|
92
|
+
# Iceberg/Reserve
|
93
|
+
# All-or-None
|
94
|
+
# Fill-or-Kill
|
95
|
+
|
96
|
+
:limit_price, # double: LIMIT price, used for limit, stop-limit and relative
|
97
|
+
# orders. In all other cases specify zero. For relative
|
98
|
+
# orders with no limit price, also specify zero.
|
99
|
+
|
100
|
+
:aux_price, # double: STOP price for stop-limit orders, and the OFFSET amount
|
101
|
+
# for relative orders. In all other cases, specify zero.
|
102
|
+
|
103
|
+
:tif, # String: Time to Market:
|
104
|
+
# DAY
|
105
|
+
# GAT Good-after-Time/Date
|
106
|
+
# GTD Good-till-Date/Time
|
107
|
+
# GTC Good-till-Canceled
|
108
|
+
# IOC Immediate-or-Cancel
|
109
|
+
:oca_group, # String: one cancels all group name
|
110
|
+
:oca_type, # int: Tells how to handle remaining orders in an OCA group
|
111
|
+
# when one order or part of an order executes. Valid values:
|
112
|
+
# - 1 = Cancel all remaining orders with block
|
113
|
+
# - 2 = Remaining orders are reduced in size with block
|
114
|
+
# - 3 = Remaining orders are reduced in size with no block
|
115
|
+
# If you use a value "with block" your order has
|
116
|
+
# overfill protection. This means that only one order in
|
117
|
+
# the group will be routed at a time to remove the
|
118
|
+
# possibility of an overfill.
|
119
|
+
:transmit, # bool:if false, order will be created but not transmitted.
|
120
|
+
:parent_id, # int: The order ID of the parent (original) order, used
|
121
|
+
# for bracket (STP) and auto trailing stop (TRAIL) orders.
|
122
|
+
:block_order, # bool: the order is an ISE Block order.
|
123
|
+
:sweep_to_fill, # bool: the order is a Sweep-to-Fill order.
|
124
|
+
:display_size, # int: publicly disclosed order size for Iceberg orders.
|
125
|
+
|
126
|
+
:trigger_method, # Specifies how Simulated Stop, Stop-Limit and Trailing
|
127
|
+
# Stop orders are triggered. Valid values are:
|
128
|
+
# 0 - Default, "double bid/ask" method will be used for OTC stocks
|
129
|
+
# and US options orders, "last" method will be used all others.
|
130
|
+
# 1 - "double bid/ask" method, stop orders are triggered based on
|
131
|
+
# two consecutive bid or ask prices.
|
132
|
+
# 2 - "last" method, stops are triggered based on the last price.
|
133
|
+
# 3 - double last method.
|
134
|
+
# 4 - bid/ask method. For a buy order, a single occurrence of the
|
135
|
+
# bid price must be at or above the trigger price. For a sell
|
136
|
+
# order, a single occurrence of the ask price must be at or
|
137
|
+
# below the trigger price.
|
138
|
+
# 7 - last or bid/ask method. For a buy order, a single bid price
|
139
|
+
# or the last price must be at or above the trigger price.
|
140
|
+
# For a sell order, a single ask price or the last price
|
141
|
+
# must be at or below the trigger price.
|
142
|
+
# 8 - mid-point method, where the midpoint must be at or above
|
143
|
+
# (for a buy) or at or below (for a sell) the trigger price,
|
144
|
+
# and the spread between the bid and ask must be less than
|
145
|
+
# 0.1% of the midpoint
|
146
|
+
|
147
|
+
:outside_rth, # bool: allows orders to also trigger or fill outside
|
148
|
+
# of regular trading hours. (WAS: ignore_rth)
|
149
|
+
:hidden, # bool: the order will not be visible when viewing
|
150
|
+
# the market depth. Only for ISLAND exchange.
|
151
|
+
:good_after_time, # FORMAT: 20060505 08:00:00 {time zone}
|
152
|
+
# Use an empty String if not applicable.
|
153
|
+
:good_till_date, # FORMAT: 20060505 08:00:00 {time zone}
|
154
|
+
# Use an empty String if not applicable.
|
155
|
+
:override_percentage_constraints, # bool: Precautionary constraints defined on
|
156
|
+
# the TWS Presets page ensure that your price and size order values are reasonable.
|
157
|
+
# Orders sent from the API are also validated against these safety constraints,
|
158
|
+
# unless this parameter is set to True.
|
159
|
+
|
160
|
+
:rule_80a, # Individual = 'I', Agency = 'A', AgentOtherMember = 'W',
|
161
|
+
# IndividualPTIA = 'J', AgencyPTIA = 'U', AgentOtherMemberPTIA = 'M',
|
162
|
+
# IndividualPT = 'K', AgencyPT = 'Y', AgentOtherMemberPT = 'N'
|
163
|
+
:all_or_none, # bool: yes=1, no=0
|
164
|
+
:min_quantity, # int: Identifies a minimum quantity order type.
|
165
|
+
:percent_offset, # double: percent offset amount for relative (REL)orders only
|
166
|
+
:trail_stop_price, # double: for TRAILLIMIT orders only
|
167
|
+
|
168
|
+
# Financial advisors only - use an empty String if not applicable.
|
169
|
+
:fa_group, :fa_profile, :fa_method, :fa_percentage,
|
170
|
+
|
171
|
+
# Institutional orders only!
|
172
|
+
:open_close, # String: O=Open, C=Close
|
173
|
+
:origin, # 0=Customer, 1=Firm
|
174
|
+
:order_ref, # String: The order reference. For institutional customers only.
|
175
|
+
:short_sale_slot, # 1 - you hold the shares,
|
176
|
+
# 2 - they will be delivered from elsewhere.
|
177
|
+
# Only for Action="SSHORT
|
178
|
+
:designated_location, # String: set when slot==2 only
|
179
|
+
:exempt_code, # int
|
180
|
+
|
181
|
+
# Clearing info
|
182
|
+
:account, # String: The account. For institutional customers only.
|
183
|
+
:settling_firm, # String: Institutional only
|
184
|
+
:clearing_account, # String: For IBExecution customers: Specifies the
|
185
|
+
# true beneficiary of the order. This value is required
|
186
|
+
# for FUT/FOP orders for reporting to the exchange.
|
187
|
+
:clearing_intent, # IBExecution customers: "", IB, Away, PTA (post trade allocation).
|
188
|
+
|
189
|
+
# SMART routing only
|
190
|
+
:discretionary_amount, # double: The amount off the limit price
|
191
|
+
# allowed for discretionary orders.
|
192
|
+
:etrade_only, # bool: Trade with electronic quotes.
|
193
|
+
:firm_quote_only, # bool: Trade with firm quotes.
|
194
|
+
:nbbo_price_cap, # double: Maximum Smart order distance from the NBBO.
|
195
|
+
|
196
|
+
# BOX or VOL ORDERS ONLY
|
197
|
+
:auction_strategy, # For BOX exchange only. Valid values:
|
198
|
+
# 1=AUCTION_MATCH, 2=AUCTION_IMPROVEMENT, 3=AUCTION_TRANSPARENT
|
199
|
+
:starting_price, # double: Starting price. Valid on BOX orders only.
|
200
|
+
:stock_ref_price, # double: The stock reference price, used for VOL
|
201
|
+
# orders to compute the limit price sent to an exchange (whether or not
|
202
|
+
# Continuous Update is selected), and for price range monitoring.
|
203
|
+
:delta, # double: Stock delta. Valid on BOX orders only.
|
204
|
+
|
205
|
+
# Pegged to stock or VOL orders. For price improvement option orders
|
206
|
+
# on BOX and VOL orders with dynamic management:
|
207
|
+
:stock_range_lower, # double: The lower value for the acceptable
|
208
|
+
# underlying stock price range.
|
209
|
+
:stock_range_upper, # double The upper value for the acceptable
|
210
|
+
# underlying stock price range.
|
211
|
+
|
212
|
+
# VOLATILITY ORDERS ONLY:
|
213
|
+
:volatility, # double: What the price is, computed via TWSs Options
|
214
|
+
# Analytics. For VOL orders, the limit price sent to an
|
215
|
+
# exchange is not editable, as it is the output of a
|
216
|
+
# function. Volatility is expressed as a percentage.
|
217
|
+
:volatility_type, # int: How the volatility is calculated: 1=daily, 2=annual
|
218
|
+
:reference_price_type, # int: For dynamic management of volatility orders:
|
219
|
+
# - 1 = Average of National Best Bid or Ask,
|
220
|
+
# - 2 = National Best Bid when buying a call or selling a put;
|
221
|
+
# and National Best Ask when selling a call or buying a put.
|
222
|
+
:delta_neutral_order_type, # String: Enter an order type to instruct TWS
|
223
|
+
# to submit a delta neutral trade on full or partial execution of the
|
224
|
+
# VOL order. For no hedge delta order to be sent, specify NONE.
|
225
|
+
:delta_neutral_aux_price, # double: Use this field to enter a value if
|
226
|
+
# the value in the deltaNeutralOrderType field is an order
|
227
|
+
# type that requires an Aux price, such as a REL order.
|
228
|
+
:continuous_update, # int: Used for dynamic management of volatility orders.
|
229
|
+
# Determines whether TWS is supposed to update the order price as the underlying
|
230
|
+
# moves. If selected, the limit price sent to an exchange is modified by TWS
|
231
|
+
# if the computed price of the option changes enough to warrant doing so. This
|
232
|
+
# is helpful in keeping the limit price up to date as the underlying price changes.
|
233
|
+
|
234
|
+
# COMBO ORDERS ONLY:
|
235
|
+
:basis_points, # double: EFP orders only
|
236
|
+
:basis_points_type, # double: EFP orders only
|
237
|
+
|
238
|
+
# SCALE ORDERS ONLY
|
239
|
+
:scale_init_level_size, # int: Size of the first (initial) order component.
|
240
|
+
:scale_subs_level_size, # int: Order size of the subsequent scale order
|
241
|
+
# components. Used in conjunction with scaleInitLevelSize().
|
242
|
+
:scale_price_increment, # double: Defines the price increment between
|
243
|
+
# scale components. This field is required for Scale orders.
|
244
|
+
|
245
|
+
# ALGO ORDERS ONLY
|
246
|
+
:algo_strategy, # String
|
247
|
+
:algo_params, # public Vector<TagValue> m_algoParams; ?!
|
248
|
+
|
249
|
+
# WTF?!
|
250
|
+
:what_if, # bool: Use to request pre-trade commissions and margin
|
251
|
+
# information. If set to true, margin and commissions data is received
|
252
|
+
# back via the OrderState() object for the openOrder() callback.
|
253
|
+
:not_held # public boolean m_notHeld; // Not Held
|
263
254
|
|
264
255
|
# Some Order properties (received back from IB) are separated into
|
265
256
|
# OrderState object. Here, they are lumped into Order proper: see OrderState.java
|
266
257
|
# TODO: Extract OrderState object, for better record keeping
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
258
|
+
prop :status, # String: Displays the order status.Possible values include:
|
259
|
+
# � PendingSubmit - indicates that you have transmitted the order, but
|
260
|
+
# have not yet received confirmation that it has been accepted by the
|
261
|
+
# order destination. NOTE: This order status is NOT sent back by TWS
|
262
|
+
# and should be explicitly set by YOU when an order is submitted.
|
263
|
+
# � PendingCancel - indicates that you have sent a request to cancel
|
264
|
+
# the order but have not yet received cancel confirmation from the
|
265
|
+
# order destination. At this point, your order cancel is not confirmed.
|
266
|
+
# You may still receive an execution while your cancellation request
|
267
|
+
# is pending. NOTE: This order status is not sent back by TWS and
|
268
|
+
# should be explicitly set by YOU when an order is canceled.
|
269
|
+
# � PreSubmitted - indicates that a simulated order type has been
|
270
|
+
# accepted by the IB system and that this order has yet to be elected.
|
271
|
+
# The order is held in the IB system until the election criteria are
|
272
|
+
# met. At that time the order is transmitted to the order destination
|
273
|
+
# as specified.
|
274
|
+
# � Submitted - indicates that your order has been accepted at the order
|
275
|
+
# destination and is working.
|
276
|
+
# � Cancelled - indicates that the balance of your order has been
|
277
|
+
# confirmed canceled by the IB system. This could occur unexpectedly
|
278
|
+
# when IB or the destination has rejected your order.
|
279
|
+
# � ApiCancelled - canceled via API
|
280
|
+
# � Filled - indicates that the order has been completely filled.
|
281
|
+
# � Inactive - indicates that the order has been accepted by the system
|
282
|
+
# (simulated orders) or an exchange (native orders) but that currently
|
283
|
+
# the order is inactive due to system, exchange or other issues.
|
284
|
+
:commission, # double: Shows the commission amount on the order.
|
285
|
+
:commission_currency, # String: Shows the currency of the commission.
|
286
|
+
|
287
|
+
#The possible range of the actual order commission:
|
288
|
+
:min_commission,
|
289
|
+
:max_commission,
|
290
|
+
|
291
|
+
:warning_text, # String: Displays a warning message if warranted.
|
292
|
+
|
293
|
+
# String: Shows the impact the order would have on your initial margin.
|
294
|
+
:init_margin => proc { |val| self[:init_margin] = filter_max val },
|
295
|
+
|
296
|
+
# String: Shows the impact the order would have on your maintenance margin.
|
297
|
+
:maint_margin => proc { |val| self[:maint_margin] = filter_max val },
|
298
|
+
|
299
|
+
# String: Shows the impact the order would have on your equity with loan value.
|
300
|
+
:equity_with_loan => proc { |val| self[:equity_with_loan] = filter_max val }
|
310
301
|
|
311
302
|
# IB uses weird String with Java Double.MAX_VALUE to indicate no value here
|
312
|
-
def
|
313
|
-
|
303
|
+
def filter_max val
|
304
|
+
val == "1.7976931348623157E308" ? nil : val.to_f
|
314
305
|
end
|
315
306
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
307
|
+
DEFAULT_PROPS = {:aux_price => 0.0,
|
308
|
+
:parent_id => 0,
|
309
|
+
:tif => 'DAY',
|
310
|
+
:outside_rth => false,
|
311
|
+
:open_close => "O",
|
312
|
+
:origin => Origin_Customer,
|
313
|
+
:transmit => true,
|
314
|
+
:designated_location => '',
|
315
|
+
:exempt_code => -1,
|
316
|
+
:delta_neutral_order_type => '',
|
317
|
+
:what_if => false,
|
318
|
+
:not_held => false,
|
319
|
+
:algo_strategy => '', }
|
325
320
|
|
326
321
|
def initialize opts = {}
|
327
|
-
# Assign defaults first!
|
328
|
-
@aux_price = 0.0
|
329
|
-
@parent_id=0
|
330
|
-
@tif='DAY'
|
331
|
-
|
332
|
-
@outside_rth = false
|
333
|
-
@open_close = "O"
|
334
|
-
@origin = Origin_Customer
|
335
|
-
@transmit = true
|
336
|
-
@designated_location = ''
|
337
|
-
@exempt_code = -1
|
338
|
-
@delta_neutral_order_type = ''
|
339
|
-
@what_if = false
|
340
|
-
@not_held = false
|
341
|
-
@algo_strategy = ''
|
342
322
|
@algo_params = []
|
343
|
-
|
344
|
-
# TODO: Initialize with nil instead of Max_Value, or change
|
345
|
-
# Order sending code in IB::Messages::Outgoing::PlaceOrder
|
346
|
-
#@min_quantity = Max_Value
|
347
|
-
#@percent_offset = Max_Value # -"-
|
348
|
-
#@nbbo_price_cap = Max_Value # -"-
|
349
|
-
#@starting_price = Max_Value # -"-
|
350
|
-
#@stock_ref_price = Max_Value # -"-
|
351
|
-
#@delta = Max_Value
|
352
|
-
#@stock_range_lower = Max_Value # -"-
|
353
|
-
#@stock_range_upper = Max_Value # -"-
|
354
|
-
#@volatility = Max_Value # -"-
|
355
|
-
#@volatility_type = Max_Value # -"-
|
356
|
-
#@delta_neutral_aux_price = Max_Value # -"-
|
357
|
-
#@reference_price_type = Max_Value # -"-
|
358
|
-
#@trail_stop_price = Max_Value # -"-
|
359
|
-
#@basis_points = Max_Value # -"-
|
360
|
-
#@basis_points_type = Max_Value # -"-
|
361
|
-
#@scale_init_level_size = Max_Value # -"-
|
362
|
-
#@scale_subs_level_size = Max_Value # -"-
|
363
|
-
#@scale_price_increment = Max_Value # -"-
|
364
|
-
#@reference_price_type = Max_Value # -"-
|
365
|
-
#@reference_price_type = Max_Value # -"-
|
366
|
-
#@reference_price_type = Max_Value # -"-
|
367
|
-
#@reference_price_type = Max_Value # -"-
|
368
|
-
|
369
323
|
super opts
|
370
324
|
end
|
371
325
|
|
@@ -433,10 +387,20 @@ module IB
|
|
433
387
|
clearing_intent,
|
434
388
|
not_held,
|
435
389
|
contract.serialize_under_comp,
|
436
|
-
serialize_algo,
|
390
|
+
serialize_algo(),
|
437
391
|
what_if]
|
438
392
|
end
|
439
393
|
|
394
|
+
def serialize_algo
|
395
|
+
if algo_strategy.nil? || algo_strategy.empty?
|
396
|
+
['']
|
397
|
+
else
|
398
|
+
[algo_strategy,
|
399
|
+
algo_params.size,
|
400
|
+
algo_params.to_a]
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
440
404
|
# Order comparison
|
441
405
|
def == other
|
442
406
|
perm_id && perm_id == other.perm_id ||
|
@@ -462,16 +426,6 @@ module IB
|
|
462
426
|
# TODO: || compare all attributes!
|
463
427
|
end
|
464
428
|
|
465
|
-
def serialize_algo
|
466
|
-
if algo_strategy.nil? || algo_strategy.empty?
|
467
|
-
['']
|
468
|
-
else
|
469
|
-
[algo_strategy,
|
470
|
-
algo_params.size,
|
471
|
-
algo_params.to_a]
|
472
|
-
end
|
473
|
-
end
|
474
|
-
|
475
429
|
def to_s #human
|
476
430
|
"<Order:" + instance_variables.map do |key|
|
477
431
|
value = instance_variable_get(key)
|