ib-ruby 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/HISTORY +3 -0
- data/README.md +29 -9
- data/VERSION +1 -1
- data/app/assets/javascripts/ib/bars.js +2 -0
- data/app/assets/javascripts/ib/executions.js +2 -0
- data/app/assets/javascripts/ib/order_states.js +2 -0
- data/app/assets/stylesheets/ib/bars.css +4 -0
- data/app/assets/stylesheets/ib/executions.css +4 -0
- data/app/assets/stylesheets/ib/order_states.css +4 -0
- data/app/controllers/ib/bars_controller.rb +87 -0
- data/app/controllers/ib/combo_legs_controller.rb +87 -0
- data/app/controllers/ib/contract_details_controller.rb +87 -0
- data/app/controllers/ib/contracts_controller.rb +87 -0
- data/app/controllers/ib/executions_controller.rb +87 -0
- data/app/controllers/ib/order_states_controller.rb +87 -0
- data/app/controllers/ib/orders_controller.rb +87 -0
- data/app/helpers/ib/bars_helper.rb +4 -0
- data/app/helpers/ib/combo_legs_helper.rb +4 -0
- data/app/helpers/ib/contract_details_helper.rb +4 -0
- data/app/helpers/ib/contracts_helper.rb +4 -0
- data/app/helpers/ib/executions_helper.rb +4 -0
- data/app/helpers/ib/order_states_helper.rb +4 -0
- data/app/helpers/ib/orders_helper.rb +4 -0
- data/app/views/ib/bars/_form.html.erb +57 -0
- data/app/views/ib/bars/edit.html.erb +6 -0
- data/app/views/ib/bars/index.html.erb +41 -0
- data/app/views/ib/bars/new.html.erb +5 -0
- data/app/views/ib/bars/show.html.erb +55 -0
- data/app/views/ib/combo_legs/_form.html.erb +53 -0
- data/app/views/ib/combo_legs/edit.html.erb +6 -0
- data/app/views/ib/combo_legs/index.html.erb +39 -0
- data/app/views/ib/combo_legs/new.html.erb +5 -0
- data/app/views/ib/combo_legs/show.html.erb +55 -0
- data/app/views/ib/contract_details/_form.html.erb +141 -0
- data/app/views/ib/contract_details/edit.html.erb +6 -0
- data/app/views/ib/contract_details/index.html.erb +83 -0
- data/app/views/ib/contract_details/new.html.erb +5 -0
- data/app/views/ib/contract_details/show.html.erb +160 -0
- data/app/views/ib/contracts/_form.html.erb +77 -0
- data/app/views/ib/contracts/edit.html.erb +6 -0
- data/app/views/ib/contracts/index.html.erb +53 -0
- data/app/views/ib/contracts/new.html.erb +5 -0
- data/app/views/ib/contracts/show.html.erb +85 -0
- data/app/views/ib/executions/_form.html.erb +77 -0
- data/app/views/ib/executions/edit.html.erb +6 -0
- data/app/views/ib/executions/index.html.erb +51 -0
- data/app/views/ib/executions/new.html.erb +5 -0
- data/app/views/ib/executions/show.html.erb +80 -0
- data/app/views/ib/order_states/_form.html.erb +93 -0
- data/app/views/ib/order_states/edit.html.erb +6 -0
- data/app/views/ib/order_states/index.html.erb +59 -0
- data/app/views/ib/order_states/new.html.erb +5 -0
- data/app/views/ib/order_states/show.html.erb +100 -0
- data/app/views/ib/orders/_form.html.erb +353 -0
- data/app/views/ib/orders/edit.html.erb +6 -0
- data/app/views/ib/orders/index.html.erb +193 -0
- data/app/views/ib/orders/new.html.erb +5 -0
- data/app/views/ib/orders/show.html.erb +435 -0
- data/bin/scaffold.rb +29 -0
- data/config/routes.rb +8 -1
- data/db/config.yml +5 -0
- data/db/migrate/101_add_ib_executions.rb +3 -0
- data/db/migrate/111_add_ib_bars.rb +6 -0
- data/db/migrate/121_add_ib_order_states.rb +8 -0
- data/db/migrate/131_add_ib_orders.rb +24 -0
- data/db/migrate/141_add_ib_combo_legs.rb +6 -0
- data/db/migrate/151_add_ib_underlyings.rb +3 -0
- data/db/migrate/161_add_ib_contract_details.rb +11 -0
- data/db/migrate/171_add_ib_contracts.rb +8 -1
- data/db/schema.rb +6 -5
- data/lib/ib/base.rb +3 -1
- data/lib/ib/base_properties.rb +26 -15
- data/lib/ib/connection.rb +3 -2
- data/lib/ib/errors.rb +16 -9
- data/lib/ib/extensions.rb +6 -4
- data/lib/ib/symbols.rb +10 -3
- data/lib/ib/symbols/forex.rb +49 -64
- data/lib/ib/symbols/futures.rb +2 -3
- data/lib/ib/symbols/options.rb +2 -1
- data/lib/ib/symbols/stocks.rb +2 -1
- data/lib/models/ib/bar.rb +6 -2
- data/lib/models/ib/combo_leg.rb +4 -3
- data/lib/models/ib/contract.rb +9 -5
- data/lib/models/ib/contract_detail.rb +1 -1
- data/lib/models/ib/execution.rb +3 -1
- data/lib/models/ib/order.rb +22 -20
- data/lib/models/ib/order_state.rb +4 -2
- data/lib/models/ib/underlying.rb +3 -4
- data/spec/README.md +12 -10
- data/spec/ib/symbols/symbols_spec.rb +10 -0
- data/spec/integration_helper.rb +1 -1
- data/spec/model_helper.rb +9 -8
- data/spec/models/ib/combo_leg_spec.rb +29 -28
- data/spec/models/ib/contract_detail_spec.rb +4 -1
- data/spec/models/ib/contract_spec.rb +66 -58
- data/spec/models/ib/execution_spec.rb +50 -44
- data/spec/models/ib/order_spec.rb +2 -2
- data/spec/order_helper.rb +5 -4
- data/spec/spec_helper.rb +3 -3
- metadata +59 -35
- data/app/models/ib/underlying.rb +0 -5
- data/bin/account_info +0 -29
- data/bin/cancel_orders +0 -27
- data/bin/contract_details +0 -35
- data/bin/depth_of_market +0 -43
- data/bin/fa_accounts +0 -22
- data/bin/fundamental_data +0 -39
- data/bin/historic_data +0 -51
- data/bin/historic_data_cli +0 -182
- data/bin/list_orders +0 -28
- data/bin/market_data +0 -41
- data/bin/option_data +0 -44
- data/bin/place_combo_order +0 -58
- data/bin/place_order +0 -27
- data/bin/template +0 -18
- data/bin/tick_data +0 -26
- data/bin/time_and_sales +0 -53
|
@@ -20,7 +20,7 @@ describe IB::ContractDetail,
|
|
|
20
20
|
:liquid_hours => '20120422:0930-1600;20120423:0930-1600',
|
|
21
21
|
},
|
|
22
22
|
|
|
23
|
-
:human
|
|
23
|
+
:human =>/ContractDetail: callable: false category: Computers contract_month: 201301 convertible: false coupon: 0.0 created_at: .* industry: Technology liquid_hours: 20120422:0930-1600;20120423:0930-1600 long_name: APPLE INC market_name: AAPL min_tick: 0.01 next_option_partial: false order_types: ACTIVETIM,ADJUST,ALERT,ALGO,ALLOC,AON,AVGCOST,BASKET,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,FOK,GAT,GTC,GTD,GTT,HID,ICE,IOC,LIT,LMT,MIT,MKT,MTL,NONALGO,OCA,PAON,POSTONLY,RELSTK,SCALE,SCALERST,SMARTSTG,STP,STPLMT,TRAIL,TRAILLIT,TRAILLMT,TRAILMIT,VOLAT,WHATIF, price_magnifier: 1 puttable: false subcategory: Computers time_zone: EST trading_class: AAPL trading_hours: 20120422:0930-1600;20120423:0930-1600 under_con_id: 265598 updated_at: .* valid_exchanges: SMART,AMEX,BATS,BOX,CBOE,CBOE2,IBSX,ISE,MIBSX,NASDAQOM,PHLX,PSE>/,
|
|
24
24
|
|
|
25
25
|
:errors =>
|
|
26
26
|
{:time_zone => ['should be XXX'],
|
|
@@ -38,4 +38,7 @@ describe IB::ContractDetail,
|
|
|
38
38
|
it_behaves_like 'Model with invalid defaults'
|
|
39
39
|
it_behaves_like 'Self-equal Model'
|
|
40
40
|
|
|
41
|
+
it 'inherited equality method works (important for IB::Base derived tableless models)' do
|
|
42
|
+
IB::ContractDetail.new(props).should == IB::ContractDetail.new(props)
|
|
43
|
+
end
|
|
41
44
|
end # describe IB::ContractDetail
|
|
@@ -2,56 +2,64 @@ require 'model_helper'
|
|
|
2
2
|
require 'combo_helper'
|
|
3
3
|
|
|
4
4
|
describe IB::Contract,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
5
|
+
:props =>
|
|
6
|
+
{:symbol => 'AAPL',
|
|
7
|
+
:sec_type => :option,
|
|
8
|
+
:expiry => '201301',
|
|
9
|
+
:strike => 600.5,
|
|
10
|
+
:right => :put,
|
|
11
|
+
:sec_id => 'US0378331005',
|
|
12
|
+
:sec_id_type => 'ISIN',
|
|
13
|
+
:multiplier => 10,
|
|
14
|
+
:exchange => 'SMART',
|
|
15
|
+
:currency => 'USD',
|
|
16
|
+
:local_symbol => 'AAPL 130119C00500000'},
|
|
17
|
+
|
|
18
|
+
:human => "<Contract: AAPL option 201301 put 600.5 SMART USD>",
|
|
19
|
+
|
|
20
|
+
:errors => {:sec_type => ["should be valid security type"] },
|
|
21
|
+
|
|
22
|
+
:assigns => {:expiry =>
|
|
23
|
+
{[200609, '200609'] => '200609',
|
|
24
|
+
[20060913, '20060913'] => '20060913',
|
|
25
|
+
[:foo, 2006, 42, 'bar'] => /should be YYYYMM or YYYYMMDD/},
|
|
26
|
+
|
|
27
|
+
:sec_type => codes_and_values_for(:sec_type).
|
|
28
|
+
merge([:foo, 'BAR', 42] => /should be valid security type/),
|
|
29
|
+
|
|
30
|
+
:sec_id =>
|
|
31
|
+
{[:US0378331005, 'us0378331005', 'US0378331005'] => 'US0378331005',
|
|
32
|
+
[:'37833100', 37833100, '37833100'] => '37833100',
|
|
33
|
+
[:'AAPL.O', 'AAPL.O'] => 'AAPL.O',
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
:sec_id_type =>
|
|
37
|
+
{[:isin, 'ISIN', 'iSin'] => 'ISIN',
|
|
38
|
+
[:sedol, :SEDOL, 'sEDoL', 'SEDOL'] => 'SEDOL',
|
|
39
|
+
[:cusip, :CUSIP, 'Cusip', 'CUSIP'] => 'CUSIP',
|
|
40
|
+
[:ric, :RIC, 'rIC', 'RIC'] => 'RIC',
|
|
41
|
+
nil => nil,
|
|
42
|
+
'' => '',
|
|
43
|
+
[:foo, 'BAR', 'baz'] => /should be valid security identifier/},
|
|
44
|
+
|
|
45
|
+
:right =>
|
|
46
|
+
{["PUT", "put", "P", "p", :put] => :put,
|
|
47
|
+
["CALL", "call", "C", "c", :call] => :call,
|
|
48
|
+
['', '0', '?', :none] => :none,
|
|
49
|
+
[:foo, 'BAR', 42] => /should be put, call or none/},
|
|
50
|
+
|
|
51
|
+
:exchange => string_upcase_assigns.merge(
|
|
52
|
+
[:smart, 'SMART', 'smArt'] => 'SMART'),
|
|
53
|
+
|
|
54
|
+
:primary_exchange =>string_upcase_assigns.merge(
|
|
55
|
+
[:SMART, 'SMART'] => /should not be SMART/),
|
|
56
|
+
|
|
57
|
+
:multiplier => to_i_assigns,
|
|
58
|
+
|
|
59
|
+
:strike => to_f_assigns,
|
|
60
|
+
|
|
61
|
+
:include_expired => boolean_assigns,
|
|
62
|
+
} do
|
|
55
63
|
|
|
56
64
|
it_behaves_like 'Model with invalid defaults'
|
|
57
65
|
it_behaves_like 'Self-equal Model'
|
|
@@ -119,17 +127,17 @@ describe IB::Contract,
|
|
|
119
127
|
|
|
120
128
|
it "serializes long" do
|
|
121
129
|
subject.serialize_long.should ==
|
|
122
|
-
|
|
130
|
+
["AAPL", "OPT", "201301", 600.5, "P", 10, "SMART", nil, "USD", "AAPL 130119C00500000"]
|
|
123
131
|
end
|
|
124
132
|
|
|
125
133
|
it "serializes short" do
|
|
126
134
|
subject.serialize_short.should ==
|
|
127
|
-
|
|
135
|
+
["AAPL", "OPT", "201301", 600.5, "P", 10, "SMART", "USD", "AAPL 130119C00500000"]
|
|
128
136
|
end
|
|
129
137
|
|
|
130
138
|
it "serializes combo (BAG) contracts for Order placement" do
|
|
131
139
|
@combo.serialize_long(:con_id, :sec_id).should ==
|
|
132
|
-
|
|
140
|
+
[0, "GOOG", "BAG", "", 0.0, "", nil, "SMART", nil, "USD", "", nil, nil]
|
|
133
141
|
end
|
|
134
142
|
|
|
135
143
|
it 'also serializes attached combo legs' do
|
|
@@ -137,13 +145,13 @@ describe IB::Contract,
|
|
|
137
145
|
subject.serialize_legs(:extended).should == []
|
|
138
146
|
|
|
139
147
|
@combo.serialize_legs.should ==
|
|
140
|
-
|
|
148
|
+
[3, 81032967, 1, "BUY", "SMART", 81032968, 2, "SELL", "SMART", 81032973, 1, "BUY", "SMART"]
|
|
141
149
|
|
|
142
150
|
@combo.serialize_legs(:extended).should ==
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
151
|
+
[3, 81032967, 1, "BUY", "SMART", 0, 0, "", -1,
|
|
152
|
+
81032968, 2, "SELL", "SMART", 0, 0, "", -1,
|
|
153
|
+
81032973, 1, "BUY", "SMART", 0, 0, "", -1]
|
|
154
|
+
end
|
|
147
155
|
end #serialization
|
|
148
156
|
|
|
149
157
|
|
|
@@ -1,50 +1,45 @@
|
|
|
1
1
|
require 'model_helper'
|
|
2
2
|
|
|
3
3
|
describe IB::Execution,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
:time => "20120312 15:41:09",
|
|
18
|
-
},
|
|
19
|
-
:human =>
|
|
20
|
-
"<Execution: 20120312 15:41:09 buy 20000 at 1.31075 on IDEALPRO, " +
|
|
21
|
-
"cumulative 20000 at 1.31075, ids 373/1695693619/0001f4e8.4f5d48f1.01.01>",
|
|
22
|
-
:errors =>
|
|
23
|
-
{:side=>["should be buy/sell/short"],
|
|
24
|
-
:cumulative_quantity=>["is not a number"],
|
|
25
|
-
:average_price=>["is not a number"]},
|
|
26
|
-
|
|
27
|
-
:assigns =>
|
|
28
|
-
{[:local_id, :perm_id, :client_id, :cumulative_quantity, :price, :average_price] =>
|
|
29
|
-
numeric_assigns,
|
|
30
|
-
:liquidation => boolean_assigns,
|
|
4
|
+
:props => {:account_name => "DU111110",
|
|
5
|
+
:client_id => 1111,
|
|
6
|
+
:exchange => "IDEALPRO",
|
|
7
|
+
:exec_id => "0001f4e8.4f5d48f1.01.01",
|
|
8
|
+
:liquidation => true,
|
|
9
|
+
:local_id => 373,
|
|
10
|
+
:perm_id => 1695693619,
|
|
11
|
+
:price => 1.31075,
|
|
12
|
+
:average_price => 1.31075,
|
|
13
|
+
:shares => 20000,
|
|
14
|
+
:cumulative_quantity => 20000,
|
|
15
|
+
:side => :buy,
|
|
16
|
+
:time => "20120312 15:41:09",
|
|
31
17
|
},
|
|
32
18
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
:human => "<Execution: 20120312 15:41:09 buy 20000 at 1.31075 on IDEALPRO, cumulative 20000 at 1.31075, ids 373/1695693619/0001f4e8.4f5d48f1.01.01>",
|
|
20
|
+
|
|
21
|
+
:errors => {:side=>["should be buy/sell/short"],
|
|
22
|
+
:cumulative_quantity=>["is not a number"],
|
|
23
|
+
:average_price=>["is not a number"]},
|
|
24
|
+
|
|
25
|
+
:assigns => {[:local_id, :perm_id, :client_id, :cumulative_quantity, :price, :average_price] =>
|
|
26
|
+
numeric_assigns,
|
|
27
|
+
:liquidation => boolean_assigns,
|
|
28
|
+
},
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
:aliases => {[:side, :action] => buy_sell_assigns,
|
|
31
|
+
[:quantity, :shares] => numeric_assigns,
|
|
32
|
+
[:account_name, :account_number]=> string_assigns,
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
:associations => {:order => {:local_id => 23,
|
|
36
|
+
:perm_id => 173276893,
|
|
37
|
+
:client_id => 1111,
|
|
38
|
+
:parent_id => 0,
|
|
39
|
+
:quantity => 100,
|
|
40
|
+
:side => :buy,
|
|
41
|
+
:order_type => :market}
|
|
42
|
+
} do
|
|
48
43
|
|
|
49
44
|
it_behaves_like 'Model with invalid defaults'
|
|
50
45
|
it_behaves_like 'Self-equal Model'
|
|
@@ -81,6 +76,7 @@ describe IB::Execution,
|
|
|
81
76
|
subject { IB::Execution.new props }
|
|
82
77
|
|
|
83
78
|
it 'correctly serializes Model into hash and json' do
|
|
79
|
+
# p subject.as_json
|
|
84
80
|
{"account_name"=>"DU111110",
|
|
85
81
|
"average_price"=>1.31075,
|
|
86
82
|
"client_id"=>1111,
|
|
@@ -95,14 +91,24 @@ describe IB::Execution,
|
|
|
95
91
|
"price"=>1.31075,
|
|
96
92
|
"quantity"=>20000,
|
|
97
93
|
"time"=>"20120312 15:41:09",
|
|
98
|
-
|
|
94
|
+
"side"=>:buy, }.each do |key, value|
|
|
99
95
|
|
|
100
96
|
subject.serializable_hash[key].should == value
|
|
101
|
-
|
|
97
|
+
|
|
98
|
+
if OPTS[:rails] == "Dummy" # "Dummy" Rails app removes extra key level from json...
|
|
99
|
+
subject.as_json[key].should == value
|
|
100
|
+
else
|
|
101
|
+
subject.as_json["execution"][key].should == value
|
|
102
|
+
end
|
|
102
103
|
end
|
|
103
104
|
|
|
104
105
|
subject.to_xml.should =~ /<account-name>DU111110<.account-name>\n <average-price type=\"float\">1.31075<.average-price>\n <client-id type=\"integer\">1111<.client-id>/
|
|
105
|
-
|
|
106
|
+
|
|
107
|
+
if OPTS[:rails] == "Dummy" # "Dummy" Rails app removes extra key level from json...
|
|
108
|
+
subject.to_json.should =~ /\{\"account_name\":\"DU111110\",\"average_price\":1.31075,\"client_id\":1111,\"/
|
|
109
|
+
else
|
|
110
|
+
subject.to_json.should =~ /\{\"execution\":\{\"account_name\":\"DU111110\",\"average_price\":1.31075,\"client_id\":1111,\"/
|
|
111
|
+
end
|
|
106
112
|
|
|
107
113
|
IB::Execution.new.from_json(subject.to_json).should == subject
|
|
108
114
|
end
|
|
@@ -8,10 +8,10 @@ describe IB::Order,
|
|
|
8
8
|
:perm_id => 173276893,
|
|
9
9
|
:parent_id => 0,
|
|
10
10
|
:side => :buy,
|
|
11
|
+
:tif => :good_till_cancelled,
|
|
11
12
|
:order_type => :market_if_touched,
|
|
12
13
|
:limit_price => 0.1,
|
|
13
14
|
:quantity => 100,
|
|
14
|
-
:tif => :good_till_cancelled,
|
|
15
15
|
:open_close => :close,
|
|
16
16
|
:oca_group => '',
|
|
17
17
|
:oca_type => :reduce_no_block,
|
|
@@ -87,7 +87,7 @@ describe IB::Order,
|
|
|
87
87
|
it_behaves_like 'Model with invalid defaults'
|
|
88
88
|
|
|
89
89
|
context 'Order associations' do
|
|
90
|
-
after(:all) { DatabaseCleaner.clean if IB
|
|
90
|
+
after(:all) { DatabaseCleaner.clean if IB.db_backed? }
|
|
91
91
|
|
|
92
92
|
subject { IB::Order.new props }
|
|
93
93
|
|
data/spec/order_helper.rb
CHANGED
|
@@ -127,7 +127,7 @@ shared_examples_for 'Placed Order' do
|
|
|
127
127
|
context "Cancelling placed order" do
|
|
128
128
|
before(:all) do
|
|
129
129
|
@ib.cancel_order @local_id_placed
|
|
130
|
-
@ib.wait_for [:
|
|
130
|
+
@ib.wait_for [:OpenOrder, 2], :Alert, 3
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
after(:all) { clean_connection } # Clear logs and message collector
|
|
@@ -138,6 +138,8 @@ shared_examples_for 'Placed Order' do
|
|
|
138
138
|
|
|
139
139
|
it 'only receives OpenOrder message with PendingCancel' do
|
|
140
140
|
if @ib.received? :OpenOrder
|
|
141
|
+
# p @ib.received[:OrderStatus].size
|
|
142
|
+
# p @ib.received[ :OpenOrder].map {|m| m.order.limit_price.to_s+m.status}
|
|
141
143
|
order_should_be /PendingCancel/
|
|
142
144
|
end
|
|
143
145
|
end
|
|
@@ -182,7 +184,7 @@ end
|
|
|
182
184
|
def status_should_be status, order=@order
|
|
183
185
|
msg = @ib.received[:OrderStatus].find do |msg|
|
|
184
186
|
msg.local_id == order.local_id &&
|
|
185
|
-
|
|
187
|
+
status.is_a?(Regexp) ? msg.status =~ status : msg.status == status
|
|
186
188
|
end
|
|
187
189
|
msg.should_not be_nil
|
|
188
190
|
msg.should be_an IB::Messages::Incoming::OrderStatus
|
|
@@ -211,11 +213,10 @@ end
|
|
|
211
213
|
def order_should_be status, order=@order
|
|
212
214
|
msg = @ib.received[:OpenOrder].find do |msg|
|
|
213
215
|
msg.local_id == order.local_id &&
|
|
214
|
-
|
|
216
|
+
status.is_a?(Regexp) ? msg.status =~ status : msg.status == status
|
|
215
217
|
end
|
|
216
218
|
msg.should_not be_nil
|
|
217
219
|
msg.should be_an IB::Messages::Incoming::OpenOrder
|
|
218
220
|
msg.order.should == order
|
|
219
221
|
msg.contract.should == @contract
|
|
220
222
|
end
|
|
221
|
-
|
data/spec/spec_helper.rb
CHANGED
|
@@ -6,8 +6,8 @@ require 'ib'
|
|
|
6
6
|
OPTS ||= {
|
|
7
7
|
:verbose => false, #true, # Run test suite in a verbose mode ?
|
|
8
8
|
:brokertron => false, # Use mock (Brokertron) instead of paper account ?
|
|
9
|
-
:
|
|
10
|
-
:
|
|
9
|
+
:rails => IB.rails? && Rails.application.class.parent_name,
|
|
10
|
+
:db => IB.db_backed?
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
if OPTS[:brokertron]
|
|
@@ -59,7 +59,7 @@ RSpec.configure do |config|
|
|
|
59
59
|
|
|
60
60
|
:db => proc { |condition| IB.db_backed? != condition }, # true/false
|
|
61
61
|
|
|
62
|
-
:rails => proc { |condition| IB.rails? != condition }, #
|
|
62
|
+
:rails => proc { |condition| IB.rails? != condition }, # false or "Dummy"/"Combustion"
|
|
63
63
|
|
|
64
64
|
:reuters => proc { |condition| !OPTS[:connection][:reuters] == condition }, # true/false
|
|
65
65
|
}
|
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: ib-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.8.
|
|
5
|
+
version: 0.8.5
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Paul Legato
|
|
@@ -11,7 +11,7 @@ autorequire:
|
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
13
|
|
|
14
|
-
date: 2012-
|
|
14
|
+
date: 2012-08-11 00:00:00 Z
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
17
17
|
name: bundler
|
|
@@ -183,37 +183,76 @@ email:
|
|
|
183
183
|
- pjlegato@gmail.com
|
|
184
184
|
- arvicco@gmail.com
|
|
185
185
|
executables:
|
|
186
|
-
-
|
|
187
|
-
- cancel_orders
|
|
188
|
-
- contract_details
|
|
189
|
-
- depth_of_market
|
|
190
|
-
- fa_accounts
|
|
191
|
-
- fundamental_data
|
|
192
|
-
- historic_data
|
|
193
|
-
- historic_data_cli
|
|
194
|
-
- list_orders
|
|
195
|
-
- market_data
|
|
196
|
-
- option_data
|
|
197
|
-
- place_combo_order
|
|
198
|
-
- place_order
|
|
199
|
-
- template
|
|
200
|
-
- tick_data
|
|
201
|
-
- time_and_sales
|
|
186
|
+
- scaffold.rb
|
|
202
187
|
extensions: []
|
|
203
188
|
|
|
204
189
|
extra_rdoc_files: []
|
|
205
190
|
|
|
206
191
|
files:
|
|
207
192
|
- app/assets/javascripts/ib/application.js
|
|
193
|
+
- app/assets/javascripts/ib/bars.js
|
|
194
|
+
- app/assets/javascripts/ib/executions.js
|
|
195
|
+
- app/assets/javascripts/ib/order_states.js
|
|
208
196
|
- app/assets/javascripts/ib/underlyings.js
|
|
209
197
|
- app/assets/stylesheets/scaffold.css
|
|
210
198
|
- app/assets/stylesheets/ib/application.css
|
|
199
|
+
- app/assets/stylesheets/ib/bars.css
|
|
200
|
+
- app/assets/stylesheets/ib/executions.css
|
|
201
|
+
- app/assets/stylesheets/ib/order_states.css
|
|
211
202
|
- app/assets/stylesheets/ib/underlyings.css
|
|
212
203
|
- app/controllers/ib/application_controller.rb
|
|
204
|
+
- app/controllers/ib/bars_controller.rb
|
|
205
|
+
- app/controllers/ib/combo_legs_controller.rb
|
|
206
|
+
- app/controllers/ib/contract_details_controller.rb
|
|
207
|
+
- app/controllers/ib/contracts_controller.rb
|
|
208
|
+
- app/controllers/ib/executions_controller.rb
|
|
209
|
+
- app/controllers/ib/order_states_controller.rb
|
|
210
|
+
- app/controllers/ib/orders_controller.rb
|
|
213
211
|
- app/controllers/ib/underlyings_controller.rb
|
|
214
212
|
- app/helpers/ib/application_helper.rb
|
|
213
|
+
- app/helpers/ib/bars_helper.rb
|
|
214
|
+
- app/helpers/ib/combo_legs_helper.rb
|
|
215
|
+
- app/helpers/ib/contract_details_helper.rb
|
|
216
|
+
- app/helpers/ib/contracts_helper.rb
|
|
217
|
+
- app/helpers/ib/executions_helper.rb
|
|
218
|
+
- app/helpers/ib/order_states_helper.rb
|
|
219
|
+
- app/helpers/ib/orders_helper.rb
|
|
215
220
|
- app/helpers/ib/underlyings_helper.rb
|
|
216
|
-
- app/
|
|
221
|
+
- app/views/ib/bars/_form.html.erb
|
|
222
|
+
- app/views/ib/bars/edit.html.erb
|
|
223
|
+
- app/views/ib/bars/index.html.erb
|
|
224
|
+
- app/views/ib/bars/new.html.erb
|
|
225
|
+
- app/views/ib/bars/show.html.erb
|
|
226
|
+
- app/views/ib/combo_legs/_form.html.erb
|
|
227
|
+
- app/views/ib/combo_legs/edit.html.erb
|
|
228
|
+
- app/views/ib/combo_legs/index.html.erb
|
|
229
|
+
- app/views/ib/combo_legs/new.html.erb
|
|
230
|
+
- app/views/ib/combo_legs/show.html.erb
|
|
231
|
+
- app/views/ib/contract_details/_form.html.erb
|
|
232
|
+
- app/views/ib/contract_details/edit.html.erb
|
|
233
|
+
- app/views/ib/contract_details/index.html.erb
|
|
234
|
+
- app/views/ib/contract_details/new.html.erb
|
|
235
|
+
- app/views/ib/contract_details/show.html.erb
|
|
236
|
+
- app/views/ib/contracts/_form.html.erb
|
|
237
|
+
- app/views/ib/contracts/edit.html.erb
|
|
238
|
+
- app/views/ib/contracts/index.html.erb
|
|
239
|
+
- app/views/ib/contracts/new.html.erb
|
|
240
|
+
- app/views/ib/contracts/show.html.erb
|
|
241
|
+
- app/views/ib/executions/_form.html.erb
|
|
242
|
+
- app/views/ib/executions/edit.html.erb
|
|
243
|
+
- app/views/ib/executions/index.html.erb
|
|
244
|
+
- app/views/ib/executions/new.html.erb
|
|
245
|
+
- app/views/ib/executions/show.html.erb
|
|
246
|
+
- app/views/ib/order_states/_form.html.erb
|
|
247
|
+
- app/views/ib/order_states/edit.html.erb
|
|
248
|
+
- app/views/ib/order_states/index.html.erb
|
|
249
|
+
- app/views/ib/order_states/new.html.erb
|
|
250
|
+
- app/views/ib/order_states/show.html.erb
|
|
251
|
+
- app/views/ib/orders/_form.html.erb
|
|
252
|
+
- app/views/ib/orders/edit.html.erb
|
|
253
|
+
- app/views/ib/orders/index.html.erb
|
|
254
|
+
- app/views/ib/orders/new.html.erb
|
|
255
|
+
- app/views/ib/orders/show.html.erb
|
|
217
256
|
- app/views/ib/underlyings/_form.html.erb
|
|
218
257
|
- app/views/ib/underlyings/edit.html.erb
|
|
219
258
|
- app/views/ib/underlyings/index.html.erb
|
|
@@ -231,22 +270,7 @@ files:
|
|
|
231
270
|
- db/migrate/151_add_ib_underlyings.rb
|
|
232
271
|
- db/migrate/161_add_ib_contract_details.rb
|
|
233
272
|
- db/migrate/171_add_ib_contracts.rb
|
|
234
|
-
- bin/
|
|
235
|
-
- bin/cancel_orders
|
|
236
|
-
- bin/contract_details
|
|
237
|
-
- bin/depth_of_market
|
|
238
|
-
- bin/fa_accounts
|
|
239
|
-
- bin/fundamental_data
|
|
240
|
-
- bin/historic_data
|
|
241
|
-
- bin/historic_data_cli
|
|
242
|
-
- bin/list_orders
|
|
243
|
-
- bin/market_data
|
|
244
|
-
- bin/option_data
|
|
245
|
-
- bin/place_combo_order
|
|
246
|
-
- bin/place_order
|
|
247
|
-
- bin/template
|
|
248
|
-
- bin/tick_data
|
|
249
|
-
- bin/time_and_sales
|
|
273
|
+
- bin/scaffold.rb
|
|
250
274
|
- lib/ib-ruby.rb
|
|
251
275
|
- lib/ib.rb
|
|
252
276
|
- lib/ib/base.rb
|