ib-extensions 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
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: '1.0'
4
+ version: '1.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: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2021-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ox
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ib-api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '972.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '972.4'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -126,22 +140,9 @@ files:
126
140
  - Rakefile
127
141
  - bin/console
128
142
  - bin/console.yml
129
- - bin/gateway.rb
143
+ - bin/gateway
130
144
  - bin/setup
131
145
  - changelog.md
132
- - examples/cancel_orders
133
- - examples/eod
134
- - examples/input.rb
135
- - examples/market_price
136
- - examples/option_chain
137
- - examples/place_and_modify_order
138
- - examples/place_bracket_order
139
- - examples/place_butterfly_order
140
- - examples/place_combo_order
141
- - examples/place_limit_order
142
- - examples/place_the_limit_order
143
- - examples/volatility_research
144
- - examples/what_if_order
145
146
  - ib-extensions.gemspec
146
147
  - lib/ib-gateway.rb
147
148
  - lib/ib/alerts/base-alert.rb
@@ -157,7 +158,7 @@ files:
157
158
  - lib/ib/gateway/order-handling.rb
158
159
  - lib/ib/market-price.rb
159
160
  - lib/ib/models/account.rb
160
- - lib/ib/models/spread.rb
161
+ - lib/ib/models/option.rb
161
162
  - lib/ib/option-chain.rb
162
163
  - lib/ib/option-greeks.rb
163
164
  - lib/ib/order-prototypes.rb
@@ -199,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
200
  - !ruby/object:Gem::Version
200
201
  version: '0'
201
202
  requirements: []
202
- rubygems_version: 3.0.4
203
+ rubygems_version: 3.2.3
203
204
  signing_key:
204
205
  specification_version: 4
205
206
  summary: Part of IB-Ruby. Tools to to access the tws-api comfortably.
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This script allows you to cancel either a set of open Orders by their ids,
4
- # or ALL Orders opened via IB API at once. The latter is useful when your
5
- # robot goes crazy and opens gazillions of wrong limit orders.
6
- #
7
- # Accepts the port to connect to as first command-parameter, T)ws or G)ateway, which is the default
8
- #
9
- # Numeric Parameter are interpreted as keys for specific orders to kill
10
-
11
- require 'bundler/setup'
12
- require 'ib-api'
13
- specified_port = ARGV[0] || 'Gateway'
14
- port = case specified_port
15
- when /^[gG]/
16
- ARGV.shift # consume the first argument
17
- 4002
18
- when /^[Tt]/
19
- ARGV.shift # consume the first argument
20
- 7497
21
- end
22
-
23
- # First, connect to IB TWS.
24
- ib = IB::Connection.new client_id: 1111, port: port do | gw |
25
-
26
- # Subscribe to TWS alerts/errors and order-related messages
27
- gw.subscribe(:Alert, :OpenOrder, :OrderStatus, :OpenOrderEnd) { |msg| puts msg.to_human }
28
- # Set log level
29
- gw.logger.level = Logger::FATAL # DEBUG -- INFO -- WARN -- ERROR -- FATAL
30
- end
31
-
32
- if ARGV.empty?
33
- ib.send_message :RequestGlobalCancel
34
- else
35
- puts "ARGV: #{ARGV}"
36
- # Will only work for Orders placed under the same :client_id
37
- ib.cancel_order *ARGV
38
- puts '-'*55
39
- puts "Remaining Orders"
40
- puts '-'*55
41
- end
42
-
43
- puts '-'*55
44
- puts "Remaining Orders"
45
- ib.send_message :RequestAllOpenOrders
46
- puts '-'*55
47
-
48
- sleep 3
49
-
50
-
51
- ## Expected output
52
- #12:20:25.154 Connected to server, version: 137,
53
- # connection time: 2018-02-27 12:20:25 +0000 local, 2018-02-27T12:20:25+00:00 remote.
54
- #12:20:25.156 Got message 5 (IB::Messages::Incoming::OpenOrder)
55
- #<OpenOrder: <Stock: WFC USD> <Order: LMT GTC buy 100.0 1.13 Submitted #1/1562725191 from 1112/DU167348 fee 0.0>>
56
- #12:20:25.158 Got message 3 (IB::Messages::Incoming::OrderStatus)
57
- #<OrderStatus: <OrderState: Submitted #1/1562725191 from 1112 filled 0.0/100.0 at 0.0/0.0 why_held >>
58
- #12:20:25.197 Got message 53 (IB::Messages::Incoming::OpenOrderEnd)
59
- #<OpenOrderEnd: >
60
- #12:20:25.197 Got message 15 (IB::Messages::Incoming::ManagedAccounts)
61
- #12:20:25.197 No subscribers for message IB::Messages::Incoming::ManagedAccounts!
62
- #12:20:25.197 Got message 9 (IB::Messages::Incoming::NextValidId)
63
- #12:20:25.197 Got next valid order id: 2.
64
- #12:20:25.254 Got message 5 (IB::Messages::Incoming::OpenOrder)
65
- #<OpenOrder: <Stock: WFC USD> <Order: LMT GTC buy 100.0 1.13 PendingCancel #1/1562725191 from 1112/DU167348 fee 0.0>>
66
- #12:20:25.256 Got message 3 (IB::Messages::Incoming::OrderStatus)
67
- #<OrderStatus: <OrderState: PendingCancel #1/1562725191 from 1112 filled 0.0/100.0 at 0.0/0.0 why_held >>
68
- #12:20:25.297 Got message 53 (IB::Messages::Incoming::OpenOrderEnd)
69
- #<OpenOrderEnd: >
70
- #12:20:25.342 Got message 3 (IB::Messages::Incoming::OrderStatus)
71
- #<OrderStatus: <OrderState: Cancelled #1/1562725191 from 1112 filled 0.0/100.0 at 0.0/0.0 why_held >>
72
- #12:20:25.343 Got message 4 (IB::Messages::Incoming::Alert)
73
- #TWS Error 202: Order Canceled - reason:
74
- ##
data/examples/eod DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This script downloads historic data for specific symbols from IB
4
-
5
- require 'bundler/setup'
6
- require 'ib-api'
7
- require 'ib/symbols'
8
- require 'ib/eod'
9
-
10
- # Definition of what we want data for. We have to keep track of what ticker id
11
- # corresponds to what symbol ourselves, because the ticks don't include any other
12
- # identifying information. The choice of ticker ids is, as far as I can tell, arbitrary.
13
- # Predefined Symbol-definitions --> lib/ib/symbols
14
- contracts = [ IB::Symbols::Futures.mini_dax,
15
- IB::Stock.new( symbol: 'BAS', currency: 'EUR') , # BASF
16
- IB::Symbols::Forex.eurusd
17
- ]
18
-
19
-
20
- # Connect to IB TWS.
21
- #ib = IB::Connection.new( :client_id => 1102, port: 7496, host: '10.222.148.177' ) do | gw |
22
- ib = IB::Connection.new :client_id => 1112, :port => 7496 do | gw | #, :port => 7497 # TWS
23
-
24
- # Subscribe to TWS alerts/errors
25
- gw.subscribe(:Alert, :ManagedAccounts) { |msg| puts msg.to_human }
26
-
27
- end
28
- contracts.each do | c |
29
- c.eod( duration: '10 d', to: Date.today){|y| y.each{|z| puts z.to_human}}
30
- end
31
-
32
- puts "\n******** Press <Enter> to exit... *********\n\n"
33
- STDIN.gets
34
-
35
-
data/examples/input.rb DELETED
@@ -1,475 +0,0 @@
1
-
2
- require 'bundler/setup'
3
- require 'ib/symbols'
4
- require 'yaml'
5
-
6
-
7
- # First, connect to IB TWS and subscribe for events.
8
-
9
- IB::Symbols.allocate_collection :w500
10
- IB::Symbols::W500.purge_collection
11
-
12
- IB::Symbols.allocate_collection :w500
13
-
14
-
15
- symbols = %w(
16
- DD
17
- MMM
18
- WBAI
19
- WUBA
20
- EGHT
21
- AHC
22
- ATEN
23
- AAC
24
- AIR
25
- AAN
26
- ABB
27
- ABT
28
- ABBV
29
- ANF
30
- ACP
31
- JEQ
32
- ABM
33
- AKR
34
- ACN
35
- ACCO
36
- ATV
37
- ATU
38
- AYI
39
- GOLF
40
- ADX
41
- PEO
42
- AGRO
43
- ADNT
44
- ADT
45
- ATGE
46
- AAP
47
- ADSW
48
- WMS
49
- ASIX
50
- AAV
51
- AVK
52
- AGC
53
- LCM
54
- ACM
55
- ANW
56
- AEB
57
- AED
58
- AEG
59
- AEH
60
- AER
61
- HIVE
62
- AJRD
63
- AET
64
- AMG
65
- AFL
66
- MITT
67
- AGCO
68
- A
69
- AEM
70
- ADC
71
- AL
72
- APD
73
- AYR
74
- AKS
75
- ALG
76
- AGI
77
- ALK
78
- AIN
79
- ALB
80
- AA
81
- ALEX
82
- ALX
83
- ARE
84
- AQN
85
- BABA
86
- Y
87
- ATI
88
- ALLE
89
- AGN
90
- ALE
91
- AKP
92
- ADS
93
- AFB
94
- AOI
95
- AWF
96
- AB
97
- LNT
98
- CBH
99
- NCV
100
- NCZ
101
- ACV
102
- NIE
103
- NFJ
104
- ALSN
105
- ALLY
106
- AGD
107
- AWP
108
- AOD
109
- AYX
110
- ATUS
111
- MO
112
- ACH
113
- AMBR
114
- ABEV
115
- AMC
116
- AEE
117
- AMRC
118
- AMOV
119
- AMX
120
- AAT
121
- AXL
122
- ACC
123
- AEO
124
- AEP
125
- AEL
126
- AXP
127
- AFG
128
- AFGE
129
- AFGH
130
- AMH
131
- AIG
132
- AMID
133
- ARL
134
- ARA
135
- AWR
136
- AMT
137
- AVD
138
- AWK
139
- COLD
140
- APU
141
- AMP
142
- ABC
143
- ANFI
144
- AMN
145
- AP
146
- APH
147
- AXR
148
- AME
149
- AFSS
150
- AFST
151
- AEUA
152
- APC
153
- ANDV
154
- ANDX
155
- AU
156
- BUD
157
- AXE
158
- NLY
159
- AMGP
160
- AM
161
- AR
162
- ANTM
163
- ANH
164
- AON
165
- APA
166
- AIV
167
- ARI
168
- APO
169
- AIY
170
- AFT
171
- AIF
172
- APLE
173
- AIT
174
- ATR
175
- APTV
176
- WTR
177
- AQ
178
- WAAS
179
- ARMK
180
- ABR
181
- ARC
182
- MT
183
- ARCH
184
- ADM
185
- AROC
186
- ARNC
187
- ARCO
188
- RCUS
189
- ARD
190
- ASC
191
- AFC
192
- ACRE
193
- ARDC
194
- ARES
195
- AGX
196
- ANET
197
- AI
198
- AIC
199
- AIW
200
- AHH
201
- ARR
202
- AFI
203
- AWI
204
- ARW
205
- AJG
206
- APAM
207
- ASA
208
- ABG
209
- ASX
210
- ASGN
211
- AHT
212
- ASH
213
- APB
214
- ASPN
215
- AHL
216
- ASB
217
- AC
218
- AIZ
219
- AIZP
220
- AGO
221
- AZN
222
- HOME
223
- T
224
- TBB
225
- ATTO
226
- ATH
227
- ATKR
228
- AT
229
- ATO
230
- AUO
231
- ATHM
232
- ALV
233
- AN
234
- AZO
235
- AVB
236
- AGR
237
- AVYA
238
- AVY
239
- AVH
240
- AVA
241
- AVT
242
- AVP
243
- AVX
244
- AXTA
245
- AXS
246
- AZUL
247
- AZRE
248
- AZZ
249
- BGS
250
- BW
251
- BGH
252
- BMI
253
- BHGE
254
- BBN
255
- BLL
256
- BANC
257
- BBVA
258
- BBD
259
- BBDO
260
- BCH
261
- BLX
262
- BSMX
263
- BSBR
264
- BSAC
265
- SAN
266
- CIB
267
- BXS
268
- BAC
269
- NTB
270
- BK
271
- BNS
272
- BKU
273
- BCS
274
- MCI
275
- MPV
276
- BNED
277
- BKS
278
- B
279
- ABX
280
- BAS
281
- BAX
282
- BTE
283
- BBT
284
- BFR
285
- BBX
286
- BCE
287
- BZH
288
- BDX
289
- BDXA
290
- BDC
291
- BXE
292
- BEL
293
- BMS
294
- BHE
295
- BHLB
296
- BERY
297
- BBY
298
- BSTI
299
- BGCA
300
- BHP
301
- BBL
302
- BIG
303
- BH
304
- BHVN
305
- BIO
306
- BITA
307
- BKH
308
- BKHU
309
- BKI
310
- BSM
311
- BB
312
- BGIO
313
- BJZ
314
- BFZ
315
- CII
316
- BHK
317
- HYT
318
- BTZ
319
- DSU
320
- BGR
321
- BDJ
322
- EGF
323
- FRA
324
- BFO
325
- BGT
326
- BOE
327
- BME
328
- BAF
329
- BKT
330
- BGY
331
- BKN
332
- BTA
333
- BIT
334
- MUI
335
- MNE
336
- MUA
337
- BPK
338
- BKK
339
- BBK
340
- BBF
341
- BYM
342
- BFK
343
- BTT
344
- MEN
345
- MUC
346
- MUH
347
- MHD
348
- MFL
349
- MUJ
350
- MHN
351
- MUE
352
- MUS
353
- MVT
354
- MYC
355
- MCA
356
- MYD
357
- MYF
358
- MFT
359
- MIY
360
- MYJ
361
- MYN
362
- MPA
363
- MQT
364
- MYI
365
- MQY
366
- BNJ
367
- BNY
368
- BLH
369
- BQH
370
- BSE
371
- BCX
372
- BST
373
- BSD
374
- BUI
375
- BLK
376
- BGB
377
- BGX
378
- BSL
379
- APRN
380
- BCRH
381
- BXG
382
- BXC
383
- BWP
384
- BA
385
- BCC
386
- BCEI
387
- BOOT
388
- BAH
389
- BWA
390
- SAM
391
- BXP
392
- BSX
393
- BOX
394
- BYD
395
- BPMP
396
- BP
397
- BPT
398
- BRC
399
- BHR
400
- BDN
401
- BWG
402
- LND
403
- BAK
404
- BRFS
405
- BPI
406
- BGG
407
- BFAM
408
- BEDU
409
- BSA
410
- BSIG
411
- EAT
412
- BCO
413
- BMY
414
- BRS
415
- BTI
416
- BRX
417
- BR
418
- BKD
419
- BAM
420
- BBU
421
- INF
422
- BIP
423
- RA
424
- BEP
425
- BRO
426
- BRT
427
- BC
428
- BT
429
- BPL
430
- BKE
431
- BVN
432
- BBW
433
- BG
434
- BURL
435
- BWXT
436
- BY
437
- CJ
438
- GYB
439
- PFH
440
- CABO
441
- CBT
442
- COG
443
- CACI
444
- WHD
445
- CADE
446
- CAE
447
- CAI
448
- CAL
449
- CRC
450
- CWT
451
- CALX
452
- ELY
453
- CPE
454
- CBM
455
- CPT
456
- CCJ
457
- CPB
458
- CWH
459
- GOOS
460
- CM
461
- CNI
462
- CNQ
463
- CP
464
- CNNE
465
- CAJ
466
- CMD
467
- COF
468
- CSU
469
- BXMT
470
- CIC
471
- CMO )
472
-
473
- symbols.each_with_index{ |sy,i| IB::Symbols::W500.add_contract i, IB::Stock.new( symbol: sy) }
474
-
475
- puts IB::Symbols::W500.size