ib-ruby 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -194,7 +194,7 @@
194
194
 
195
195
  * Combo routing parameters and algo parameters supported
196
196
 
197
- == 0.8.3 / 2012-07-15
197
+ == 0.8.4 / 2012-07-18
198
198
 
199
- * Rails Engine integration
199
+ * Working Rails Engine integration
200
200
 
data/README.md CHANGED
@@ -145,7 +145,8 @@ if defined?(Bundler)
145
145
  Now run:
146
146
 
147
147
  $ bundle install
148
- $ rake ib_engine:install:migrations
148
+ $ rake ib:install:migrations
149
+ $ rake db:migrate
149
150
 
150
151
  This will install ib-ruby gem and copy its migrations into your Rails apps migrations.
151
152
 
@@ -177,6 +178,13 @@ The gem comes with a spec suit that may be used to test ib-ruby compatibility wi
177
178
  specific TWS/Gateway installation. Please read 'spec/Readme.md' for more details about
178
179
  running specs.
179
180
 
181
+ ## RUBY VERSION COMPATIBILITY:
182
+
183
+ The library is continuously tested with JRuby 1.6.7 (ruby-1.8.7-p357-compatible mode) and
184
+ JRuby head (ruby-1.9.3-p203-compatible mode). It is not JRuby-specific though, as it is currently used in a some MRI Ruby based projects. If there are any problems in any mode
185
+ for either JRuby or MRI, please report an [issue](https://github.com/ib-ruby/ib-ruby/issues/new)
186
+ and we will work on it.
187
+
180
188
  ## CONTRIBUTING:
181
189
 
182
190
  1. Fork it
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.3
1
+ 0.8.4
@@ -1,5 +1,23 @@
1
+ # These modules are used to facilitate referencing of most popular IB Contracts.
2
+ # For example, suppose you're explicitely creating such Contract in all your scripts:
3
+ # wfc = IB::Contract.new(:symbol => "WFC",
4
+ # :exchange => "NYSE",
5
+ # :currency => "USD",
6
+ # :sec_type => :stock,
7
+ # :description => "Wells Fargo Stock"),
8
+ #
9
+ # Instead, you can put this contract definition into 'ib/symbols/stocks' and just reference
10
+ # it as IB::Symbols::Stock[:wfc] anywhere you need it.
11
+ #
12
+ # Note that the :description field is local to ib-ruby, and is NOT part of the standard TWS API.
13
+ # It is never transmitted to IB. It's purely used clientside, and you can store any arbitrary
14
+ # string that you may find useful there.
15
+
1
16
  module IB
2
17
  module Symbols
18
+ def [] symbol
19
+ contracts[symbol]
20
+ end
3
21
  end
4
22
  end
5
23
 
@@ -1,71 +1,74 @@
1
- # Note that the :description field is particular to ib, and is NOT part of the
2
- # standard TWS API. It is never transmitted to IB. It's purely used clientside, and
3
- # you can store any arbitrary string that you may find useful there.
4
1
  module IB
5
2
  module Symbols
6
- # IDEALPRO is for orders over 25,000 and routes to the interbank quote stream.
7
- # IDEAL is for smaller orders, and has wider spreads/slower execution... generally
8
- # used for smaller currency conversions.
9
- Forex = {
10
- :audusd => IB::Contract.new(:symbol => "AUD",
11
- :exchange => "IDEALPRO",
12
- :currency => "USD",
13
- :sec_type => :forex,
14
- :description => "AUDUSD"),
3
+ module Forex
4
+ extend Symbols
15
5
 
16
- :gbpusd => IB::Contract.new(:symbol => "GBP",
17
- :exchange => "IDEALPRO",
18
- :currency => "USD",
19
- :sec_type => :forex,
20
- :description => "GBPUSD"),
6
+ # IDEALPRO is for orders over 25,000 and routes to the interbank quote stream.
7
+ # IDEAL is for smaller orders, and has wider spreads/slower execution... generally
8
+ # used for smaller currency conversions.
9
+ def self.contracts
10
+ @contracts ||= {
11
+ :audusd => IB::Contract.new(:symbol => "AUD",
12
+ :exchange => "IDEALPRO",
13
+ :currency => "USD",
14
+ :sec_type => :forex,
15
+ :description => "AUDUSD"),
21
16
 
22
- :euraud => IB::Contract.new(:symbol => "EUR",
23
- :exchange => "IDEALPRO",
24
- :currency => "AUD",
25
- :sec_type => :forex,
26
- :description => "EURAUD"),
17
+ :gbpusd => IB::Contract.new(:symbol => "GBP",
18
+ :exchange => "IDEALPRO",
19
+ :currency => "USD",
20
+ :sec_type => :forex,
21
+ :description => "GBPUSD"),
27
22
 
28
- :eurgbp => IB::Contract.new(:symbol => "EUR",
29
- :exchange => "IDEALPRO",
30
- :currency => "GBP",
31
- :sec_type => :forex,
32
- :description => "EURGBP"),
23
+ :euraud => IB::Contract.new(:symbol => "EUR",
24
+ :exchange => "IDEALPRO",
25
+ :currency => "AUD",
26
+ :sec_type => :forex,
27
+ :description => "EURAUD"),
33
28
 
34
- :eurjpy => IB::Contract.new(:symbol => "EUR",
35
- :exchange => "IDEALPRO",
36
- :currency => "JPY",
37
- :sec_type => :forex,
38
- :description => "EURJPY"),
29
+ :eurgbp => IB::Contract.new(:symbol => "EUR",
30
+ :exchange => "IDEALPRO",
31
+ :currency => "GBP",
32
+ :sec_type => :forex,
33
+ :description => "EURGBP"),
39
34
 
40
- :eurusd => IB::Contract.new(:symbol => "EUR",
41
- :exchange => "IDEALPRO",
42
- :currency => "USD",
43
- :sec_type => :forex,
44
- :description => "EURUSD"),
35
+ :eurjpy => IB::Contract.new(:symbol => "EUR",
36
+ :exchange => "IDEALPRO",
37
+ :currency => "JPY",
38
+ :sec_type => :forex,
39
+ :description => "EURJPY"),
45
40
 
46
- :eurcad => IB::Contract.new(:symbol => "EUR",
47
- :exchange => "IDEALPRO",
48
- :currency => "CAD",
49
- :sec_type => :forex,
50
- :description => "EURCAD"),
41
+ :eurusd => IB::Contract.new(:symbol => "EUR",
42
+ :exchange => "IDEALPRO",
43
+ :currency => "USD",
44
+ :sec_type => :forex,
45
+ :description => "EURUSD"),
51
46
 
52
- :usdchf => IB::Contract.new(:symbol => "USD",
53
- :exchange => "IDEALPRO",
54
- :currency => "CHF",
55
- :sec_type => :forex,
56
- :description => "USDCHF"),
47
+ :eurcad => IB::Contract.new(:symbol => "EUR",
48
+ :exchange => "IDEALPRO",
49
+ :currency => "CAD",
50
+ :sec_type => :forex,
51
+ :description => "EURCAD"),
57
52
 
58
- :usdcad => IB::Contract.new(:symbol => "USD",
59
- :exchange => "IDEALPRO",
60
- :currency => "CAD",
61
- :sec_type => :forex,
62
- :description => "USDCAD"),
53
+ :usdchf => IB::Contract.new(:symbol => "USD",
54
+ :exchange => "IDEALPRO",
55
+ :currency => "CHF",
56
+ :sec_type => :forex,
57
+ :description => "USDCHF"),
63
58
 
64
- :usdjpy => IB::Contract.new(:symbol => "USD",
65
- :exchange => "IDEALPRO",
66
- :currency => "JPY",
67
- :sec_type => :forex,
68
- :description => "USDJPY")
69
- }
59
+ :usdcad => IB::Contract.new(:symbol => "USD",
60
+ :exchange => "IDEALPRO",
61
+ :currency => "CAD",
62
+ :sec_type => :forex,
63
+ :description => "USDCAD"),
64
+
65
+ :usdjpy => IB::Contract.new(:symbol => "USD",
66
+ :exchange => "IDEALPRO",
67
+ :currency => "JPY",
68
+ :sec_type => :forex,
69
+ :description => "USDJPY")
70
+ }
71
+ end
72
+ end
70
73
  end
71
74
  end
@@ -1,113 +1,111 @@
1
- # The Futures constant is currently for testing purposes. It guesses the front month
2
- # currency future using a crude algorithm that does not take into account expiry/rollover day.
3
- # This will be valid most of the time, but near/after expiry day the next quarter's contract
4
- # takes over as the volume leader.
5
- #
6
- #
7
- # Note that the :description field is particular to ib, and is NOT part of the standard TWS API.
8
- # It is never transmitted to IB. It's purely used clientside, and you can store any arbitrary string that
9
- # you may find useful there.
10
- #
1
+ # The Futures module tries to guess the front month currency future using a crude algorithm
2
+ # that does not take into account expiry/rollover day. This will be valid most of the time,
3
+ # but near/after expiry day the next quarter's contract takes over as the volume leader.
11
4
 
12
5
  module IB
13
6
  module Symbols
7
+ module Futures
8
+ extend Symbols
9
+
10
+ # Find the next front month of quarterly futures.
11
+ #
12
+ # N.B. This will not work as expected during the front month before expiration, as
13
+ # it will point to the next quarter even though the current month is still valid!
14
+ def self.next_quarter_month time=Time.now
15
+ [3, 6, 9, 12].find { |month| month > time.month } || 3 # for December, next March
16
+ end
14
17
 
15
- # Find the next front month of quarterly futures.
16
- #
17
- # N.B. This will not work as expected during the front month before expiration, as
18
- # it will point to the next quarter even though the current month is still valid!
19
- def self.next_quarter_month time=Time.now
20
- [3, 6, 9, 12].find { |month| month > time.month } || 3 # for December, next March
21
- end
22
-
23
- def self.next_quarter_year time=Time.now
24
- next_quarter_month(time) < time.month ? time.year + 1 : time.year
25
- end
18
+ def self.next_quarter_year time=Time.now
19
+ next_quarter_month(time) < time.month ? time.year + 1 : time.year
20
+ end
26
21
 
27
- # WARNING: This is currently broken. It returns the next
28
- # quarterly expiration month after the current month. Many futures
29
- # instruments have monthly contracts for the near months. This
30
- # method will not work for such contracts; it will return the next
31
- # quarter after the current month, even though the present month
32
- # has the majority of the trading volume.
33
- #
34
- # For example, in early November of 2011, many contracts have the
35
- # vast majority of their volume in the Nov 2011 contract, but this
36
- # method will return the Dec 2011 contract instead.
37
- #
38
- def self.next_expiry time=Time.now
39
- "#{ next_quarter_year(time) }#{ sprintf("%02d", next_quarter_month(time)) }"
40
- end
22
+ # WARNING: This is currently broken. It returns the next
23
+ # quarterly expiration month after the current month. Many futures
24
+ # instruments have monthly contracts for the near months. This
25
+ # method will not work for such contracts; it will return the next
26
+ # quarter after the current month, even though the present month
27
+ # has the majority of the trading volume.
28
+ #
29
+ # For example, in early November of 2011, many contracts have the
30
+ # vast majority of their volume in the Nov 2011 contract, but this
31
+ # method will return the Dec 2011 contract instead.
32
+ #
33
+ def self.next_expiry time=Time.now
34
+ "#{ next_quarter_year(time) }#{ sprintf("%02d", next_quarter_month(time)) }"
35
+ end
41
36
 
42
- # Convenience method; generates an IB::Contract instance for a futures
43
- # contract with the given parameters.
44
- #
45
- # If expiry is nil, it will use the end month of the current
46
- # quarter. This will be wrong for most contracts most of the time,
47
- # since most contracts have the majority of their volume in a
48
- # nearby intraquarter month.
49
- #
50
- # It is recommended that you specify an expiration date manually
51
- # until next_expiry is fixed. Expiry should be a string in the
52
- # format "YYYYMM", where YYYY is the 4 digit year and MM is the 2
53
- # digit month. For example, November 2011 is "201111".
54
- #
55
- def self.future(base_symbol, exchange, currency, description="", expiry=nil)
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
- end
37
+ # Convenience method; generates an IB::Contract instance for a futures
38
+ # contract with the given parameters.
39
+ #
40
+ # If expiry is nil, it will use the end month of the current
41
+ # quarter. This will be wrong for most contracts most of the time,
42
+ # since most contracts have the majority of their volume in a
43
+ # nearby intraquarter month.
44
+ #
45
+ # It is recommended that you specify an expiration date manually
46
+ # until next_expiry is fixed. Expiry should be a string in the
47
+ # format "YYYYMM", where YYYY is the 4 digit year and MM is the 2
48
+ # digit month. For example, November 2011 is "201111".
49
+ #
50
+ def self.future(base_symbol, exchange, currency, description="", expiry=nil)
51
+ IB::Contract.new :symbol => base_symbol,
52
+ :expiry => expiry || next_expiry,
53
+ :exchange => exchange,
54
+ :currency => currency,
55
+ :sec_type => SECURITY_TYPES[:future],
56
+ :description => description
57
+ end
63
58
 
64
- Futures ={
65
- :ym => IB::Contract.new(:symbol => "YM",
66
- :expiry => next_expiry,
67
- :exchange => "ECBOT",
68
- :currency => "USD",
69
- :sec_type => :future,
70
- :description => "Mini Dow Jones Industrial"),
59
+ def self.contracts
60
+ @contracts ||= {
61
+ :ym => IB::Contract.new(:symbol => "YM",
62
+ :expiry => next_expiry,
63
+ :exchange => "ECBOT",
64
+ :currency => "USD",
65
+ :sec_type => :future,
66
+ :description => "Mini Dow Jones Industrial"),
71
67
 
72
- :es => IB::Contract.new(:symbol => "ES",
73
- :expiry => next_expiry,
74
- :exchange => "GLOBEX",
75
- :currency => "USD",
76
- :sec_type => :future,
77
- :multiplier => 50,
78
- :description => "E-Mini S&P 500"),
68
+ :es => IB::Contract.new(:symbol => "ES",
69
+ :expiry => next_expiry,
70
+ :exchange => "GLOBEX",
71
+ :currency => "USD",
72
+ :sec_type => :future,
73
+ :multiplier => 50,
74
+ :description => "E-Mini S&P 500"),
79
75
 
80
- :gbp => IB::Contract.new(:symbol => "GBP",
81
- :expiry => next_expiry,
82
- :exchange => "GLOBEX",
83
- :currency => "USD",
84
- :sec_type => :future,
85
- :multiplier => 62500,
86
- :description => "British Pounds"),
76
+ :gbp => IB::Contract.new(:symbol => "GBP",
77
+ :expiry => next_expiry,
78
+ :exchange => "GLOBEX",
79
+ :currency => "USD",
80
+ :sec_type => :future,
81
+ :multiplier => 62500,
82
+ :description => "British Pounds"),
87
83
 
88
- :eur => IB::Contract.new(:symbol => "EUR",
89
- :expiry => next_expiry,
90
- :exchange => "GLOBEX",
91
- :currency => "USD",
92
- :sec_type => :future,
93
- :multiplier => 12500,
94
- :description => "Euro FX"),
84
+ :eur => IB::Contract.new(:symbol => "EUR",
85
+ :expiry => next_expiry,
86
+ :exchange => "GLOBEX",
87
+ :currency => "USD",
88
+ :sec_type => :future,
89
+ :multiplier => 12500,
90
+ :description => "Euro FX"),
95
91
 
96
- :jpy => IB::Contract.new(:symbol => "JPY",
97
- :expiry => next_expiry,
98
- :exchange => "GLOBEX",
99
- :currency => "USD",
100
- :sec_type => :future,
101
- :multiplier => 12500000,
102
- :description => "Japanese Yen"),
92
+ :jpy => IB::Contract.new(:symbol => "JPY",
93
+ :expiry => next_expiry,
94
+ :exchange => "GLOBEX",
95
+ :currency => "USD",
96
+ :sec_type => :future,
97
+ :multiplier => 12500000,
98
+ :description => "Japanese Yen"),
103
99
 
104
- :hsi => IB::Contract.new(:symbol => "HSI",
105
- :expiry => next_expiry,
106
- :exchange => "HKFE",
107
- :currency => "HKD",
108
- :sec_type => :future,
109
- :multiplier => 50,
110
- :description => "Hang Seng Index")
111
- }
100
+ :hsi => IB::Contract.new(:symbol => "HSI",
101
+ :expiry => next_expiry,
102
+ :exchange => "HKFE",
103
+ :currency => "HKD",
104
+ :sec_type => :future,
105
+ :multiplier => 50,
106
+ :description => "Hang Seng Index")
107
+ }
108
+ end
109
+ end
112
110
  end
113
111
  end
@@ -1,36 +1,36 @@
1
- # Stock contracts definitions
2
- #
3
- # Note that the :description field is particular to ib, and is NOT part of the
4
- # standard TWS API. It is never transmitted to IB. It's purely used clientside, and
5
- # you can store any arbitrary string that you may find useful there.
6
-
1
+ # Option contracts definitions
7
2
  module IB
8
3
  module Symbols
4
+ module Options
5
+ extend Symbols
9
6
 
10
- Options =
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'),
7
+ def self.contracts
8
+ @contracts ||= {
9
+ :wfc20 => IB::Option.new(:symbol => "WFC",
10
+ :expiry => "201301",
11
+ :right => "CALL",
12
+ :strike => 20.0,
13
+ :description => "Wells Fargo 20 Call 2013-01"),
14
+ :aapl500 => IB::Option.new(:symbol => "AAPL",
15
+ :expiry => "201301",
16
+ :right => "CALL",
17
+ :strike => 500,
18
+ :description => "Apple 500 Call 2013-01"),
19
+ :z50 => IB::Option.new(:symbol => "Z",
20
+ :exchange => "LIFFE",
21
+ :expiry => "201206",
22
+ :right => "CALL",
23
+ :strike => 50.0,
24
+ :description => " FTSE-100 index 50 Call 2012-06"),
25
+ :spy75 => IB::Option.new(:symbol => 'SPY',
26
+ :expiry => "20120615",
27
+ :right => "P",
28
+ :currency => "USD",
29
+ :strike => 75.0,
30
+ :description => "SPY 75.0 Put 2012-06-16"),
31
+ :spy100 => IB::Option.new(:osi => 'SPY 121222P00100000'),
34
32
  }
33
+ end
34
+ end
35
35
  end
36
36
  end
@@ -1,29 +1,30 @@
1
1
  # Stock contracts definitions
2
- #
3
- # Note that the :description field is particular to ib, and is NOT part of the
4
- # standard TWS API. It is never transmitted to IB. It's purely used clientside, and
5
- # you can store any arbitrary string that you may find useful there.
6
-
7
2
  module IB
8
3
  module Symbols
4
+ module Stocks
5
+ extend Symbols
9
6
 
10
- Stocks =
11
- {:wfc => IB::Contract.new(:symbol => "WFC",
12
- :exchange => "NYSE",
13
- :currency => "USD",
14
- :sec_type => :stock,
15
- :description => "Wells Fargo"),
16
-
17
- :aapl => IB::Contract.new(:symbol => "AAPL",
7
+ def self.contracts
8
+ @contracts ||= {
9
+ :wfc => IB::Contract.new(:symbol => "WFC",
10
+ :exchange => "NYSE",
18
11
  :currency => "USD",
19
12
  :sec_type => :stock,
20
- :description => "Apple Inc."),
13
+ :description => "Wells Fargo"),
21
14
 
22
- :wrong => IB::Contract.new(:symbol => "QEEUUE",
23
- :exchange => "NYSE",
15
+ :aapl => IB::Contract.new(:symbol => "AAPL",
24
16
  :currency => "USD",
25
17
  :sec_type => :stock,
26
- :description => "Non-existent stock"),
18
+ :description => "Apple Inc."),
19
+
20
+ :wrong => IB::Contract.new(:symbol => "QEEUUE",
21
+ :exchange => "NYSE",
22
+ :currency => "USD",
23
+ :sec_type => :stock,
24
+ :description => "Non-existent stock"),
27
25
  }
26
+ end
27
+
28
+ end
28
29
  end
29
30
  end
@@ -33,15 +33,6 @@ switches (by default, TWS port is used):
33
33
  $ rspec -rgw [spec/specific_spec.rb]
34
34
  $ rspec -rtws [spec/specific_spec.rb]
35
35
 
36
- Some of the specs may randomly fail from time to time when you are running the spec suit
37
- against your IB paper account. This happens because these specs depend on live connection
38
- to IB, which is inherently non-deterministic. Anything happening along the way - network
39
- delay, problems with IB data farms, even high CPU load on your machine - may delay the
40
- expected responce, so that the spec times out or does not find expected data. It is
41
- suggested that you run the failing specs several times, and start debugging them only
42
- if they are failing regularly. Otherwise, you may just waste time chasing an artifact of
43
- unreliable IB connection, rather than some real problem with the specs.
44
-
45
36
  ## RUNNING RAILS-SPECIFIC SPECS:
46
37
 
47
38
  This gem has two operating modes: standalone and Rails-engine. If you require it in a
@@ -64,6 +55,21 @@ To run specs with Dummy Rails application, use:
64
55
 
65
56
  Other suit switches described in previous section should work with Rails as well.
66
57
 
58
+ ## PROBLEMS WHILE RUNNING THE SPECS:
59
+
60
+ Some of the specs may randomly fail from time to time when you are running the spec suit
61
+ against your IB paper account. This happens because these specs depend on live connection
62
+ to IB, which is inherently non-deterministic. Anything happening along the way - network
63
+ delay, problems with IB data farms, even high CPU load on your machine - may delay the
64
+ expected responce, so that the spec times out or does not find expected data. For example,
65
+ IB historical data farm is known to disappear from time to time, so any specs related to
66
+ historical data will fail while this outage lasts.
67
+
68
+ If you experience such intermittent spec failures, it is recommended that you run the
69
+ failing specs several times, possibly with a delay of 10-20 minutes. Start debugging
70
+ the specs only if they are failing regularly. Otherwise, you may just waste time chasing
71
+ an artifact of unreliable IB connection, rather than some real problem with the specs.
72
+
67
73
  # WRITING YOUR OWN INTEGRATION SPECS
68
74
 
69
75
  You can easily create your own integration specs. Pattern for writing specs is like this:
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe IB::Symbols do
4
+
5
+ it 'references pre-defined IB stock Contracts' do
6
+ wfc = IB::Symbols::Stocks[:wfc]
7
+ wfc.should be_an IB::Contract
8
+ wfc.sec_type.should == :stock
9
+ wfc.symbol.should == "WFC"
10
+ wfc.exchange.should == "NYSE"
11
+ wfc.currency.should == "USD"
12
+ wfc.description.should == "Wells Fargo"
13
+ end
14
+
15
+ it 'references pre-defined IB option Contracts' do
16
+ wfc = IB::Symbols::Options[:wfc20]
17
+ wfc.should be_an IB::Contract
18
+ wfc.sec_type.should == :option
19
+ wfc.symbol.should == "WFC"
20
+ wfc.expiry.should == "201301"
21
+ wfc.right.should == :call
22
+ wfc.strike.should == 20
23
+ wfc.description.should == "Wells Fargo 20 Call 2013-01"
24
+ end
25
+
26
+ it 'references pre-defined IB forex Contracts' do
27
+ fx = IB::Symbols::Forex[:gbpusd]
28
+ fx.should be_an IB::Contract
29
+ fx.sec_type.should == :forex
30
+ fx.symbol.should == "GBP"
31
+ fx.currency.should == "USD"
32
+ fx.exchange.should == "IDEALPRO"
33
+ fx.description.should == "GBPUSD"
34
+ end
35
+
36
+ it 'references pre-defined IB futures Contracts' do
37
+ fx = IB::Symbols::Futures[:gbp]
38
+ fx.should be_an IB::Contract
39
+ fx.expiry.should == IB::Symbols::Futures.next_expiry
40
+ fx.sec_type.should == :future
41
+ fx.symbol.should == "GBP"
42
+ fx.currency.should == "USD"
43
+ fx.multiplier.should == 62500
44
+ fx.exchange.should == "GLOBEX"
45
+ fx.description.should == "British Pounds"
46
+ end
47
+
48
+
49
+ end # describe IB::Symbols
@@ -184,7 +184,7 @@ describe "Request Contract Info", :connected => true, :integration => true do
184
184
 
185
185
  contract.symbol.should == 'YM'
186
186
  contract.local_symbol.should =~ /YM/
187
- contract.expiry.should =~ Regexp.new(IB::Symbols.next_expiry)
187
+ contract.expiry.should =~ Regexp.new(IB::Symbols::Futures.next_expiry)
188
188
  contract.exchange.should == 'ECBOT'
189
189
  contract.con_id.should be_an Integer
190
190
 
@@ -35,7 +35,7 @@ end
35
35
 
36
36
  RSpec.configure do |config|
37
37
 
38
- puts "Running specs '#{config.pattern}' with OPTS:"
38
+ puts "Running specs with OPTS:"
39
39
  pp OPTS
40
40
 
41
41
  # config.filter = { :focus => true }
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.3
5
+ version: 0.8.4
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-16 00:00:00 Z
14
+ date: 2012-07-18 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -322,6 +322,7 @@ files:
322
322
  - spec/ib/messages/incoming/order_status_spec.rb
323
323
  - spec/ib/messages/outgoing/account_data_spec.rb
324
324
  - spec/ib/messages/outgoing/market_data_type_spec.rb
325
+ - spec/ib/symbols/symbols_spec.rb
325
326
  - spec/integration/account_info_spec.rb
326
327
  - spec/integration/contract_info_spec.rb
327
328
  - spec/integration/depth_data_spec.rb
@@ -407,6 +408,7 @@ test_files:
407
408
  - spec/ib/messages/incoming/order_status_spec.rb
408
409
  - spec/ib/messages/outgoing/account_data_spec.rb
409
410
  - spec/ib/messages/outgoing/market_data_type_spec.rb
411
+ - spec/ib/symbols/symbols_spec.rb
410
412
  - spec/integration/account_info_spec.rb
411
413
  - spec/integration/contract_info_spec.rb
412
414
  - spec/integration/depth_data_spec.rb