12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
|
# File 'lib/ib/messages/outgoing/place_order.rb', line 12
def encode
order = @data[:order]
contract = @data[:contract]
[super,
contract.serialize_long(:con_id, :sec_id),
(order.side == :short ? 'SSHORT' : order.side == :short_exempt ? 'SSHORTX' : order.side.to_sup),
order.quantity,
order[:order_type], order.limit_price,
order.aux_price,
order[:tif],
order.oca_group,
order.account,
order.open_close.to_sup[0..0],
order[:origin],
order.order_ref,
order.transmit,
order.parent_id,
order.block_order || false,
order.sweep_to_fill || false,
order.display_size,
order[:trigger_method],
order.outside_rth || false, order.hidden || false,
contract.serialize_legs(:extended),
if contract.bag?
[
[contract.legs.size] + contract.legs.map { |_| nil },
order.combo_params.empty? ? 0 : [order.combo_params.size] + order.combo_params.to_a
]
else
[]
end,
'', order.discretionary_amount,
order.good_after_time,
order.good_till_date,
order.fa_group,
order.fa_method,
order.fa_percentage,
order.fa_profile,
order[:short_sale_slot], order.designated_location, order.exempt_code,
order[:oca_type],
order[:rule_80a], order.settling_firm,
order.all_or_none || false,
order.min_quantity,
order.percent_offset,
order.etrade_only || false,
order.firm_quote_only || false,
order.nbbo_price_cap,
order[:auction_strategy],
order.starting_price,
order.stock_ref_price,
order.delta,
order.stock_range_lower,
order.stock_range_upper,
order.override_percentage_constraints || false,
order.volatility, order[:volatility_type],
if order.delta_neutral_order_type && order.delta_neutral_order_type != :none
[order[:delta_neutral_order_type],
order.delta_neutral_aux_price,
order.delta_neutral_con_id,
order.delta_neutral_settling_firm,
order.delta_neutral_clearing_account,
order[:delta_neutral_clearing_intent]
]
else
['', '']
end,
order.continuous_update, order[:reference_price_type],
order.trail_stop_price, order.trailing_percent,
order.scale_init_level_size, order.scale_subs_level_size, order.scale_price_increment,
if order.scale_price_increment && order.scale_price_increment > 0
[order.scale_price_adjust_value,
order.scale_price_adjust_interval,
order.scale_profit_offset,
order.scale_auto_reset || false,
order.scale_init_position,
order.scale_init_fill_qty,
order.scale_random_percent || false
]
else
[]
end,
order.hedge_type, order.hedge_param || [],
order.opt_out_smart_routing || false,
order.clearing_account,
order.clearing_intent,
order.not_held || false,
contract.serialize_under_comp,
order.serialize_algo(),
order.what_if]
end
|