ib-ruby 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.gitignore +3 -0
  2. data/HISTORY +3 -0
  3. data/README.md +29 -9
  4. data/VERSION +1 -1
  5. data/app/assets/javascripts/ib/bars.js +2 -0
  6. data/app/assets/javascripts/ib/executions.js +2 -0
  7. data/app/assets/javascripts/ib/order_states.js +2 -0
  8. data/app/assets/stylesheets/ib/bars.css +4 -0
  9. data/app/assets/stylesheets/ib/executions.css +4 -0
  10. data/app/assets/stylesheets/ib/order_states.css +4 -0
  11. data/app/controllers/ib/bars_controller.rb +87 -0
  12. data/app/controllers/ib/combo_legs_controller.rb +87 -0
  13. data/app/controllers/ib/contract_details_controller.rb +87 -0
  14. data/app/controllers/ib/contracts_controller.rb +87 -0
  15. data/app/controllers/ib/executions_controller.rb +87 -0
  16. data/app/controllers/ib/order_states_controller.rb +87 -0
  17. data/app/controllers/ib/orders_controller.rb +87 -0
  18. data/app/helpers/ib/bars_helper.rb +4 -0
  19. data/app/helpers/ib/combo_legs_helper.rb +4 -0
  20. data/app/helpers/ib/contract_details_helper.rb +4 -0
  21. data/app/helpers/ib/contracts_helper.rb +4 -0
  22. data/app/helpers/ib/executions_helper.rb +4 -0
  23. data/app/helpers/ib/order_states_helper.rb +4 -0
  24. data/app/helpers/ib/orders_helper.rb +4 -0
  25. data/app/views/ib/bars/_form.html.erb +57 -0
  26. data/app/views/ib/bars/edit.html.erb +6 -0
  27. data/app/views/ib/bars/index.html.erb +41 -0
  28. data/app/views/ib/bars/new.html.erb +5 -0
  29. data/app/views/ib/bars/show.html.erb +55 -0
  30. data/app/views/ib/combo_legs/_form.html.erb +53 -0
  31. data/app/views/ib/combo_legs/edit.html.erb +6 -0
  32. data/app/views/ib/combo_legs/index.html.erb +39 -0
  33. data/app/views/ib/combo_legs/new.html.erb +5 -0
  34. data/app/views/ib/combo_legs/show.html.erb +55 -0
  35. data/app/views/ib/contract_details/_form.html.erb +141 -0
  36. data/app/views/ib/contract_details/edit.html.erb +6 -0
  37. data/app/views/ib/contract_details/index.html.erb +83 -0
  38. data/app/views/ib/contract_details/new.html.erb +5 -0
  39. data/app/views/ib/contract_details/show.html.erb +160 -0
  40. data/app/views/ib/contracts/_form.html.erb +77 -0
  41. data/app/views/ib/contracts/edit.html.erb +6 -0
  42. data/app/views/ib/contracts/index.html.erb +53 -0
  43. data/app/views/ib/contracts/new.html.erb +5 -0
  44. data/app/views/ib/contracts/show.html.erb +85 -0
  45. data/app/views/ib/executions/_form.html.erb +77 -0
  46. data/app/views/ib/executions/edit.html.erb +6 -0
  47. data/app/views/ib/executions/index.html.erb +51 -0
  48. data/app/views/ib/executions/new.html.erb +5 -0
  49. data/app/views/ib/executions/show.html.erb +80 -0
  50. data/app/views/ib/order_states/_form.html.erb +93 -0
  51. data/app/views/ib/order_states/edit.html.erb +6 -0
  52. data/app/views/ib/order_states/index.html.erb +59 -0
  53. data/app/views/ib/order_states/new.html.erb +5 -0
  54. data/app/views/ib/order_states/show.html.erb +100 -0
  55. data/app/views/ib/orders/_form.html.erb +353 -0
  56. data/app/views/ib/orders/edit.html.erb +6 -0
  57. data/app/views/ib/orders/index.html.erb +193 -0
  58. data/app/views/ib/orders/new.html.erb +5 -0
  59. data/app/views/ib/orders/show.html.erb +435 -0
  60. data/bin/scaffold.rb +29 -0
  61. data/config/routes.rb +8 -1
  62. data/db/config.yml +5 -0
  63. data/db/migrate/101_add_ib_executions.rb +3 -0
  64. data/db/migrate/111_add_ib_bars.rb +6 -0
  65. data/db/migrate/121_add_ib_order_states.rb +8 -0
  66. data/db/migrate/131_add_ib_orders.rb +24 -0
  67. data/db/migrate/141_add_ib_combo_legs.rb +6 -0
  68. data/db/migrate/151_add_ib_underlyings.rb +3 -0
  69. data/db/migrate/161_add_ib_contract_details.rb +11 -0
  70. data/db/migrate/171_add_ib_contracts.rb +8 -1
  71. data/db/schema.rb +6 -5
  72. data/lib/ib/base.rb +3 -1
  73. data/lib/ib/base_properties.rb +26 -15
  74. data/lib/ib/connection.rb +3 -2
  75. data/lib/ib/errors.rb +16 -9
  76. data/lib/ib/extensions.rb +6 -4
  77. data/lib/ib/symbols.rb +10 -3
  78. data/lib/ib/symbols/forex.rb +49 -64
  79. data/lib/ib/symbols/futures.rb +2 -3
  80. data/lib/ib/symbols/options.rb +2 -1
  81. data/lib/ib/symbols/stocks.rb +2 -1
  82. data/lib/models/ib/bar.rb +6 -2
  83. data/lib/models/ib/combo_leg.rb +4 -3
  84. data/lib/models/ib/contract.rb +9 -5
  85. data/lib/models/ib/contract_detail.rb +1 -1
  86. data/lib/models/ib/execution.rb +3 -1
  87. data/lib/models/ib/order.rb +22 -20
  88. data/lib/models/ib/order_state.rb +4 -2
  89. data/lib/models/ib/underlying.rb +3 -4
  90. data/spec/README.md +12 -10
  91. data/spec/ib/symbols/symbols_spec.rb +10 -0
  92. data/spec/integration_helper.rb +1 -1
  93. data/spec/model_helper.rb +9 -8
  94. data/spec/models/ib/combo_leg_spec.rb +29 -28
  95. data/spec/models/ib/contract_detail_spec.rb +4 -1
  96. data/spec/models/ib/contract_spec.rb +66 -58
  97. data/spec/models/ib/execution_spec.rb +50 -44
  98. data/spec/models/ib/order_spec.rb +2 -2
  99. data/spec/order_helper.rb +5 -4
  100. data/spec/spec_helper.rb +3 -3
  101. metadata +59 -35
  102. data/app/models/ib/underlying.rb +0 -5
  103. data/bin/account_info +0 -29
  104. data/bin/cancel_orders +0 -27
  105. data/bin/contract_details +0 -35
  106. data/bin/depth_of_market +0 -43
  107. data/bin/fa_accounts +0 -22
  108. data/bin/fundamental_data +0 -39
  109. data/bin/historic_data +0 -51
  110. data/bin/historic_data_cli +0 -182
  111. data/bin/list_orders +0 -28
  112. data/bin/market_data +0 -41
  113. data/bin/option_data +0 -44
  114. data/bin/place_combo_order +0 -58
  115. data/bin/place_order +0 -27
  116. data/bin/template +0 -18
  117. data/bin/tick_data +0 -26
  118. 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 =>/<ContractDetail: callable: false category: Computers contract_month: 201301 convertible: false coupon: 0.0 .*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 .*valid_exchanges: SMART,AMEX,BATS,BOX,CBOE,CBOE2,IBSX,ISE,MIBSX,NASDAQOM,PHLX,PSE>/,
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
- :props =>
6
- {:symbol => 'AAPL',
7
- :sec_type => :option,
8
- :expiry => '201301',
9
- :strike => 600.5,
10
- :right => :put,
11
- :multiplier => 10,
12
- :exchange => 'SMART',
13
- :currency => 'USD',
14
- :local_symbol => 'AAPL 130119C00500000'},
15
-
16
- :human => "<Contract: AAPL option 201301 put 600.5 SMART USD>",
17
-
18
- :errors => {:sec_type => ["should be valid security type"] },
19
-
20
- :assigns =>
21
- {:expiry =>
22
- {[200609, '200609'] => '200609',
23
- [20060913, '20060913'] => '20060913',
24
- [:foo, 2006, 42, 'bar'] => /should be YYYYMM or YYYYMMDD/},
25
-
26
- :sec_type => codes_and_values_for(:sec_type).
27
- merge([:foo, 'BAR', 42] => /should be valid security type/),
28
-
29
- :sec_id_type =>
30
- {[:isin, 'ISIN', 'iSin'] => 'ISIN',
31
- [:sedol, :SEDOL, 'sEDoL', 'SEDOL'] => 'SEDOL',
32
- [:cusip, :CUSIP, 'Cusip', 'CUSIP'] => 'CUSIP',
33
- [:ric, :RIC, 'rIC', 'RIC'] => 'RIC',
34
- [nil, ''] => '',
35
- [:foo, 'BAR', 'baz'] => /should be valid security identifier/},
36
-
37
- :right =>
38
- {["PUT", "put", "P", "p", :put] => :put,
39
- ["CALL", "call", "C", "c", :call] => :call,
40
- ['', '0', '?', :none] => :none,
41
- [:foo, 'BAR', 42] => /should be put, call or none/},
42
-
43
- :exchange => string_upcase_assigns.merge(
44
- [:smart, 'SMART', 'smArt'] => 'SMART'),
45
-
46
- :primary_exchange =>string_upcase_assigns.merge(
47
- [:SMART, 'SMART'] => /should not be SMART/),
48
-
49
- :multiplier => to_i_assigns,
50
-
51
- :strike => to_f_assigns,
52
-
53
- :include_expired => boolean_assigns,
54
- } do
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
- ["AAPL", "OPT", "201301", 600.5, "P", 10, "SMART", "", "USD", "AAPL 130119C00500000"]
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
- ["AAPL", "OPT", "201301", 600.5, "P", 10, "SMART", "USD", "AAPL 130119C00500000"]
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
- [0, "GOOG", "BAG", "", 0.0, "", nil, "SMART", "", "USD", "", "", nil]
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
- [3, 81032967, 1, "BUY", "SMART", 81032968, 2, "SELL", "SMART", 81032973, 1, "BUY", "SMART"]
148
+ [3, 81032967, 1, "BUY", "SMART", 81032968, 2, "SELL", "SMART", 81032973, 1, "BUY", "SMART"]
141
149
 
142
150
  @combo.serialize_legs(:extended).should ==
143
- [3, 81032967, 1, "BUY", "SMART", 0, 0, "", -1,
144
- 81032968, 2, "SELL", "SMART", 0, 0, "", -1,
145
- 81032973, 1, "BUY", "SMART", 0, 0, "", -1]
146
- end
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
- :props =>
5
- {:account_name => "DU111110",
6
- :client_id => 1111,
7
- :exchange => "IDEALPRO",
8
- :exec_id => "0001f4e8.4f5d48f1.01.01",
9
- :liquidation => true,
10
- :local_id => 373,
11
- :perm_id => 1695693619,
12
- :price => 1.31075,
13
- :average_price => 1.31075,
14
- :shares => 20000,
15
- :cumulative_quantity => 20000,
16
- :side => :buy,
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
- :aliases =>
34
- {[:side, :action] => buy_sell_assigns,
35
- [:quantity, :shares] => numeric_assigns,
36
- [:account_name, :account_number]=> string_assigns,
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
- :associations =>
40
- {:order => {:local_id => 23,
41
- :perm_id => 173276893,
42
- :client_id => 1111,
43
- :parent_id => 0,
44
- :quantity => 100,
45
- :side => :buy,
46
- :order_type => :market}
47
- } do # AKA IB::Execution
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
- "side"=>:buy, }.each do |key, value|
94
+ "side"=>:buy, }.each do |key, value|
99
95
 
100
96
  subject.serializable_hash[key].should == value
101
- subject.as_json["execution"][key].should == value
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
- subject.to_json.should =~ /\{\"execution\":\{\"account_name\":\"DU111110\",\"average_price\":1.31075,\"client_id\":1111,\"/
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::DB }
90
+ after(:all) { DatabaseCleaner.clean if IB.db_backed? }
91
91
 
92
92
  subject { IB::Order.new props }
93
93
 
@@ -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 [:OrderStatus, 3], :Alert
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
- status.is_a?(Regexp) ? msg.status =~ status : msg.status == status
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
- status.is_a?(Regexp) ? msg.status =~ status : msg.status == status
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
-
@@ -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
- :db => IB.db_backed?,
10
- :rails => IB.rails?
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 }, # true/false
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.4
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-07-18 00:00:00 Z
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
- - account_info
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/models/ib/underlying.rb
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/account_info
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