ib-extensions 1.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +53 -43
- data/ib-extensions.gemspec +1 -1
- data/lib/ib/eod.rb +20 -16
- data/lib/ib/extensions/version.rb +14 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e2c6ed9342fd33767b9abd239b57aded0c91338801602366ff245575a7c812f
|
4
|
+
data.tar.gz: 17a2acdf9865cfb34dabaeb6826052614c6ecd099b0ff534f2784c79826200bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9e3e6c88f52142cfff920ab547a269cf32ed21174713f8b5386fe5e9bb5be0dff922442d94b6990b9d084f85d5d429ecbe4a6fd9fb245ab3a1d0c8de7e4d7f6
|
7
|
+
data.tar.gz: 7f45042d846d30ffdbbf6d59775bdca595399366c66ba91cfea7a25e93ae0d91ab7307b20969a1589b53541bb9e05f66adf6c7545104bb9d35a94d4f16518da0
|
data/Gemfile
CHANGED
@@ -2,8 +2,8 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in ib-extensions.gemspec
|
4
4
|
gemspec
|
5
|
-
gem "ib-api"
|
5
|
+
#gem "ib-api", path: "../ib-api/"
|
6
6
|
## move this to gemspec and include as development dependency after the gem is released
|
7
7
|
gem "ib-symbols" # , path: "../ib-symbols/"
|
8
|
-
|
8
|
+
gem "ib-api" #, :git=> 'https://github.com/ib-ruby/ib-api.git'
|
9
9
|
gem "rake", "~> 12.0"
|
data/Gemfile.lock
CHANGED
@@ -1,46 +1,47 @@
|
|
1
|
-
|
2
|
-
remote:
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/ib-ruby/ib-api.git
|
3
|
+
revision: 90b3a97952565c198560009c0388a6cf23e80c65
|
3
4
|
specs:
|
4
|
-
ib-api (972.
|
5
|
+
ib-api (972.5.2)
|
5
6
|
activemodel
|
6
7
|
activesupport (>= 6.0)
|
7
|
-
|
8
|
-
PATH
|
9
|
-
remote: ../ib-symbols
|
10
|
-
specs:
|
11
|
-
ib-symbols (1.0)
|
12
|
-
ib-api
|
13
8
|
ox
|
9
|
+
terminal-table
|
14
10
|
|
15
11
|
PATH
|
16
12
|
remote: .
|
17
13
|
specs:
|
18
|
-
ib-extensions (
|
14
|
+
ib-extensions (2.0)
|
15
|
+
distribution
|
16
|
+
ib-api (~> 972.5.2)
|
19
17
|
ox
|
18
|
+
polars-df (~> 0.3.1)
|
19
|
+
prime
|
20
20
|
|
21
21
|
GEM
|
22
22
|
remote: https://rubygems.org/
|
23
23
|
specs:
|
24
|
-
activemodel (
|
25
|
-
activesupport (=
|
26
|
-
activesupport (
|
24
|
+
activemodel (7.0.4.2)
|
25
|
+
activesupport (= 7.0.4.2)
|
26
|
+
activesupport (7.0.4.2)
|
27
27
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
28
|
i18n (>= 1.6, < 2)
|
29
29
|
minitest (>= 5.1)
|
30
30
|
tzinfo (~> 2.0)
|
31
|
-
zeitwerk (~> 2.3)
|
32
31
|
coderay (1.1.3)
|
33
|
-
concurrent-ruby (1.
|
34
|
-
diff-lcs (1.
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
concurrent-ruby (1.2.2)
|
33
|
+
diff-lcs (1.5.0)
|
34
|
+
distribution (0.8.0)
|
35
|
+
ffi (1.15.5)
|
36
|
+
formatador (1.1.0)
|
37
|
+
forwardable (1.3.3)
|
38
|
+
guard (2.18.0)
|
38
39
|
formatador (>= 0.2.4)
|
39
40
|
listen (>= 2.7, < 4.0)
|
40
41
|
lumberjack (>= 1.0.12, < 2.0)
|
41
42
|
nenv (~> 0.1)
|
42
43
|
notiffany (~> 0.0)
|
43
|
-
pry (>= 0.
|
44
|
+
pry (>= 0.13.0)
|
44
45
|
shellany (~> 0.0)
|
45
46
|
thor (>= 0.18.1)
|
46
47
|
guard-compat (1.2.1)
|
@@ -48,52 +49,61 @@ GEM
|
|
48
49
|
guard (~> 2.1)
|
49
50
|
guard-compat (~> 1.1)
|
50
51
|
rspec (>= 2.99.0, < 4.0)
|
51
|
-
i18n (1.
|
52
|
+
i18n (1.12.0)
|
52
53
|
concurrent-ruby (~> 1.0)
|
53
|
-
|
54
|
+
ib-symbols (1.5)
|
55
|
+
ib-api
|
56
|
+
listen (3.8.0)
|
54
57
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
55
58
|
rb-inotify (~> 0.9, >= 0.9.10)
|
56
59
|
lumberjack (1.2.8)
|
57
60
|
method_source (1.0.0)
|
58
|
-
minitest (5.
|
61
|
+
minitest (5.18.0)
|
59
62
|
nenv (0.3.0)
|
60
63
|
notiffany (0.1.3)
|
61
64
|
nenv (~> 0.1)
|
62
65
|
shellany (~> 0.0)
|
63
|
-
ox (2.
|
64
|
-
|
66
|
+
ox (2.14.14)
|
67
|
+
polars-df (0.3.1-x86_64-linux)
|
68
|
+
prime (0.1.2)
|
69
|
+
forwardable
|
70
|
+
singleton
|
71
|
+
pry (0.14.2)
|
65
72
|
coderay (~> 1.1)
|
66
73
|
method_source (~> 1.0)
|
67
74
|
rake (12.3.3)
|
68
|
-
rb-fsevent (0.
|
75
|
+
rb-fsevent (0.11.2)
|
69
76
|
rb-inotify (0.10.1)
|
70
77
|
ffi (~> 1.0)
|
71
|
-
rspec (3.
|
72
|
-
rspec-core (~> 3.
|
73
|
-
rspec-expectations (~> 3.
|
74
|
-
rspec-mocks (~> 3.
|
78
|
+
rspec (3.12.0)
|
79
|
+
rspec-core (~> 3.12.0)
|
80
|
+
rspec-expectations (~> 3.12.0)
|
81
|
+
rspec-mocks (~> 3.12.0)
|
75
82
|
rspec-collection_matchers (1.2.0)
|
76
83
|
rspec-expectations (>= 2.99.0.beta1)
|
77
|
-
rspec-core (3.
|
78
|
-
rspec-support (~> 3.
|
79
|
-
rspec-expectations (3.
|
84
|
+
rspec-core (3.12.1)
|
85
|
+
rspec-support (~> 3.12.0)
|
86
|
+
rspec-expectations (3.12.2)
|
80
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
-
rspec-support (~> 3.
|
88
|
+
rspec-support (~> 3.12.0)
|
82
89
|
rspec-its (1.3.0)
|
83
90
|
rspec-core (>= 3.0.0)
|
84
91
|
rspec-expectations (>= 3.0.0)
|
85
|
-
rspec-mocks (3.
|
92
|
+
rspec-mocks (3.12.3)
|
86
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
-
rspec-support (~> 3.
|
88
|
-
rspec-support (3.
|
94
|
+
rspec-support (~> 3.12.0)
|
95
|
+
rspec-support (3.12.0)
|
89
96
|
shellany (0.0.1)
|
90
|
-
|
91
|
-
|
97
|
+
singleton (0.1.1)
|
98
|
+
terminal-table (3.0.2)
|
99
|
+
unicode-display_width (>= 1.1.1, < 3)
|
100
|
+
thor (1.2.1)
|
101
|
+
tzinfo (2.0.6)
|
92
102
|
concurrent-ruby (~> 1.0)
|
93
|
-
|
103
|
+
unicode-display_width (2.4.2)
|
94
104
|
|
95
105
|
PLATFORMS
|
96
|
-
|
106
|
+
x86_64-linux
|
97
107
|
|
98
108
|
DEPENDENCIES
|
99
109
|
bundler (~> 2.0)
|
@@ -101,11 +111,11 @@ DEPENDENCIES
|
|
101
111
|
guard-rspec
|
102
112
|
ib-api!
|
103
113
|
ib-extensions!
|
104
|
-
ib-symbols
|
114
|
+
ib-symbols
|
105
115
|
rake (~> 12.0)
|
106
116
|
rspec (~> 3.0)
|
107
117
|
rspec-collection_matchers
|
108
118
|
rspec-its
|
109
119
|
|
110
120
|
BUNDLED WITH
|
111
|
-
2.
|
121
|
+
2.4.6
|
data/ib-extensions.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "bundler", "~> 2.0"
|
34
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
35
35
|
spec.add_development_dependency 'rspec-collection_matchers'
|
36
|
-
spec.add_development_dependency 'rspec-its'
|
36
|
+
spec.add_development_dependency 'rspec-its'
|
37
37
|
|
38
38
|
spec.add_development_dependency "guard"
|
39
39
|
spec.add_development_dependency "guard-rspec"
|
data/lib/ib/eod.rb
CHANGED
@@ -55,7 +55,7 @@ require 'csv'
|
|
55
55
|
end
|
56
56
|
# Receive EOD-Data and store the data in the `:bars`-property of IB::Contract
|
57
57
|
#
|
58
|
-
# contract.eod duration: {String or Integer}, start: {Date}, to: {Date} what: {see below}
|
58
|
+
# contract.eod duration: {String or Integer}, start: {Date}, to: {Date}, what: {see below}, polars: {true|false}
|
59
59
|
#
|
60
60
|
#
|
61
61
|
#
|
@@ -75,8 +75,8 @@ require 'csv'
|
|
75
75
|
#
|
76
76
|
# Polars DataFrames
|
77
77
|
# -----------------
|
78
|
-
#
|
79
|
-
#
|
78
|
+
# If »polars: true« is specified the response is stored as PolarsDataframe.
|
79
|
+
# For further processing: https://github.com/ankane/polars-ruby
|
80
80
|
# https://pola-rs.github.io/polars/py-polars/html/index.html
|
81
81
|
#
|
82
82
|
# Error-handling
|
@@ -102,7 +102,7 @@ require 'csv'
|
|
102
102
|
# Examples
|
103
103
|
# --------
|
104
104
|
#
|
105
|
-
# puts Stock.new( symbol: :iwm).eod( start: Date.new(2019,10,9), duration: 3)
|
105
|
+
# puts Stock.new( symbol: :iwm).eod( start: Date.new(2019,10,9), duration: 3, polars: true)
|
106
106
|
# shape: (3, 8)
|
107
107
|
# ┌────────────┬────────┬────────┬────────┬────────┬────────┬─────────┬────────┐
|
108
108
|
# │ time ┆ open ┆ high ┆ low ┆ close ┆ volume ┆ wap ┆ trades │
|
@@ -114,7 +114,7 @@ require 'csv'
|
|
114
114
|
# │ 2019-10-10 ┆ 146.9 ┆ 148.74 ┆ 146.87 ┆ 148.24 ┆ 134549 ┆ 147.792 ┆ 71084 │
|
115
115
|
# └────────────┴────────┴────────┴────────┴────────┴────────┴─────────┴────────┘
|
116
116
|
#
|
117
|
-
# puts Stock.new( symbol: :iwm).eod( start: Date.new(2021,10,9), duration: '3W')
|
117
|
+
# puts Stock.new( symbol: :iwm).eod( start: Date.new(2021,10,9), duration: '3W', polars: true)
|
118
118
|
# shape: (3, 8)
|
119
119
|
# ┌────────────┬────────┬────────┬────────┬────────┬─────────┬─────────┬────────┐
|
120
120
|
# │ time ┆ open ┆ high ┆ low ┆ close ┆ volume ┆ wap ┆ trades │
|
@@ -126,7 +126,7 @@ require 'csv'
|
|
126
126
|
# │ 2021-10-15 ┆ 220.69 ┆ 228.41 ┆ 218.94 ┆ 225.05 ┆ 768065 ┆ 223.626 ┆ 437817 │
|
127
127
|
# └────────────┴────────┴────────┴────────┴────────┴─────────┴─────────┴────────┘
|
128
128
|
#
|
129
|
-
# puts Stock.new( symbol: :iwm).eod( start: Date.new(2022,10,1), duration: '3M')
|
129
|
+
# puts Stock.new( symbol: :iwm).eod( start: Date.new(2022,10,1), duration: '3M', polars: true)
|
130
130
|
# shape: (3, 8)
|
131
131
|
# ┌────────────┬────────┬────────┬────────┬────────┬─────────┬─────────┬─────────┐
|
132
132
|
# │ time ┆ open ┆ high ┆ low ┆ close ┆ volume ┆ wap ┆ trades │
|
@@ -138,7 +138,7 @@ require 'csv'
|
|
138
138
|
# │ 2022-11-30 ┆ 184.51 ┆ 189.56 ┆ 174.11 ┆ 188.19 ┆ 3793861 ┆ 182.594 ┆ 1945674 │
|
139
139
|
# └────────────┴────────┴────────┴────────┴────────┴─────────┴─────────┴─────────┘
|
140
140
|
#
|
141
|
-
# puts Stock.new( symbol: :iwm).eod( start: Date.new(2020,1,1), duration: '3M', what: :option_implied_vol
|
141
|
+
# puts Stock.new( symbol: :iwm).eod( start: Date.new(2020,1,1), duration: '3M', what: :option_implied_vol, polars: true
|
142
142
|
# atility )
|
143
143
|
# shape: (3, 8)
|
144
144
|
# ┌────────────┬──────────┬──────────┬──────────┬──────────┬────────┬──────────┬────────┐
|
@@ -151,7 +151,7 @@ require 'csv'
|
|
151
151
|
# │ 2020-02-28 ┆ 0.185732 ┆ 0.436549 ┆ 0.134933 ┆ 0.39845 ┆ 0 ┆ 0.435866 ┆ 0 │
|
152
152
|
# └────────────┴──────────┴──────────┴──────────┴──────────┴────────┴──────────┴────────┘
|
153
153
|
#
|
154
|
-
def eod start: nil, to: nil, duration: nil , what: :trades
|
154
|
+
def eod start: nil, to: nil, duration: nil , what: :trades, polars: false
|
155
155
|
|
156
156
|
# error "EOD:: Start-Date (parameter: to) must be a Date-Object" unless to.is_a? Date
|
157
157
|
normalize_duration = ->(d) do
|
@@ -166,7 +166,7 @@ require 'csv'
|
|
166
166
|
d = normalize_duration.call(duration)
|
167
167
|
case d[-1]
|
168
168
|
when "D"
|
169
|
-
start + d.to_i - 1
|
169
|
+
start + d.to_i - 1
|
170
170
|
when 'W'
|
171
171
|
Date.commercial( start.year, start.cweek + d.to_i - 1, 1)
|
172
172
|
when 'M'
|
@@ -175,15 +175,15 @@ require 'csv'
|
|
175
175
|
end
|
176
176
|
|
177
177
|
if to.nil?
|
178
|
-
# case eod start= Date.new ...
|
178
|
+
# case eod start= Date.new ...
|
179
179
|
to = if start.present? && duration.nil?
|
180
|
-
# case eod start= Date.new
|
180
|
+
# case eod start= Date.new
|
181
181
|
duration = BuisinesDays.business_days_between(start, to).to_s + "D"
|
182
182
|
Date.today # assign to var: to
|
183
183
|
elsif start.present? && duration.present?
|
184
184
|
# case eod start= Date.new , duration: 'nN'
|
185
185
|
get_end_date.call # assign to var: to
|
186
|
-
elsif duration.present?
|
186
|
+
elsif duration.present?
|
187
187
|
# case start is not present, we are collecting until the present day
|
188
188
|
Date.today # assign to var: to
|
189
189
|
else
|
@@ -202,7 +202,7 @@ require 'csv'
|
|
202
202
|
end
|
203
203
|
|
204
204
|
|
205
|
-
get_bars(to.to_time.to_ib , normalize_duration[duration], barsize, what)
|
205
|
+
get_bars(to.to_time.to_ib , normalize_duration[duration], barsize, what, polars)
|
206
206
|
|
207
207
|
end # def
|
208
208
|
|
@@ -223,7 +223,7 @@ require 'csv'
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
|
-
def get_bars(end_date_time, duration, bar_size, what_to_show)
|
226
|
+
def get_bars(end_date_time, duration, bar_size, what_to_show, polars)
|
227
227
|
|
228
228
|
tws = IB::Connection.current
|
229
229
|
received = Queue.new
|
@@ -231,8 +231,12 @@ require 'csv'
|
|
231
231
|
# the hole response is transmitted at once!
|
232
232
|
a = tws.subscribe(IB::Messages::Incoming::HistoricalData) do |msg|
|
233
233
|
if msg.request_id == con_id
|
234
|
-
|
235
|
-
|
234
|
+
self.bars = if polars
|
235
|
+
# msg.results.each { |entry| puts " #{entry}" }
|
236
|
+
Polars::DataFrame.new msg.results.map( &:invariant_attributes )
|
237
|
+
else
|
238
|
+
msg.results
|
239
|
+
end
|
236
240
|
end
|
237
241
|
received.push Time.now
|
238
242
|
end
|
@@ -1,5 +1,18 @@
|
|
1
1
|
module IB
|
2
2
|
module Extensions
|
3
|
-
VERSION = "1.3"
|
3
|
+
VERSION = "1.3.1"
|
4
4
|
end
|
5
5
|
end
|
6
|
+
|
7
|
+
|
8
|
+
__END__
|
9
|
+
|
10
|
+
Changelog V. 1.2 -> 1.3
|
11
|
+
|
12
|
+
* added probability_of_expiring to IB::Option
|
13
|
+
* IB::Contract.eod returns a Polars DataFrame
|
14
|
+
* improved IB::Option.request_greeks
|
15
|
+
* improved IB::Contract.verify
|
16
|
+
|
17
|
+
1.3.1: Contract.eod: Parameter polars: true|false
|
18
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ib-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hartmut Bischoff
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ox
|
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
248
|
- !ruby/object:Gem::Version
|
249
249
|
version: '0'
|
250
250
|
requirements: []
|
251
|
-
rubygems_version: 3.
|
251
|
+
rubygems_version: 3.4.6
|
252
252
|
signing_key:
|
253
253
|
specification_version: 4
|
254
254
|
summary: Part of IB-Ruby. Tools to to access the tws-api comfortably.
|