ib-ruby 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/bin/scaffold.rb +2 -2
- data/lib/ib/flex.rb +2 -2
- data/lib/ib/messages/incoming/real_time_bar.rb +2 -2
- data/lib/ib/messages/outgoing.rb +15 -7
- data/lib/ib/messages/outgoing/bar_requests.rb +25 -6
- metadata +2 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Ruby Implementation of the Interactive Brokers Trader Workstation (TWS) API v.965-967.
|
4
4
|
|
5
|
-
Copyright (C) 2006-
|
5
|
+
Copyright (C) 2006-2013 Paul Legato, Wes Devauld, and Ar Vicco.
|
6
6
|
|
7
7
|
https://github.com/ib-ruby/ib-ruby
|
8
8
|
|
@@ -212,7 +212,7 @@ If you want to contribute to ib-ruby development:
|
|
212
212
|
8. Push to the branch (git push origin my-new-feature)
|
213
213
|
9. Go to your Github fork and create new Pull Request via Github GUI
|
214
214
|
|
215
|
-
... then proceed from step
|
215
|
+
... then proceed from step 5 for more code modifications...
|
216
216
|
|
217
217
|
## LICENSE:
|
218
218
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.2
|
data/bin/scaffold.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# This script converts
|
3
|
+
# This dev helper script converts any migration file into a Rails scaffold command
|
4
4
|
|
5
5
|
output = STDOUT
|
6
6
|
ARGV.each do |file_name|
|
@@ -19,7 +19,7 @@ ARGV.each do |file_name|
|
|
19
19
|
field, type = Regexp.last_match(2), Regexp.last_match(1)
|
20
20
|
if type == 'references'
|
21
21
|
field, type = field + '_id', 'integer'
|
22
|
-
end
|
22
|
+
end
|
23
23
|
output.print "#{field}:#{type} "
|
24
24
|
end
|
25
25
|
end
|
data/lib/ib/flex.rb
CHANGED
@@ -25,7 +25,7 @@ module IB
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
# Create new Flex query with options:
|
28
|
+
# Create new Flex query with options:
|
29
29
|
# :token => 1111111111111111111111111111111111 # CHANGE to your actual token!
|
30
30
|
# :query_id => 11111 # CHANGE to actual query id!
|
31
31
|
# :format => :xml (default) / :csv
|
@@ -55,7 +55,7 @@ module IB
|
|
55
55
|
:text_ok => @format != :xml)
|
56
56
|
|
57
57
|
# If Status is specified, returned xml contains only error message, not actual report
|
58
|
-
if report.is_a?(Hash) && report['Status']
|
58
|
+
if report.is_a?(Hash) && report['Status'] =~ /Fail|Warn/
|
59
59
|
error_code = report['ErrorCode'].to_i
|
60
60
|
error_message = "#{error_code}: #{report['ErrorMessage']}"
|
61
61
|
|
@@ -7,7 +7,7 @@ module IB
|
|
7
7
|
# :time - The date-time stamp of the start of the bar. The format is offset in
|
8
8
|
# seconds from the beginning of 1970, same format as the UNIX epoch time
|
9
9
|
# :bar - received RT Bar
|
10
|
-
RealTimeBar = def_message 50,
|
10
|
+
RealTimeBar = def_message [50, 3],
|
11
11
|
[:request_id, :int],
|
12
12
|
[:bar, :time, :int],
|
13
13
|
[:bar, :open, :decimal],
|
@@ -23,7 +23,7 @@ module IB
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_human
|
26
|
-
"<RealTimeBar: #{request_id} #{
|
26
|
+
"<RealTimeBar: #{request_id} #{bar}>"
|
27
27
|
end
|
28
28
|
end # RealTimeBar
|
29
29
|
|
data/lib/ib/messages/outgoing.rb
CHANGED
@@ -14,16 +14,28 @@ module IB
|
|
14
14
|
## Empty messages (no data)
|
15
15
|
|
16
16
|
# Request the open orders that were placed from THIS client. Each open order
|
17
|
-
# will be fed back through the OpenOrder and OrderStatus messages.
|
17
|
+
# will be fed back through the OpenOrder and OrderStatus messages ONCE.
|
18
18
|
# NB: Client with a client_id of 0 will also receive the TWS-owned open orders.
|
19
19
|
# These orders will be associated with the client and a new orderId will be
|
20
20
|
# generated. This association will persist over multiple API and TWS sessions.
|
21
21
|
RequestOpenOrders = def_message 5
|
22
22
|
|
23
23
|
# Request the open orders placed from all clients and also from TWS. Each open
|
24
|
-
# order will be fed back through the OpenOrder and OrderStatus messages.
|
24
|
+
# order will be fed back through the OpenOrder and OrderStatus messages ONCE.
|
25
|
+
# Note this does not re-bind those Orders to requesting Client!
|
26
|
+
# Use RequestAutoOpenOrders to request such re-binding.
|
25
27
|
RequestAllOpenOrders = def_message 16
|
26
28
|
|
29
|
+
# Request that newly created TWS orders be implicitly associated with this client.
|
30
|
+
# When a new TWS order is created, the order will be associated with this client
|
31
|
+
# and automatically fed back through the OpenOrder and OrderStatus messages.
|
32
|
+
# It is a 'continuous' request such that it gets turned 'on' when called with a
|
33
|
+
# TRUE auto_bind parameter. When it's called with FALSE auto_bind, new TWS orders
|
34
|
+
# will not bind to this client going forward. Note that TWS orders can only be
|
35
|
+
# bound to clients with a client_id of 0. TODO: how to properly test this?
|
36
|
+
# data = { :auto_bind => boolean }
|
37
|
+
RequestAutoOpenOrders = def_message 15, :auto_bind
|
38
|
+
|
27
39
|
# Requests an XML document that describes the valid parameters that a scanner
|
28
40
|
# subscription can have (for outgoing RequestScannerSubscription message).
|
29
41
|
RequestScannerParameters = def_message 24
|
@@ -48,8 +60,6 @@ module IB
|
|
48
60
|
## Data format is: @data ={ :id => local_id of order to cancel }
|
49
61
|
CancelOrder = def_message 4
|
50
62
|
|
51
|
-
## These messages contain just one or two extra fields:
|
52
|
-
|
53
63
|
# Request the next valid ID that can be used when placing an order. Responds with
|
54
64
|
# NextValidId message, and the id returned is that next valid Id for orders.
|
55
65
|
# That ID will reflect any autobinding that has occurred (which generates new
|
@@ -60,8 +70,6 @@ module IB
|
|
60
70
|
RequestNewsBulletins = def_message 12, :all_messages
|
61
71
|
# data = { :log_level => int }
|
62
72
|
SetServerLoglevel = def_message 14, :log_level
|
63
|
-
# data = { :auto_bind => boolean }
|
64
|
-
RequestAutoOpenOrders = def_message 15, :auto_bind
|
65
73
|
# data = { :fa_data_type => int }
|
66
74
|
RequestFA = def_message 18, :fa_data_type
|
67
75
|
# data = { :fa_data_type => int, :xml => String }
|
@@ -75,7 +83,7 @@ module IB
|
|
75
83
|
:account_code)
|
76
84
|
|
77
85
|
# data => { :id => request_id (int), :contract => Contract }
|
78
|
-
#
|
86
|
+
#
|
79
87
|
# Special case for options: "wildcards" in the Contract fields retrieve Option chains
|
80
88
|
# strike = 0 means all strikes
|
81
89
|
# right = "" meanns both call and put
|
@@ -13,16 +13,16 @@ module IB
|
|
13
13
|
error ":data_type must be one of #{DATA_TYPES.inspect}", :args
|
14
14
|
end
|
15
15
|
|
16
|
-
size = data[:bar_size] || data[:size]
|
17
|
-
bar_size = BAR_SIZES.invert[size] || size
|
18
|
-
unless BAR_SIZES.keys.include?(bar_size)
|
19
|
-
error ":bar_size must be one of #{BAR_SIZES.inspect}", :args
|
20
|
-
end
|
16
|
+
#size = data[:bar_size] || data[:size]
|
17
|
+
#bar_size = BAR_SIZES.invert[size] || size
|
18
|
+
# unless BAR_SIZES.keys.include?(bar_size)
|
19
|
+
# error ":bar_size must be one of #{BAR_SIZES.inspect}", :args
|
20
|
+
# end
|
21
21
|
|
22
22
|
contract = data[:contract].is_a?(IB::Contract) ?
|
23
23
|
data[:contract] : IB::Contract.from_ib_ruby(data[:contract])
|
24
24
|
|
25
|
-
[data_type,
|
25
|
+
[data_type, nil, contract]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -44,6 +44,14 @@ module IB
|
|
44
44
|
RequestRealTimeBars = def_message 50, BarRequestMessage
|
45
45
|
|
46
46
|
class RequestRealTimeBars
|
47
|
+
def parse data
|
48
|
+
data_type, bar_size, contract = super data
|
49
|
+
|
50
|
+
size = data[:bar_size] || data[:size]
|
51
|
+
bar_size = size.to_i
|
52
|
+
[data_type, bar_size, contract]
|
53
|
+
end
|
54
|
+
|
47
55
|
def encode
|
48
56
|
data_type, bar_size, contract = parse @data
|
49
57
|
|
@@ -150,6 +158,17 @@ module IB
|
|
150
158
|
RequestHistoricalData = def_message [20, 4], BarRequestMessage
|
151
159
|
|
152
160
|
class RequestHistoricalData
|
161
|
+
def parse data
|
162
|
+
data_type, bar_size, contract = super data
|
163
|
+
|
164
|
+
size = data[:bar_size] || data[:size]
|
165
|
+
bar_size = BAR_SIZES.invert[size] || size
|
166
|
+
unless BAR_SIZES.keys.include?(bar_size)
|
167
|
+
error ":bar_size must be one of #{BAR_SIZES.inspect}", :args
|
168
|
+
end
|
169
|
+
[data_type, bar_size, contract]
|
170
|
+
end
|
171
|
+
|
153
172
|
def encode
|
154
173
|
data_type, bar_size, contract = parse @data
|
155
174
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ib-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Legato
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|