ib-ruby 0.5.18 → 0.5.19

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.
@@ -19,16 +19,16 @@ describe IB::Models::Order do
19
19
  subject { IB::Models::Order.new }
20
20
 
21
21
  it { should_not be_nil }
22
- its(:outside_rth) {should == false}
23
- its(:open_close) {should == "O"}
24
- its(:origin) {should == IB::Models::Order::Origin_Customer}
25
- its(:transmit) {should == true}
26
- its(:designated_location) {should == ''}
27
- its(:exempt_code) {should == -1}
28
- its(:delta_neutral_order_type) {should == ''}
29
- its(:what_if) {should == false}
30
- its(:not_held) {should == false}
31
- its(:created_at) {should be_a Time}
22
+ its(:outside_rth) { should == false }
23
+ its(:open_close) { should == "O" }
24
+ its(:origin) { should == IB::Models::Order::Origin_Customer }
25
+ its(:transmit) { should == true }
26
+ its(:designated_location) { should == '' }
27
+ its(:exempt_code) { should == -1 }
28
+ its(:delta_neutral_order_type) { should == '' }
29
+ its(:what_if) { should == false }
30
+ its(:not_held) { should == false }
31
+ its(:created_at) { should be_a Time }
32
32
  end
33
33
 
34
34
  context 'with properties' do
@@ -41,13 +41,13 @@ describe IB::Models::Order do
41
41
  end
42
42
 
43
43
  context 'essential properties are still set, even if not given explicitely' do
44
- its(:created_at) {should be_a Time}
44
+ its(:created_at) { should be_a Time }
45
45
  end
46
46
  end
47
47
 
48
48
  it 'allows setting attributes' do
49
+ x = IB::Models::Order.new
49
50
  expect {
50
- x = IB::Models::Order.new
51
51
  x.outside_rth = true
52
52
  x.open_close = 'C'
53
53
  x.origin = IB::Models::Order::Origin_Firm
@@ -58,7 +58,29 @@ describe IB::Models::Order do
58
58
  x.what_if = true
59
59
  x.not_held = true
60
60
  }.to_not raise_error
61
+
62
+ x.outside_rth.should == true
63
+ x.open_close.should == 'C'
64
+ x.origin.should == IB::Models::Order::Origin_Firm
65
+ x.transmit.should == false
66
+ x.designated_location.should == "WHATEVER"
67
+ x.exempt_code.should == 123
68
+ x.delta_neutral_order_type.should == "HACK"
69
+ x.what_if.should == true
70
+ x.not_held.should == true
61
71
  end
62
72
  end #instantiation
63
73
 
74
+ context 'equality' do
75
+ subject { IB::Models::Order.new properties }
76
+
77
+ it 'be self-equal ' do
78
+ should == subject
79
+ end
80
+
81
+ it 'be equal to Order with the same properties' do
82
+ should == IB::Models::Order.new(properties)
83
+ end
84
+ end
85
+
64
86
  end # describe IB::Models::Order
@@ -64,10 +64,20 @@ def connect_and_receive *message_types
64
64
  @ib.start_reader
65
65
  end
66
66
 
67
+ # Clear logs and message collector. Output may be silenced
68
+ def clean_connection
69
+ unless SILENT
70
+ puts @received.map { |type, msg| [" #{type}:", msg.map(&:to_human)] }
71
+ puts " Logs:"
72
+ puts log_entries
73
+ end
74
+ @stdout.string = '' if @stdout
75
+ @received.clear if @received
76
+ end
77
+
67
78
  def close_connection
68
79
  @ib.close if @ib
69
- puts log_entries
70
- p @received.map { |type, msg| [type, msg.size] }
80
+ clean_connection
71
81
  end
72
82
 
73
83
  #noinspection RubyArgCount
@@ -75,3 +85,7 @@ def wait_for time = 1, &condition
75
85
  timeout = Time.now + time
76
86
  sleep 0.1 until timeout < Time.now || condition && condition.call
77
87
  end
88
+
89
+ def received? symbol
90
+ not @received[symbol].empty?
91
+ end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,20 @@ RSpec.configure do |config|
10
10
  # config.mock_with :rr
11
11
  end
12
12
 
13
+ puts
14
+ puts 'WARNING: MAKE SURE TO RUN ALL YOUR TESTS AGAINST IB PAPER ACCOUNT ONLY!'
15
+ puts 'WARNING: FINANCIAL LOSSES MAY RESULT IF YOU RUN TESTS WITH REAL IB ACCOUNT!'
16
+ puts 'WARNING: YOU HAVE BEEN WARNED!'
17
+ puts
18
+ puts 'Configure your connection to IB PAPER ACCOUNT in spec/spec_helper.rb'
19
+ puts
20
+
21
+ # Please uncomment next line if you are REALLY sure you have properly configured
22
+ # Connection to IB PAPER ACCOUNT or mock (Brokertron) account
23
+ #exit
24
+
25
+ SILENT = false #true
26
+
13
27
  BROKERTRON = false
14
28
 
15
29
  CONNECTION_OPTS = BROKERTRON ?
@@ -18,6 +32,7 @@ CONNECTION_OPTS = BROKERTRON ?
18
32
  :port=> 10501
19
33
  } :
20
34
  {:client_id => 1111,
21
- :host => '127.0.0.1',
35
+ :host => '10.211.55.2', # localhost?
22
36
  :port=> 4001
23
37
  }
38
+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ib-ruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.18
5
+ version: 0.5.19
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-02-15 00:00:00 Z
14
+ date: 2012-02-23 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -49,7 +49,7 @@ dependencies:
49
49
  description: Ruby Implementation of the Interactive Brokers TWS API
50
50
  email:
51
51
  - pjlegato@gmail.com
52
- - arvitallian@gmail.com
52
+ - arvicco@gmail.com
53
53
  executables:
54
54
  - account_info
55
55
  - cancel_orders
@@ -110,6 +110,8 @@ files:
110
110
  - spec/ib-ruby/messages/account_info_spec.rb
111
111
  - spec/ib-ruby/messages/just_connect_spec.rb
112
112
  - spec/ib-ruby/messages/market_data_spec.rb
113
+ - spec/ib-ruby/messages/open_order
114
+ - spec/ib-ruby/messages/orders_spec.rb
113
115
  - spec/ib-ruby/messages/README.md
114
116
  - spec/ib-ruby/models/combo_leg_spec.rb
115
117
  - spec/ib-ruby/models/contract_spec.rb
@@ -162,6 +164,8 @@ test_files:
162
164
  - spec/ib-ruby/messages/account_info_spec.rb
163
165
  - spec/ib-ruby/messages/just_connect_spec.rb
164
166
  - spec/ib-ruby/messages/market_data_spec.rb
167
+ - spec/ib-ruby/messages/open_order
168
+ - spec/ib-ruby/messages/orders_spec.rb
165
169
  - spec/ib-ruby/messages/README.md
166
170
  - spec/ib-ruby/models/combo_leg_spec.rb
167
171
  - spec/ib-ruby/models/contract_spec.rb