ib-ruby 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/HISTORY +4 -0
  2. data/README.md +60 -30
  3. data/TODO +1 -0
  4. data/VERSION +1 -1
  5. data/bin/account_info +1 -4
  6. data/bin/cancel_orders +0 -3
  7. data/bin/contract_details +2 -5
  8. data/bin/depth_of_market +1 -4
  9. data/bin/fa_accounts +22 -0
  10. data/bin/historic_data +1 -4
  11. data/bin/historic_data_cli +0 -4
  12. data/bin/list_orders +2 -6
  13. data/bin/market_data +1 -4
  14. data/bin/option_data +2 -5
  15. data/bin/place_combo_order +17 -22
  16. data/bin/place_order +6 -10
  17. data/bin/tick_data +6 -9
  18. data/bin/time_and_sales +2 -5
  19. data/lib/ib-ruby/connection.rb +10 -5
  20. data/lib/ib-ruby/messages/incoming/open_order.rb +15 -13
  21. data/lib/ib-ruby/messages/incoming/ticks.rb +1 -1
  22. data/lib/ib-ruby/messages/incoming.rb +18 -18
  23. data/lib/ib-ruby/messages/outgoing.rb +2 -2
  24. data/lib/ib-ruby/messages.rb +3 -7
  25. data/lib/ib-ruby/models/{contract → contracts}/bag.rb +5 -8
  26. data/lib/ib-ruby/models/contracts/contract.rb +296 -0
  27. data/lib/ib-ruby/models/{contract → contracts}/option.rb +2 -4
  28. data/lib/ib-ruby/models/contracts.rb +27 -0
  29. data/lib/ib-ruby/models/execution.rb +1 -1
  30. data/lib/ib-ruby/models/order.rb +6 -17
  31. data/lib/ib-ruby/models.rb +9 -7
  32. data/lib/ib-ruby/symbols/forex.rb +50 -50
  33. data/lib/ib-ruby/symbols/futures.rb +47 -47
  34. data/lib/ib-ruby/symbols/options.rb +23 -23
  35. data/lib/ib-ruby/symbols/stocks.rb +14 -14
  36. data/lib/ib-ruby.rb +17 -9
  37. data/spec/README.md +6 -0
  38. data/spec/account_helper.rb +1 -1
  39. data/spec/combo_helper.rb +31 -0
  40. data/spec/ib-ruby/models/combo_leg_spec.rb +4 -4
  41. data/spec/ib-ruby/models/contract_spec.rb +37 -26
  42. data/spec/ib-ruby/models/execution_spec.rb +5 -5
  43. data/spec/ib-ruby/models/order_spec.rb +16 -16
  44. data/spec/integration/contract_info_spec.rb +8 -10
  45. data/spec/integration/historic_data_spec.rb +1 -1
  46. data/spec/integration/market_data_spec.rb +5 -5
  47. data/spec/integration/orders/attached_spec.rb +87 -0
  48. data/spec/integration/orders/combo_spec.rb +52 -65
  49. data/spec/integration/orders/placement_spec.rb +8 -8
  50. data/spec/order_helper.rb +97 -28
  51. data/spec/spec_helper.rb +2 -2
  52. metadata +12 -5
  53. data/lib/ib-ruby/models/contract.rb +0 -308
@@ -53,61 +53,61 @@ module IB
53
53
  # digit month. For example, November 2011 is "201111".
54
54
  #
55
55
  def self.future(base_symbol, exchange, currency, description="", expiry=nil)
56
- Models::Contract.new(:symbol => base_symbol,
57
- :expiry => expiry || next_expiry,
58
- :exchange => exchange,
59
- :currency => currency,
60
- :sec_type => SECURITY_TYPES[:future],
61
- :description => description)
56
+ IB::Contract.new :symbol => base_symbol,
57
+ :expiry => expiry || next_expiry,
58
+ :exchange => exchange,
59
+ :currency => currency,
60
+ :sec_type => SECURITY_TYPES[:future],
61
+ :description => description
62
62
  end
63
63
 
64
64
  Futures ={
65
- :ym => Models::Contract.new(:symbol => "YM",
66
- :expiry => next_expiry,
67
- :exchange => "ECBOT",
68
- :currency => "USD",
69
- :sec_type => SECURITY_TYPES[:future],
70
- :description => "Mini Dow Jones Industrial"),
65
+ :ym => IB::Contract.new(:symbol => "YM",
66
+ :expiry => next_expiry,
67
+ :exchange => "ECBOT",
68
+ :currency => "USD",
69
+ :sec_type => SECURITY_TYPES[:future],
70
+ :description => "Mini Dow Jones Industrial"),
71
71
 
72
- :es => Models::Contract.new(:symbol => "ES",
73
- :expiry => next_expiry,
74
- :exchange => "GLOBEX",
75
- :currency => "USD",
76
- :sec_type => SECURITY_TYPES[:future],
77
- :multiplier => 50,
78
- :description => "E-Mini S&P 500"),
72
+ :es => IB::Contract.new(:symbol => "ES",
73
+ :expiry => next_expiry,
74
+ :exchange => "GLOBEX",
75
+ :currency => "USD",
76
+ :sec_type => SECURITY_TYPES[:future],
77
+ :multiplier => 50,
78
+ :description => "E-Mini S&P 500"),
79
79
 
80
- :gbp => Models::Contract.new(:symbol => "GBP",
81
- :expiry => next_expiry,
82
- :exchange => "GLOBEX",
83
- :currency => "USD",
84
- :sec_type => SECURITY_TYPES[:future],
85
- :multiplier => 62500,
86
- :description => "British Pounds"),
80
+ :gbp => IB::Contract.new(:symbol => "GBP",
81
+ :expiry => next_expiry,
82
+ :exchange => "GLOBEX",
83
+ :currency => "USD",
84
+ :sec_type => SECURITY_TYPES[:future],
85
+ :multiplier => 62500,
86
+ :description => "British Pounds"),
87
87
 
88
- :eur => Models::Contract.new(:symbol => "EUR",
89
- :expiry => next_expiry,
90
- :exchange => "GLOBEX",
91
- :currency => "USD",
92
- :sec_type => SECURITY_TYPES[:future],
93
- :multiplier => 12500,
94
- :description => "Euro FX"),
88
+ :eur => IB::Contract.new(:symbol => "EUR",
89
+ :expiry => next_expiry,
90
+ :exchange => "GLOBEX",
91
+ :currency => "USD",
92
+ :sec_type => SECURITY_TYPES[:future],
93
+ :multiplier => 12500,
94
+ :description => "Euro FX"),
95
95
 
96
- :jpy => Models::Contract.new(:symbol => "JPY",
97
- :expiry => next_expiry,
98
- :exchange => "GLOBEX",
99
- :currency => "USD",
100
- :sec_type => SECURITY_TYPES[:future],
101
- :multiplier => 12500000,
102
- :description => "Japanese Yen"),
96
+ :jpy => IB::Contract.new(:symbol => "JPY",
97
+ :expiry => next_expiry,
98
+ :exchange => "GLOBEX",
99
+ :currency => "USD",
100
+ :sec_type => SECURITY_TYPES[:future],
101
+ :multiplier => 12500000,
102
+ :description => "Japanese Yen"),
103
103
 
104
- :hsi => Models::Contract.new(:symbol => "HSI",
105
- :expiry => next_expiry,
106
- :exchange => "HKFE",
107
- :currency => "HKD",
108
- :sec_type => SECURITY_TYPES[:future],
109
- :multiplier => 50,
110
- :description => "Hang Seng Index")
104
+ :hsi => IB::Contract.new(:symbol => "HSI",
105
+ :expiry => next_expiry,
106
+ :exchange => "HKFE",
107
+ :currency => "HKD",
108
+ :sec_type => SECURITY_TYPES[:future],
109
+ :multiplier => 50,
110
+ :description => "Hang Seng Index")
111
111
  }
112
112
  end
113
113
  end
@@ -8,29 +8,29 @@ module IB
8
8
  module Symbols
9
9
 
10
10
  Options =
11
- {:wfc20 => Models::Contract::Option.new(:symbol => "WFC",
12
- :expiry => "201207",
13
- :right => "CALL",
14
- :strike => 20.0,
15
- :description => "Wells Fargo 20 Call 2012-07"),
16
- :aapl500 => Models::Contract::Option.new(:symbol => "AAPL",
17
- :expiry => "201301",
18
- :right => "CALL",
19
- :strike => 500,
20
- :description => "Apple 500 Call 2013-01"),
21
- :z50 => Models::Contract::Option.new(:symbol => "Z",
22
- :exchange => "LIFFE",
23
- :expiry => "201206",
24
- :right => "CALL",
25
- :strike => 50.0,
26
- :description => " FTSE-100 index 50 Call 2012-06"),
27
- :spy75 => Models::Contract::Option.new(:symbol => 'SPY',
28
- :expiry => "20120615",
29
- :right => "P",
30
- :currency => "USD",
31
- :strike => 75.0,
32
- :description => "SPY 75.0 Put 2012-06-16"),
33
- :spy100 => Models::Contract::Option.new(:osi => 'SPY 121222P00100000'),
11
+ {:wfc20 => IB::Option.new(:symbol => "WFC",
12
+ :expiry => "201207",
13
+ :right => "CALL",
14
+ :strike => 20.0,
15
+ :description => "Wells Fargo 20 Call 2012-07"),
16
+ :aapl500 => IB::Option.new(:symbol => "AAPL",
17
+ :expiry => "201301",
18
+ :right => "CALL",
19
+ :strike => 500,
20
+ :description => "Apple 500 Call 2013-01"),
21
+ :z50 => IB::Option.new(:symbol => "Z",
22
+ :exchange => "LIFFE",
23
+ :expiry => "201206",
24
+ :right => "CALL",
25
+ :strike => 50.0,
26
+ :description => " FTSE-100 index 50 Call 2012-06"),
27
+ :spy75 => IB::Option.new(:symbol => 'SPY',
28
+ :expiry => "20120615",
29
+ :right => "P",
30
+ :currency => "USD",
31
+ :strike => 75.0,
32
+ :description => "SPY 75.0 Put 2012-06-16"),
33
+ :spy100 => IB::Option.new(:osi => 'SPY 121222P00100000'),
34
34
  }
35
35
  end
36
36
  end
@@ -8,22 +8,22 @@ module IB
8
8
  module Symbols
9
9
 
10
10
  Stocks =
11
- {:wfc => Models::Contract.new(:symbol => "WFC",
12
- :exchange => "NYSE",
13
- :currency => "USD",
14
- :sec_type => SECURITY_TYPES[:stock],
15
- :description => "Wells Fargo"),
11
+ {:wfc => IB::Contract.new(:symbol => "WFC",
12
+ :exchange => "NYSE",
13
+ :currency => "USD",
14
+ :sec_type => SECURITY_TYPES[:stock],
15
+ :description => "Wells Fargo"),
16
16
 
17
- :aapl => Models::Contract.new(:symbol => "AAPL",
18
- :currency => "USD",
19
- :sec_type => SECURITY_TYPES[:stock],
20
- :description => "Apple Inc."),
17
+ :aapl => IB::Contract.new(:symbol => "AAPL",
18
+ :currency => "USD",
19
+ :sec_type => SECURITY_TYPES[:stock],
20
+ :description => "Apple Inc."),
21
21
 
22
- :wrong => Models::Contract.new(:symbol => "QEEUUE",
23
- :exchange => "NYSE",
24
- :currency => "USD",
25
- :sec_type => SECURITY_TYPES[:stock],
26
- :description => "Non-existent stock"),
22
+ :wrong => IB::Contract.new(:symbol => "QEEUUE",
23
+ :exchange => "NYSE",
24
+ :currency => "USD",
25
+ :sec_type => SECURITY_TYPES[:stock],
26
+ :description => "Non-existent stock"),
27
27
  }
28
28
  end
29
29
  end
data/lib/ib-ruby.rb CHANGED
@@ -1,12 +1,20 @@
1
1
  module IB
2
- end # module IB
2
+
3
+ require 'ib-ruby/version'
4
+ require 'ib-ruby/extensions'
5
+ require 'ib-ruby/errors'
6
+ require 'ib-ruby/constants'
7
+ require 'ib-ruby/connection'
8
+
9
+ require 'ib-ruby/models'
10
+ Datatypes = Models # Flatten namespace (IB::Contract instead of IB::Models::Contract)
11
+ include Models # Legacy alias
12
+
13
+ require 'ib-ruby/messages'
14
+ IncomingMessages = Messages::Incoming # Legacy alias
15
+ OutgoingMessages = Messages::Outgoing # Legacy alias
16
+
17
+ require 'ib-ruby/symbols'
18
+ end
3
19
  IbRuby = IB
4
20
 
5
- require 'ib-ruby/version'
6
- require 'ib-ruby/extensions'
7
- require 'ib-ruby/errors'
8
- require 'ib-ruby/constants'
9
- require 'ib-ruby/connection'
10
- require 'ib-ruby/models'
11
- require 'ib-ruby/messages'
12
- require 'ib-ruby/symbols'
data/spec/README.md CHANGED
@@ -38,5 +38,11 @@ Pattern for writing integration specs is like this:
38
38
  call 'clean_connection' in after block to remove old content from @ib.received Hash,
39
39
  or otherwise manually clean it to remove old/not needed messages from it.
40
40
 
41
+ 11. If you want to see exactly what's going on inside ib-ruby while your examples are
42
+ running, set OPTS[:silent] = false in your context, and you'll see all the
43
+ messages received and log entries made as as result of your examples. Be warned,
44
+ output is very verbose, so don't forget to switch OPTS[:silent] = true after
45
+ you've done debugging your examples.
46
+
41
47
  Help the development!
42
48
  See 'spec/TODO' file for list of scenarios that still need to be tested.
@@ -57,7 +57,7 @@ shared_examples_for 'Valid account data request' do
57
57
  subject { @ib.received[:PortfolioValue].first }
58
58
 
59
59
  it { should be_an IB::Messages::Incoming::PortfolioValue }
60
- its(:contract) { should be_a IB::Models::Contract }
60
+ its(:contract) { should be_a IB::Contract }
61
61
  its(:data) { should be_a Hash }
62
62
  its(:position) { should be_a Integer }
63
63
  its(:market_price) { should be_a Float }
@@ -0,0 +1,31 @@
1
+ require 'integration_helper'
2
+
3
+ # Define butterfly
4
+ def butterfly symbol, expiry, right, *strikes
5
+ unless @ib && @ib.connected?
6
+ @ib = IB::Connection.new OPTS[:connection].merge(:logger => mock_logger)
7
+ end
8
+
9
+ legs = strikes.zip([1, -2, 1]).map do |strike, weight|
10
+ # Create contract
11
+ contract = IB::Option.new :symbol => symbol,
12
+ :expiry => expiry,
13
+ :right => right,
14
+ :strike => strike
15
+ # Find out contract's con_id
16
+ @ib.clear_received :ContractData, :ContractDataEnd
17
+ @ib.send_message :RequestContractData, :id => strike, :contract => contract
18
+ @ib.wait_for :ContractDataEnd, 3
19
+ con_id = @ib.received[:ContractData].last.contract.con_id
20
+
21
+ # Create Comboleg from con_id and weight
22
+ IB::ComboLeg.new :con_id => con_id, :weight => weight
23
+ end
24
+
25
+ # Create new Combo contract
26
+ IB::Bag.new :symbol => symbol,
27
+ :currency => "USD", # Only US options in combo Contracts
28
+ :exchange => "SMART",
29
+ :legs => legs
30
+ end
31
+
@@ -7,7 +7,7 @@ describe IB::Models::ComboLeg do
7
7
  :ratio=> 1234,
8
8
  :action => 'BUY',
9
9
  :exchange => 'BLAH',
10
- :open_close => IB::Models::ComboLeg::OPEN,
10
+ :open_close => IB::ComboLeg::OPEN,
11
11
  :short_sale_slot => 1,
12
12
  :designated_location => 'BLEH',
13
13
  :exempt_code => 12}
@@ -15,7 +15,7 @@ describe IB::Models::ComboLeg do
15
15
 
16
16
  context "instantiation" do
17
17
  context 'empty without properties' do
18
- subject { IB::Models::ComboLeg.new }
18
+ subject { IB::ComboLeg.new }
19
19
 
20
20
  it { should_not be_nil }
21
21
  its(:con_id) {should == 0}
@@ -28,7 +28,7 @@ describe IB::Models::ComboLeg do
28
28
  end
29
29
 
30
30
  context 'with properties' do
31
- subject { IB::Models::ComboLeg.new properties }
31
+ subject { IB::ComboLeg.new properties }
32
32
 
33
33
  it 'sets properties right' do
34
34
  properties.each do |name, value|
@@ -43,7 +43,7 @@ describe IB::Models::ComboLeg do
43
43
 
44
44
  it 'allows setting attributes' do
45
45
  expect {
46
- x = IB::Models::ComboLeg.new
46
+ x = IB::ComboLeg.new
47
47
  properties.each do |name, value|
48
48
  subject.send("#{name}=", value)
49
49
  subject.send(name).should == value
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe IB::Models::Contract do
3
+ describe IB::Models::Contracts::Contract do # AKA IB::Contract
4
4
 
5
5
  let(:properties) do
6
6
  {:symbol => "TEST",
@@ -15,7 +15,7 @@ describe IB::Models::Contract do
15
15
  end
16
16
 
17
17
  context "instantiation" do
18
- context 'empty without properties' do
18
+ context 'using fully qualified class name without properties' do
19
19
  subject { IB::Models::Contract.new }
20
20
 
21
21
  it { should_not be_nil }
@@ -26,8 +26,19 @@ describe IB::Models::Contract do
26
26
  its(:include_expired) { should == false }
27
27
  end
28
28
 
29
+ context 'using short class name without properties' do
30
+ subject { IB::Contract.new }
31
+
32
+ it { should_not be_nil }
33
+ its(:con_id) { should == 0 }
34
+ its(:strike) { should == 0 }
35
+ its(:sec_type) { should be_nil }
36
+ its(:created_at) { should be_a Time }
37
+ its(:include_expired) { should == false }
38
+ end
39
+
29
40
  context 'with properties' do
30
- subject { IB::Models::Contract.new properties }
41
+ subject { IB::Contract.new properties }
31
42
 
32
43
  it 'sets properties right' do
33
44
  properties.each do |name, value|
@@ -54,7 +65,7 @@ describe IB::Models::Contract do
54
65
  end
55
66
 
56
67
  context 'empty without properties' do
57
- subject { IB::Models::Contract.new }
68
+ subject { IB::Contract.new }
58
69
 
59
70
  its(:summary) { should == subject }
60
71
  its(:under_con_id) { should == 0 }
@@ -68,7 +79,7 @@ describe IB::Models::Contract do
68
79
  end
69
80
 
70
81
  context 'with properties' do
71
- subject { IB::Models::Contract.new detailed_properties }
82
+ subject { IB::Contract.new detailed_properties }
72
83
 
73
84
  its(:summary) { should == subject }
74
85
  its(:created_at) { should be_a Time }
@@ -83,7 +94,7 @@ describe IB::Models::Contract do
83
94
 
84
95
  it 'allows setting attributes' do
85
96
  expect {
86
- x = IB::Models::Contract.new
97
+ x = IB::Contract.new
87
98
  properties.each do |name, value|
88
99
  subject.send("#{name}=", value)
89
100
  subject.send(name).should == value
@@ -94,7 +105,7 @@ describe IB::Models::Contract do
94
105
  end
95
106
 
96
107
  it 'allows setting ContractDetails attributes' do
97
- x = IB::Models::Contract.new
108
+ x = IB::Contract.new
98
109
  expect {
99
110
  x.callable = true
100
111
  x.puttable = true
@@ -113,53 +124,53 @@ describe IB::Models::Contract do
113
124
  end
114
125
 
115
126
  it 'converts multiplier to int' do
116
- expect { @contract = IB::Models::Contract.new(:multiplier => '123') }.to_not raise_error
127
+ expect { @contract = IB::Contract.new(:multiplier => '123') }.to_not raise_error
117
128
  expect { @contract.multiplier = '123' }.to_not raise_error
118
129
  @contract.multiplier.should == 123
119
130
  end
120
131
 
121
132
  it 'raises on wrong security type' do
122
- expect { IB::Models::Contract.new(:sec_type => "asdf") }.to raise_error ArgumentError
133
+ expect { IB::Contract.new(:sec_type => "asdf") }.to raise_error ArgumentError
123
134
 
124
- expect { IB::Models::Contract.new.sec_type = "asdf" }.to raise_error ArgumentError
135
+ expect { IB::Contract.new.sec_type = "asdf" }.to raise_error ArgumentError
125
136
  end
126
137
 
127
138
  it 'accepts pre-determined security types' do
128
139
  IB::SECURITY_TYPES.values.each do |type|
129
- expect { IB::Models::Contract.new(:sec_type => type) }.to_not raise_error
140
+ expect { IB::Contract.new(:sec_type => type) }.to_not raise_error
130
141
 
131
- expect { IB::Models::Contract.new.sec_type = type }.to_not raise_error
142
+ expect { IB::Contract.new.sec_type = type }.to_not raise_error
132
143
  end
133
144
  end
134
145
 
135
146
  it 'raises on wrong expiry' do
136
- expect { IB::Models::Contract.new(:expiry => "foo") }.to raise_error ArgumentError
147
+ expect { IB::Contract.new(:expiry => "foo") }.to raise_error ArgumentError
137
148
 
138
- expect { IB::Models::Contract.new.expiry = "foo" }.to raise_error ArgumentError
149
+ expect { IB::Contract.new.expiry = "foo" }.to raise_error ArgumentError
139
150
  end
140
151
 
141
152
  it 'accepts correct expiry' do
142
- expect { IB::Models::Contract.new(:expiry => "200607") }.to_not raise_error
153
+ expect { IB::Contract.new(:expiry => "200607") }.to_not raise_error
143
154
 
144
- expect { IB::Models::Contract.new.expiry = "200607" }.to_not raise_error
155
+ expect { IB::Contract.new.expiry = "200607" }.to_not raise_error
145
156
 
146
- expect { IB::Models::Contract.new(:expiry => 200607) }.to_not raise_error
157
+ expect { IB::Contract.new(:expiry => 200607) }.to_not raise_error
147
158
 
148
159
  expect {
149
- x = IB::Models::Contract.new
160
+ x = IB::Contract.new
150
161
  x.expiry = 200607
151
162
  x.expiry.should == "200607" # converted to a string
152
163
  }.to_not raise_error
153
164
  end
154
165
 
155
166
  it 'raises on incorrect right (option type)' do
156
- expect { IB::Models::Contract.new(:right => "foo") }.to raise_error ArgumentError
157
- expect { IB::Models::Contract.new.right = "foo" }.to raise_error ArgumentError
167
+ expect { IB::Contract.new(:right => "foo") }.to raise_error ArgumentError
168
+ expect { IB::Contract.new.right = "foo" }.to raise_error ArgumentError
158
169
  end
159
170
 
160
171
  it 'accepts all correct values for right (option type)' do
161
172
  ["PUT", "put", "P", "p"].each do |right|
162
- expect { @contract = IB::Models::Contract.new(:right => right) }.to_not raise_error
173
+ expect { @contract = IB::Contract.new(:right => right) }.to_not raise_error
163
174
  @contract.right.should == "PUT"
164
175
 
165
176
  expect { @contract.right = right }.to_not raise_error
@@ -167,7 +178,7 @@ describe IB::Models::Contract do
167
178
  end
168
179
 
169
180
  ["CALL", "call", "C", "c"].each do |right|
170
- expect { @contract = IB::Models::Contract.new(:right => right) }.to_not raise_error
181
+ expect { @contract = IB::Contract.new(:right => right) }.to_not raise_error
171
182
  @contract.right.should == "CALL"
172
183
 
173
184
  expect { @contract.right = right }.to_not raise_error
@@ -177,7 +188,7 @@ describe IB::Models::Contract do
177
188
  end #instantiation
178
189
 
179
190
  context "serialization" do
180
- subject { IB::Models::Contract.new properties }
191
+ subject { IB::Contract.new properties }
181
192
 
182
193
  it "serializes long" do
183
194
  subject.serialize_long.should ==
@@ -191,15 +202,15 @@ describe IB::Models::Contract do
191
202
  end #serialization
192
203
 
193
204
  context 'equality' do
194
- subject { IB::Models::Contract.new properties }
205
+ subject { IB::Contract.new properties }
195
206
 
196
207
  it 'be self-equal ' do
197
208
  should == subject
198
209
  end
199
210
 
200
211
  it 'be equal to object with the same properties' do
201
- should == IB::Models::Contract.new(properties)
212
+ should == IB::Contract.new(properties)
202
213
  end
203
214
  end
204
215
 
205
- end # describe IB::Models::Contract
216
+ end # describe IB::Contract
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe IB::Models::Execution do
3
+ describe IB::Models::Execution do # AKA IB::Execution
4
4
 
5
5
  let(:properties) do
6
6
  {:account_name => "DU111110",
@@ -21,7 +21,7 @@ describe IB::Models::Execution do
21
21
 
22
22
  context "instantiation" do
23
23
  context 'empty without properties' do
24
- subject { IB::Models::Execution.new }
24
+ subject { IB::Execution.new }
25
25
 
26
26
  it { should_not be_nil }
27
27
  its(:order_id) { should == 0 }
@@ -34,7 +34,7 @@ describe IB::Models::Execution do
34
34
  end
35
35
 
36
36
  context 'with properties' do
37
- subject { IB::Models::Execution.new properties }
37
+ subject { IB::Execution.new properties }
38
38
 
39
39
  it 'sets properties right' do
40
40
  properties.each do |name, value|
@@ -48,7 +48,7 @@ describe IB::Models::Execution do
48
48
 
49
49
  it 'allows setting properties' do
50
50
  expect {
51
- x = IB::Models::Execution.new
51
+ x = IB::Execution.new
52
52
  properties.each do |name, value|
53
53
  subject.send("#{name}=", value)
54
54
  subject.send(name).should == value
@@ -57,7 +57,7 @@ describe IB::Models::Execution do
57
57
  end
58
58
 
59
59
  it 'sets side as directed by its setter' do
60
- @x = IB::Models::Execution.new
60
+ @x = IB::Execution.new
61
61
  ['BOT', 'BUY', 'Buy', 'buy', :BUY, :BOT, :Buy, :buy, 'B', :b].each do |val|
62
62
  expect { @x.side = val }.to_not raise_error
63
63
  @x.side.should == :buy
@@ -5,7 +5,7 @@ describe IB::Models::Order do
5
5
  let(:properties) do
6
6
  {:outside_rth => true,
7
7
  :open_close => 'C',
8
- :origin => IB::Models::Order::Origin_Firm,
8
+ :origin => IB::Order::Origin_Firm,
9
9
  :transmit => false,
10
10
  :designated_location => "WHATEVER",
11
11
  :exempt_code => 123,
@@ -16,12 +16,12 @@ describe IB::Models::Order do
16
16
 
17
17
  context "instantiation" do
18
18
  context 'empty without properties' do
19
- subject { IB::Models::Order.new }
19
+ subject { IB::Order.new }
20
20
 
21
21
  it { should_not be_nil }
22
22
  its(:outside_rth) { should == false }
23
23
  its(:open_close) { should == "O" }
24
- its(:origin) { should == IB::Models::Order::Origin_Customer }
24
+ its(:origin) { should == IB::Order::Origin_Customer }
25
25
  its(:transmit) { should == true }
26
26
  its(:designated_location) { should == '' }
27
27
  its(:exempt_code) { should == -1 }
@@ -32,7 +32,7 @@ describe IB::Models::Order do
32
32
  end
33
33
 
34
34
  context 'with properties' do
35
- subject { IB::Models::Order.new properties }
35
+ subject { IB::Order.new properties }
36
36
 
37
37
  it 'sets properties right' do
38
38
  properties.each do |name, value|
@@ -46,7 +46,7 @@ describe IB::Models::Order do
46
46
  end
47
47
 
48
48
  it 'allows setting attributes' do
49
- x = IB::Models::Order.new
49
+ x = IB::Order.new
50
50
  properties.each do |name, value|
51
51
  subject.send("#{name}=", value)
52
52
  subject.send(name).should == value
@@ -55,22 +55,22 @@ describe IB::Models::Order do
55
55
  end #instantiation
56
56
 
57
57
  context 'equality' do
58
- subject { IB::Models::Order.new properties }
58
+ subject { IB::Order.new properties }
59
59
 
60
60
  it 'is self-equal ' do
61
61
  should == subject
62
62
  end
63
63
 
64
64
  it 'is equal to Order with the same properties' do
65
- should == IB::Models::Order.new(properties)
65
+ should == IB::Order.new(properties)
66
66
  end
67
67
 
68
68
  it 'is not equal for Orders with different limit price' do
69
- order1 = IB::Models::Order.new :total_quantity => 100,
69
+ order1 = IB::Order.new :total_quantity => 100,
70
70
  :limit_price => 1,
71
71
  :action => 'BUY'
72
72
 
73
- order2 = IB::Models::Order.new :total_quantity => 100,
73
+ order2 = IB::Order.new :total_quantity => 100,
74
74
  :limit_price => 2,
75
75
  :action => 'BUY'
76
76
  order1.should_not == order2
@@ -78,11 +78,11 @@ describe IB::Models::Order do
78
78
  end
79
79
 
80
80
  it 'is not equal for Orders with different total_quantity' do
81
- order1 = IB::Models::Order.new :total_quantity => 20000,
81
+ order1 = IB::Order.new :total_quantity => 20000,
82
82
  :limit_price => 1,
83
83
  :action => 'BUY'
84
84
 
85
- order2 = IB::Models::Order.new :total_quantity => 100,
85
+ order2 = IB::Order.new :total_quantity => 100,
86
86
  :action => 'BUY',
87
87
  :limit_price => 1
88
88
  order1.should_not == order2
@@ -90,11 +90,11 @@ describe IB::Models::Order do
90
90
  end
91
91
 
92
92
  it 'is not equal for Orders with different action/side' do
93
- order1 = IB::Models::Order.new :total_quantity => 100,
93
+ order1 = IB::Order.new :total_quantity => 100,
94
94
  :limit_price => 1,
95
95
  :action => 'SELL'
96
96
 
97
- order2 = IB::Models::Order.new :total_quantity => 100,
97
+ order2 = IB::Order.new :total_quantity => 100,
98
98
  :action => 'BUY',
99
99
  :limit_price => 1
100
100
  order1.should_not == order2
@@ -102,12 +102,12 @@ describe IB::Models::Order do
102
102
  end
103
103
 
104
104
  it 'is not equal for Orders with different order_type' do
105
- order1 = IB::Models::Order.new :total_quantity => 100,
105
+ order1 = IB::Order.new :total_quantity => 100,
106
106
  :limit_price => 1,
107
107
  :action => 'BUY',
108
108
  :order_type => 'LMT'
109
109
 
110
- order2 = IB::Models::Order.new :total_quantity => 100,
110
+ order2 = IB::Order.new :total_quantity => 100,
111
111
  :action => 'BUY',
112
112
  :limit_price => 1,
113
113
  :order_type => 'MKT'
@@ -116,4 +116,4 @@ describe IB::Models::Order do
116
116
  end
117
117
  end
118
118
 
119
- end # describe IB::Models::Order
119
+ end # describe IB::Order