ib-api 972.0 → 972.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +36 -37
- data/README.md +48 -3
- data/VERSION +1 -1
- data/api.gemspec +1 -1
- data/bin/console +4 -8
- data/changelog.md +12 -0
- data/lib/ib/base_properties.rb +3 -4
- data/lib/ib/connection.rb +18 -16
- data/lib/ib/logger.rb +1 -1
- data/lib/ib/messages/incoming.rb +1 -1
- data/lib/ib/messages/incoming/abstract_message.rb +7 -7
- data/lib/ib/messages/incoming/account_value.rb +5 -1
- data/lib/ib/messages/incoming/contract_data.rb +0 -2
- data/lib/ib/messages/incoming/historical_data.rb +25 -5
- data/lib/ib/messages/incoming/ticks.rb +21 -60
- data/lib/ib/messages/outgoing.rb +4 -2
- data/lib/ib/messages/outgoing/abstract_message.rb +3 -3
- data/lib/ib/messages/outgoing/bar_requests.rb +4 -5
- data/lib/ib/messages/outgoing/request_marketdata.rb +10 -7
- data/lib/ib/models.rb +1 -1
- data/lib/ib/support.rb +32 -15
- data/lib/logging.rb +45 -0
- data/lib/models/ib/account.rb +0 -13
- data/lib/models/ib/bag.rb +7 -1
- data/lib/models/ib/bar.rb +1 -1
- data/lib/models/ib/combo_leg.rb +22 -0
- data/lib/models/ib/contract.rb +44 -32
- data/lib/models/ib/contract_detail.rb +13 -7
- data/lib/models/ib/index.rb +1 -1
- data/lib/models/ib/option.rb +8 -2
- data/lib/models/ib/option_detail.rb +19 -3
- data/lib/models/ib/order.rb +5 -0
- data/lib/models/ib/spread.rb +168 -0
- data/lib/models/ib/stock.rb +9 -3
- data/lib/models/ib/underlying.rb +4 -1
- data/lib/requires.rb +10 -3
- metadata +9 -20
- data/example/README.md +0 -76
- data/example/account_info +0 -54
- data/example/account_positions +0 -30
- data/example/account_summary +0 -88
- data/example/cancel_orders +0 -74
- data/example/fa_accounts +0 -25
- data/example/fundamental_data +0 -40
- data/example/historic_data_cli +0 -186
- data/example/list_orders +0 -45
- data/example/portfolio_csv +0 -81
- data/example/scanner_data +0 -62
- data/example/template +0 -19
- data/example/tick_data +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe3f4d98e27f1480eafe5ed066e42410fc97527fef692aba69b02a1db61836de
|
4
|
+
data.tar.gz: 8e9e733f6e383313a4c4275d5f95853944c573fb543c78f85280d41988c0e842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 306dfc26bb138a25e1f9136a24f590d47ac1f555f94936960287937888e50c107bb7bc6f5c9f802ceb6096218a4c4a22ba363b36bccb47f25c206ea6f71b0772
|
7
|
+
data.tar.gz: 4d97ce95ccc74a2c3b6d1d88b0472433b0a9382bc5433d0fd100337d6906a84570d09c363e8282e44259deb0bf8f21cfe80814a904d46e8379938ec8b7f67b9a
|
data/Gemfile.lock
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/ohler55/ox.git
|
3
|
-
revision:
|
3
|
+
revision: 59c4234fe01fb5de08d49b39ecf5fc7338c1ffdc
|
4
4
|
specs:
|
5
|
-
ox (2.
|
5
|
+
ox (2.14.4)
|
6
6
|
|
7
7
|
PATH
|
8
8
|
remote: .
|
9
9
|
specs:
|
10
|
-
ib-api (972.
|
10
|
+
ib-api (972.3.1)
|
11
11
|
activemodel
|
12
12
|
activesupport (>= 6.0)
|
13
13
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
|
-
activemodel (6.
|
18
|
-
activesupport (= 6.
|
19
|
-
activesupport (6.
|
17
|
+
activemodel (6.1.3.2)
|
18
|
+
activesupport (= 6.1.3.2)
|
19
|
+
activesupport (6.1.3.2)
|
20
20
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
-
i18n (>=
|
22
|
-
minitest (
|
23
|
-
tzinfo (~>
|
24
|
-
zeitwerk (~> 2.
|
21
|
+
i18n (>= 1.6, < 2)
|
22
|
+
minitest (>= 5.1)
|
23
|
+
tzinfo (~> 2.0)
|
24
|
+
zeitwerk (~> 2.3)
|
25
25
|
coderay (1.1.3)
|
26
|
-
concurrent-ruby (1.1.
|
26
|
+
concurrent-ruby (1.1.8)
|
27
27
|
diff-lcs (1.4.4)
|
28
|
-
ffi (1.
|
28
|
+
ffi (1.15.0)
|
29
29
|
formatador (0.2.5)
|
30
30
|
guard (2.16.2)
|
31
31
|
formatador (>= 0.2.4)
|
@@ -41,56 +41,55 @@ GEM
|
|
41
41
|
guard (~> 2.1)
|
42
42
|
guard-compat (~> 1.1)
|
43
43
|
rspec (>= 2.99.0, < 4.0)
|
44
|
-
i18n (1.8.
|
44
|
+
i18n (1.8.10)
|
45
45
|
concurrent-ruby (~> 1.0)
|
46
|
-
listen (3.
|
46
|
+
listen (3.5.1)
|
47
47
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
48
48
|
rb-inotify (~> 0.9, >= 0.9.10)
|
49
49
|
lumberjack (1.2.8)
|
50
50
|
method_source (1.0.0)
|
51
|
-
minitest (5.14.
|
51
|
+
minitest (5.14.4)
|
52
52
|
nenv (0.3.0)
|
53
53
|
notiffany (0.1.3)
|
54
54
|
nenv (~> 0.1)
|
55
55
|
shellany (~> 0.0)
|
56
|
-
pry (0.
|
56
|
+
pry (0.14.1)
|
57
57
|
coderay (~> 1.1)
|
58
58
|
method_source (~> 1.0)
|
59
|
-
rake (13.0.
|
60
|
-
rb-fsevent (0.
|
59
|
+
rake (13.0.3)
|
60
|
+
rb-fsevent (0.11.0)
|
61
61
|
rb-inotify (0.10.1)
|
62
62
|
ffi (~> 1.0)
|
63
|
-
rspec (3.
|
64
|
-
rspec-core (~> 3.
|
65
|
-
rspec-expectations (~> 3.
|
66
|
-
rspec-mocks (~> 3.
|
63
|
+
rspec (3.10.0)
|
64
|
+
rspec-core (~> 3.10.0)
|
65
|
+
rspec-expectations (~> 3.10.0)
|
66
|
+
rspec-mocks (~> 3.10.0)
|
67
67
|
rspec-collection_matchers (1.2.0)
|
68
68
|
rspec-expectations (>= 2.99.0.beta1)
|
69
|
-
rspec-core (3.
|
70
|
-
rspec-support (~> 3.
|
71
|
-
rspec-expectations (3.
|
69
|
+
rspec-core (3.10.1)
|
70
|
+
rspec-support (~> 3.10.0)
|
71
|
+
rspec-expectations (3.10.1)
|
72
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
-
rspec-support (~> 3.
|
73
|
+
rspec-support (~> 3.10.0)
|
74
74
|
rspec-its (1.3.0)
|
75
75
|
rspec-core (>= 3.0.0)
|
76
76
|
rspec-expectations (>= 3.0.0)
|
77
|
-
rspec-mocks (3.
|
77
|
+
rspec-mocks (3.10.2)
|
78
78
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.
|
80
|
-
rspec-support (3.
|
79
|
+
rspec-support (~> 3.10.0)
|
80
|
+
rspec-support (3.10.2)
|
81
81
|
shellany (0.0.1)
|
82
|
-
thor (1.0
|
83
|
-
|
84
|
-
|
85
|
-
thread_safe (~> 0.1)
|
82
|
+
thor (1.1.0)
|
83
|
+
tzinfo (2.0.4)
|
84
|
+
concurrent-ruby (~> 1.0)
|
86
85
|
value_semantics (3.6.0)
|
87
|
-
zeitwerk (2.4.
|
86
|
+
zeitwerk (2.4.2)
|
88
87
|
|
89
88
|
PLATFORMS
|
90
|
-
|
89
|
+
x86_64-linux
|
91
90
|
|
92
91
|
DEPENDENCIES
|
93
|
-
bundler
|
92
|
+
bundler
|
94
93
|
guard
|
95
94
|
guard-rspec
|
96
95
|
ib-api!
|
@@ -102,4 +101,4 @@ DEPENDENCIES
|
|
102
101
|
value_semantics
|
103
102
|
|
104
103
|
BUNDLED WITH
|
105
|
-
|
104
|
+
2.2.3
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@ Ruby interface to Interactive Brokers' TWS API
|
|
3
3
|
|
4
4
|
Reimplementation of the basic functions of ib-ruby
|
5
5
|
|
6
|
+
__Documentation: [https://ib-ruby.github.io/ib-doc/](https://ib-ruby.github.io/ib-doc/)__ (_work in progress_)
|
6
7
|
|
7
8
|
----
|
8
9
|
`ib-ruby` offers a modular access to the TWS-API-Interface of Interactive Brokers.
|
@@ -11,12 +12,18 @@ Reimplementation of the basic functions of ib-ruby
|
|
11
12
|
|
12
13
|
----
|
13
14
|
|
14
|
-
|
15
|
+
Install in the usual way
|
15
16
|
|
17
|
+
```
|
18
|
+
$ gem install ib-api
|
19
|
+
```
|
20
|
+
|
21
|
+
In its plain vanilla usage, it just exchanges messages with the TWS. Any response is stored in the `recieved-Array`.
|
16
22
|
|
17
23
|
Even then, it needs just a few lines of code to place an order
|
18
24
|
|
19
25
|
```ruby
|
26
|
+
require 'ib-api'
|
20
27
|
# connect with default parameters
|
21
28
|
ib = IB::Connection.new
|
22
29
|
|
@@ -38,10 +45,48 @@ puts ib.recieved[:OrderStatus].to_human
|
|
38
45
|
|
39
46
|
# => ["<OrderState: Submitted #17/1528367295 from 2000 filled 0.0/100.0 at 0.0/0.0 why_held >"]
|
40
47
|
|
48
|
+
```
|
49
|
+
|
50
|
+
##### User-specific Actions
|
51
|
+
Besides storing any TWS-response in an array, callbacks are implemented.
|
52
|
+
|
53
|
+
The user subscribes to a certain response and defines the actions in a typically ruby manner. These actions
|
54
|
+
can be defined globaly
|
55
|
+
```ruby
|
56
|
+
ib = IB::Connection.new do |tws|
|
57
|
+
# Subscribe to TWS alerts/errors and order-related messages
|
58
|
+
tws.subscribe(:Alert, :OpenOrder, :OrderStatus, :OpenOrderEnd) { |msg| puts msg.to_human }
|
59
|
+
end
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
or occationally
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
# first define actions
|
67
|
+
a = ib.subscribe(:Alert, :ContractData ) do |msg|
|
68
|
+
case msg
|
69
|
+
when Messages::Incoming::Alert
|
70
|
+
if msg.code == 200 # No security found
|
71
|
+
# do someting
|
72
|
+
end
|
73
|
+
when Messages::Incoming::ContractData # security returned
|
74
|
+
# do something
|
75
|
+
|
76
|
+
end # case
|
77
|
+
end
|
78
|
+
# perform request
|
79
|
+
ib.send_message :RequestContractData, :contract => #{some contract}
|
80
|
+
|
81
|
+
# wait until the :ContractDataEnd message returned
|
82
|
+
ib.wait_for :ContractDataEnd
|
83
|
+
|
84
|
+
ib.unsubscribe a # release subscriptions
|
85
|
+
|
41
86
|
```
|
42
87
|
## Minimal TWS-Version
|
43
88
|
|
44
|
-
`ib-api` is tested via the _stable
|
89
|
+
`ib-api` is tested via the _stable IB-Gateway_ (Version 9.72) and should work with any current tws-installation.
|
45
90
|
|
46
91
|
## Tests
|
47
92
|
|
@@ -58,7 +103,7 @@ You have to edit `spec/spec.yml` and replace the `:account`-Setting with your ow
|
|
58
103
|
|
59
104
|
## Contributing
|
60
105
|
|
61
|
-
Bug reports and pull requests are welcome
|
106
|
+
Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
62
107
|
|
63
108
|
## Code of Conduct
|
64
109
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
972.
|
1
|
+
972.4
|
data/api.gemspec
CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
36
|
spec.require_paths = ["lib"]
|
37
37
|
|
38
|
-
spec.add_development_dependency "bundler"
|
38
|
+
spec.add_development_dependency "bundler"
|
39
39
|
spec.add_development_dependency "rake", "~> 13.0"
|
40
40
|
spec.add_development_dependency "rspec", "~> 3.0"
|
41
41
|
spec.add_dependency 'activesupport', '>= 6.0'
|
data/bin/console
CHANGED
@@ -10,8 +10,6 @@
|
|
10
10
|
require 'bundler/setup'
|
11
11
|
require 'yaml'
|
12
12
|
|
13
|
-
require 'logger'
|
14
|
-
|
15
13
|
require 'ib-api'
|
16
14
|
|
17
15
|
class Array
|
@@ -47,7 +45,6 @@ read_yml = -> (key) do
|
|
47
45
|
puts "Namespace is IB ! "
|
48
46
|
puts
|
49
47
|
puts '-'* 45
|
50
|
-
include LogDev
|
51
48
|
include IB
|
52
49
|
require 'irb'
|
53
50
|
client_id = ARGV[1] || read_yml[:client_id]
|
@@ -62,16 +59,15 @@ read_yml = -> (key) do
|
|
62
59
|
end
|
63
60
|
|
64
61
|
ARGV.clear
|
65
|
-
logger = default_logger # Logger.new STDOUT
|
66
62
|
|
67
63
|
## The Block takes instructions which are executed after initializing all instance-variables
|
68
64
|
## and prior to the connection-process
|
69
65
|
## Here we just subscribe to some events
|
70
66
|
C = Connection.new client_id: client_id, port: port do |c| # future use__ , optional_capacities: "+PACEAPI" do |c|
|
71
67
|
|
72
|
-
c.subscribe( :ContractData, :BondContractData) { |msg| logger.info { msg.contract.to_human } }
|
73
|
-
c.subscribe( :Alert, :ContractDataEnd, :ManagedAccounts, :OrderStatus ) {| m| logger.info { m.to_human } }
|
74
|
-
c.subscribe( :PortfolioValue, :AccountValue, :OrderStatus, :OpenOrderEnd, :ExecutionData ) {| m| logger.info { m.to_human }}
|
68
|
+
c.subscribe( :ContractData, :BondContractData) { |msg| c.logger.info { msg.contract.to_human } }
|
69
|
+
c.subscribe( :Alert, :ContractDataEnd, :ManagedAccounts, :OrderStatus ) {| m| c.logger.info { m.to_human } }
|
70
|
+
c.subscribe( :PortfolioValue, :AccountValue, :OrderStatus, :OpenOrderEnd, :ExecutionData ) {| m| c.logger.info { m.to_human }}
|
75
71
|
# c.subscribe :ManagedAccounts do |msg|
|
76
72
|
# puts "------------------------------- Managed Accounts ----------------------------------"
|
77
73
|
# puts "Detected Accounts: #{msg.accounts.account.join(' -- ')} "
|
@@ -79,8 +75,8 @@ read_yml = -> (key) do
|
|
79
75
|
# end
|
80
76
|
|
81
77
|
c.subscribe( :OpenOrder){ |msg| "Open Order detected and stored: C.received[:OpenOrders] " }
|
82
|
-
c.logger.level = Logger::INFO
|
83
78
|
end
|
79
|
+
C.logger.level = Logger::INFO
|
84
80
|
unless C.received[:OpenOrder].blank?
|
85
81
|
puts "------------------------------- OpenOrders ----------------------------------"
|
86
82
|
puts C.received[:OpenOrder].to_human.join "\n"
|
data/changelog.md
CHANGED
@@ -5,3 +5,15 @@ Changelog
|
|
5
5
|
|=++++ |=++++++++++++ |
|
6
6
|
| 30.8.2020 | migrating lib-files from ib-ruby-project |
|
7
7
|
|
8
|
+
| 28.11.2020| separating lib/model and lib/models to enable extension with
|
9
|
+
ActiveRecord/Rails and OrientDB/ActiveOrient. |
|
10
|
+
| | Introducing a Database-Switch in /lib/requires to omit
|
11
|
+
loading of model- and messages files. This has to be done
|
12
|
+
manually after assigning the database-model framework. |
|
13
|
+
|
14
|
+
| 1.12.2020 | moving model/ib/spread.rb from `ib-extensions` to `ib-api`.|
|
15
|
+
| 1.12.2020 | creating a dummy Contract#verify to guaranty safe operation of spreads |
|
16
|
+
|
17
|
+
| | Preparation of a Gem-Release |
|
18
|
+
| 23.2.2021 | Fixed retrieving of ContractDetail requests of Options with strikes < 1
|
19
|
+
| | Gem Release |
|
data/lib/ib/base_properties.rb
CHANGED
@@ -19,11 +19,10 @@ module IB
|
|
19
19
|
|
20
20
|
# Comparison support
|
21
21
|
def content_attributes
|
22
|
-
#HashWithIndifferentAccess[attributes.reject do |(attr, _)|
|
23
22
|
#NoMethodError if a Hash is assigned to an attribute
|
24
23
|
Hash[attributes.reject do |(attr, _)|
|
25
24
|
attr.to_s =~ /(_count)\z/ ||
|
26
|
-
[:created_at, :
|
25
|
+
[:created_at, :type, # :updated_at,
|
27
26
|
:id, :order_id, :contract_id].include?(attr.to_sym)
|
28
27
|
end]
|
29
28
|
end
|
@@ -151,9 +150,9 @@ Remove all Time-Stamps from the list of Attributes
|
|
151
150
|
end
|
152
151
|
|
153
152
|
# Timestamps in lightweight models
|
154
|
-
|
153
|
+
# unless defined?(ActiveRecord::Base) && ancestors.include?(ActiveRecord::Base)
|
155
154
|
prop :created_at #, :updated_at
|
156
|
-
|
155
|
+
# end
|
157
156
|
|
158
157
|
end # included
|
159
158
|
end # module BaseProperties
|
data/lib/ib/connection.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'thread'
|
2
2
|
#require 'active_support'
|
3
3
|
require 'ib/socket'
|
4
|
-
require '
|
4
|
+
require 'logger'
|
5
|
+
require 'logging'
|
5
6
|
require 'ib/messages'
|
6
7
|
|
7
8
|
module IB
|
@@ -18,10 +19,9 @@ module IB
|
|
18
19
|
## public data-queue: received, received?, wait_for, clear_received
|
19
20
|
## misc: reader_running?
|
20
21
|
|
21
|
-
include
|
22
|
+
include Support::Logging # provides default_logger
|
22
23
|
|
23
24
|
mattr_accessor :current
|
24
|
-
mattr_accessor :logger ## borrowed from active_support
|
25
25
|
# Please note, we are realizing only the most current TWS protocol versions,
|
26
26
|
# thus improving performance at the expense of backwards compatibility.
|
27
27
|
# Older protocol versions support can be found in older gem versions.
|
@@ -40,7 +40,7 @@ module IB
|
|
40
40
|
connect: true, # Connect at initialization
|
41
41
|
received: true, # Keep all received messages in a @received Hash
|
42
42
|
# redis: false, # future plans
|
43
|
-
logger:
|
43
|
+
logger: nil,
|
44
44
|
client_id: rand( 1001 .. 9999 ) ,
|
45
45
|
client_version: IB::Messages::CLIENT_VERSION, # lib/ib/server_versions.rb
|
46
46
|
optional_capacities: "", # TWS-Version 974: "+PACEAPI"
|
@@ -49,17 +49,13 @@ module IB
|
|
49
49
|
# V 974 release motes
|
50
50
|
# API messages sent at a higher rate than 50/second can now be paced by TWS at the 50/second rate instead of potentially causing a disconnection. This is now done automatically by the RTD Server API and can be done with other API technologies by invoking SetConnectOptions("+PACEAPI") prior to eConnect.
|
51
51
|
|
52
|
-
|
52
|
+
self.class.configure_logger logger
|
53
53
|
# convert parameters into instance-variables and assign them
|
54
|
-
|
55
|
-
next unless type == :key
|
56
|
-
|
57
|
-
when :logger
|
58
|
-
self.logger = logger
|
59
|
-
else
|
54
|
+
method(__method__).parameters.each do |type, k|
|
55
|
+
next unless type == :key ## available: key , keyrest
|
56
|
+
next if k.to_s == 'logger'
|
60
57
|
v = eval(k.to_s)
|
61
58
|
instance_variable_set("@#{k}", v) unless v.nil?
|
62
|
-
end
|
63
59
|
end
|
64
60
|
|
65
61
|
# A couple of locks to avoid race conditions in JRuby
|
@@ -79,9 +75,9 @@ module IB
|
|
79
75
|
yield self if block_given?
|
80
76
|
|
81
77
|
self.subscribe(:NextValidId) do |msg|
|
82
|
-
|
78
|
+
self.logger.progname = "Connection#connect"
|
83
79
|
self.next_local_id = msg.local_id
|
84
|
-
|
80
|
+
self.logger.info { "Got next valid order id: #{next_local_id}." }
|
85
81
|
end
|
86
82
|
|
87
83
|
# Ensure the transmission of NextValidId.
|
@@ -100,7 +96,7 @@ module IB
|
|
100
96
|
def update_next_order_id
|
101
97
|
i,finish = 0, false
|
102
98
|
sub = self.subscribe(:NextValidID) { finish = true }
|
103
|
-
connected? ?
|
99
|
+
connected? ? self.send_message( :RequestIds ) : open()
|
104
100
|
Timeout::timeout(1, IB::TransmissionError,"Could not get NextValidId" ) do
|
105
101
|
loop { sleep 0.1; break if finish }
|
106
102
|
end
|
@@ -186,7 +182,13 @@ module IB
|
|
186
182
|
when what.is_a?(Class) && what < Messages::Incoming::AbstractMessage
|
187
183
|
[what]
|
188
184
|
when what.is_a?(Symbol)
|
189
|
-
|
185
|
+
if Messages::Incoming.const_defined?(what)
|
186
|
+
[Messages::Incoming.const_get(what)]
|
187
|
+
elsif TechnicalAnalysis::Signals.const_defined?(what)
|
188
|
+
[TechnicalAnalysis::Signals.const_get?(what)]
|
189
|
+
else
|
190
|
+
error "#{what} is no IB::Messages or TechnicalAnalyis::Signals class"
|
191
|
+
end
|
190
192
|
when what.is_a?(Regexp)
|
191
193
|
Messages::Incoming::Classes.values.find_all { |klass| klass.to_s =~ what }
|
192
194
|
else
|
data/lib/ib/logger.rb
CHANGED
data/lib/ib/messages/incoming.rb
CHANGED
@@ -139,7 +139,7 @@ module IB
|
|
139
139
|
TickRequestParameters = def_message [81, 0], [ :ticker_id, :int ],
|
140
140
|
[ :min_tick, :decimal],
|
141
141
|
[ :exchange, :string ],
|
142
|
-
[ :
|
142
|
+
[ :snapshot_permissions, :int ]
|
143
143
|
# class TickRequestParameters
|
144
144
|
# def load
|
145
145
|
# simple_load
|
@@ -30,12 +30,12 @@ module IB
|
|
30
30
|
@created_at = Time.now
|
31
31
|
if source.is_a?(Hash) # Source is a @data Hash
|
32
32
|
@data = source
|
33
|
-
@buffer =[] # initialize empty buffer, indicates a
|
33
|
+
@buffer =[] # initialize empty buffer, indicates a successful initializing
|
34
34
|
else
|
35
35
|
@buffer = source
|
36
36
|
### DEBUG DEBUG DEBUG RAW STREAM ###############
|
37
37
|
# if uncommented, the raw-input from the tws is included in the logging
|
38
|
-
|
38
|
+
## puts "BUFFER :> #{buffer.inspect} "
|
39
39
|
### DEBUG DEBUG DEBUG RAW STREAM ###############
|
40
40
|
@data = Hash.new
|
41
41
|
self.load
|
@@ -43,11 +43,11 @@ module IB
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def valid?
|
46
|
-
@buffer.empty?
|
46
|
+
@buffer.empty?
|
47
47
|
end
|
48
48
|
|
49
49
|
## more recent messages omit the transmission of a version
|
50
|
-
## thus just load the parameter-map
|
50
|
+
## thus just load the parameter-map
|
51
51
|
def simple_load
|
52
52
|
load_map *self.class.data_map
|
53
53
|
rescue IB::Error => e
|
@@ -87,7 +87,7 @@ module IB
|
|
87
87
|
|
88
88
|
when Symbol # Normal map
|
89
89
|
group, name, type, block =
|
90
|
-
if instruction[2].nil? || instruction[2].is_a?(Proc) # lambda's are Proc's
|
90
|
+
if instruction[2].nil? || instruction[2].is_a?(Proc) # lambda's are Proc's
|
91
91
|
[nil] + instruction # No group, [ :name, :type, (:block) ]
|
92
92
|
else
|
93
93
|
instruction # [ :group, :name, :type, (:block)]
|
@@ -95,14 +95,14 @@ module IB
|
|
95
95
|
begin
|
96
96
|
data = @buffer.__send__("read_#{type}", &block)
|
97
97
|
rescue IB::LoadError, NoMethodError => e
|
98
|
-
error "Reading #{self.class}: #{e.class}: #{e.message} --> Instruction: #{name}" , :reader, false
|
98
|
+
error "Reading #{self.class}: #{e.class}: #{e.message} --> Instruction: #{name}" , :reader, false
|
99
99
|
end
|
100
100
|
# debug puts data.inspect
|
101
101
|
if group
|
102
102
|
@data[group] ||= {}
|
103
103
|
@data[group][name] = data
|
104
104
|
else
|
105
|
-
@data[name] = data
|
105
|
+
@data[name] = data
|
106
106
|
end
|
107
107
|
else
|
108
108
|
error "Unrecognized instruction #{instruction}"
|