ib-extensions 1.2 → 1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -3
- data/Gemfile.lock +26 -26
- data/README.md +56 -10
- data/bin/console +10 -3
- data/bin/gateway +14 -9
- data/changelog.md +54 -0
- data/ib-extensions.gemspec +6 -4
- data/lib/ib/alerts/base-alert.rb +10 -13
- data/lib/ib/eod.rb +239 -127
- data/lib/ib/extensions/version.rb +1 -1
- data/lib/ib/extensions.rb +5 -0
- data/lib/ib/gateway/account-infos.rb +74 -47
- data/lib/ib/gateway/order-handling.rb +57 -25
- data/lib/ib/gateway.rb +45 -31
- data/lib/ib/market-price.rb +34 -34
- data/lib/ib/models/account.rb +177 -144
- data/lib/ib/models/bag.rb +19 -0
- data/lib/ib/models/contract.rb +16 -0
- data/lib/ib/models/future.rb +20 -0
- data/lib/ib/models/option.rb +20 -13
- data/lib/ib/option-chain.rb +4 -6
- data/lib/ib/option-greeks.rb +27 -21
- data/lib/ib/order_prototypes/all-in-one.rb +46 -0
- data/lib/ib/plot-poec.rb +60 -0
- data/lib/ib/probability_of_expiring.rb +109 -0
- data/lib/ib/spread-prototypes.rb +1 -0
- data/lib/ib/spread_prototypes/butterfly.rb +2 -4
- data/lib/ib/spread_prototypes/calendar.rb +25 -23
- data/lib/ib/spread_prototypes/straddle.rb +3 -3
- data/lib/ib/spread_prototypes/strangle.rb +8 -9
- data/lib/ib/spread_prototypes/vertical.rb +6 -7
- data/lib/ib/verify.rb +34 -39
- data/lib/ib-gateway.rb +12 -0
- metadata +53 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f696c98ab0dfb78f2a252e3729485ade6fcbf69c0689b72fba00003e289ec251
|
4
|
+
data.tar.gz: 5c956f55b2449685d1c08f188e4f55f71576a04dc22454414f4bde1a108ad474
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 283f7b571d300f13bf46941bb50654abd7424c51464c0bcb10e6d6f3cb9244a9761c2f111b31155e5a9332b1bb85a1289652cd8190558353c3b06b83e14e2b09
|
7
|
+
data.tar.gz: 66580a352103ceee7855146161e422eee676c919f29a4f9a447c0fc0be0177bbcb3d046e4880287a6f4f27f639e05eae243974f37b91a4634e6a1a1d306a6ba6
|
data/Gemfile
CHANGED
@@ -2,9 +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
|
-
gem "ib-symbols"
|
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"
|
10
|
-
gem 'dry-core'
|
data/Gemfile.lock
CHANGED
@@ -1,34 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../ib-api
|
3
3
|
specs:
|
4
|
-
ib-api (972.
|
4
|
+
ib-api (972.1)
|
5
5
|
activemodel
|
6
6
|
activesupport (>= 6.0)
|
7
7
|
|
8
|
+
PATH
|
9
|
+
remote: ../ib-symbols
|
10
|
+
specs:
|
11
|
+
ib-symbols (1.0)
|
12
|
+
ib-api
|
13
|
+
ox
|
14
|
+
|
8
15
|
PATH
|
9
16
|
remote: .
|
10
17
|
specs:
|
11
|
-
ib-extensions (1.
|
12
|
-
ib-api (~> 972.4)
|
18
|
+
ib-extensions (1.0)
|
13
19
|
ox
|
14
20
|
|
15
21
|
GEM
|
16
22
|
remote: https://rubygems.org/
|
17
23
|
specs:
|
18
|
-
activemodel (6.1.
|
19
|
-
activesupport (= 6.1.
|
20
|
-
activesupport (6.1.
|
24
|
+
activemodel (6.1.0)
|
25
|
+
activesupport (= 6.1.0)
|
26
|
+
activesupport (6.1.0)
|
21
27
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
22
28
|
i18n (>= 1.6, < 2)
|
23
29
|
minitest (>= 5.1)
|
24
30
|
tzinfo (~> 2.0)
|
25
31
|
zeitwerk (~> 2.3)
|
26
32
|
coderay (1.1.3)
|
27
|
-
concurrent-ruby (1.1.
|
33
|
+
concurrent-ruby (1.1.7)
|
28
34
|
diff-lcs (1.4.4)
|
29
|
-
|
30
|
-
concurrent-ruby (~> 1.0)
|
31
|
-
ffi (1.15.0)
|
35
|
+
ffi (1.13.1)
|
32
36
|
formatador (0.2.5)
|
33
37
|
guard (2.16.2)
|
34
38
|
formatador (>= 0.2.4)
|
@@ -44,23 +48,20 @@ GEM
|
|
44
48
|
guard (~> 2.1)
|
45
49
|
guard-compat (~> 1.1)
|
46
50
|
rspec (>= 2.99.0, < 4.0)
|
47
|
-
i18n (1.8.
|
51
|
+
i18n (1.8.5)
|
48
52
|
concurrent-ruby (~> 1.0)
|
49
|
-
|
50
|
-
ib-api
|
51
|
-
ox
|
52
|
-
listen (3.5.1)
|
53
|
+
listen (3.3.1)
|
53
54
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
54
55
|
rb-inotify (~> 0.9, >= 0.9.10)
|
55
56
|
lumberjack (1.2.8)
|
56
57
|
method_source (1.0.0)
|
57
|
-
minitest (5.14.
|
58
|
+
minitest (5.14.2)
|
58
59
|
nenv (0.3.0)
|
59
60
|
notiffany (0.1.3)
|
60
61
|
nenv (~> 0.1)
|
61
62
|
shellany (~> 0.0)
|
62
|
-
ox (2.
|
63
|
-
pry (0.
|
63
|
+
ox (2.13.4)
|
64
|
+
pry (0.13.1)
|
64
65
|
coderay (~> 1.1)
|
65
66
|
method_source (~> 1.0)
|
66
67
|
rake (12.3.3)
|
@@ -73,20 +74,20 @@ GEM
|
|
73
74
|
rspec-mocks (~> 3.10.0)
|
74
75
|
rspec-collection_matchers (1.2.0)
|
75
76
|
rspec-expectations (>= 2.99.0.beta1)
|
76
|
-
rspec-core (3.10.
|
77
|
+
rspec-core (3.10.0)
|
77
78
|
rspec-support (~> 3.10.0)
|
78
|
-
rspec-expectations (3.10.
|
79
|
+
rspec-expectations (3.10.0)
|
79
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
80
81
|
rspec-support (~> 3.10.0)
|
81
82
|
rspec-its (1.3.0)
|
82
83
|
rspec-core (>= 3.0.0)
|
83
84
|
rspec-expectations (>= 3.0.0)
|
84
|
-
rspec-mocks (3.10.
|
85
|
+
rspec-mocks (3.10.0)
|
85
86
|
diff-lcs (>= 1.2.0, < 2.0)
|
86
87
|
rspec-support (~> 3.10.0)
|
87
|
-
rspec-support (3.10.
|
88
|
+
rspec-support (3.10.0)
|
88
89
|
shellany (0.0.1)
|
89
|
-
thor (1.1
|
90
|
+
thor (1.0.1)
|
90
91
|
tzinfo (2.0.4)
|
91
92
|
concurrent-ruby (~> 1.0)
|
92
93
|
zeitwerk (2.4.2)
|
@@ -96,16 +97,15 @@ PLATFORMS
|
|
96
97
|
|
97
98
|
DEPENDENCIES
|
98
99
|
bundler (~> 2.0)
|
99
|
-
dry-core
|
100
100
|
guard
|
101
101
|
guard-rspec
|
102
102
|
ib-api!
|
103
103
|
ib-extensions!
|
104
|
-
ib-symbols
|
104
|
+
ib-symbols!
|
105
105
|
rake (~> 12.0)
|
106
106
|
rspec (~> 3.0)
|
107
107
|
rspec-collection_matchers
|
108
108
|
rspec-its
|
109
109
|
|
110
110
|
BUNDLED WITH
|
111
|
-
2.
|
111
|
+
2.1.4
|
data/README.md
CHANGED
@@ -6,7 +6,6 @@ __Documentation: [https://ib-ruby.github.io/ib-doc/](https://ib-ruby.github.io/i
|
|
6
6
|
|
7
7
|
__Questions, Contributions, Remarks: [Discussions are opened in ib-api](https://github.com/ib-ruby/ib-api/discussions)__
|
8
8
|
|
9
|
-
---
|
10
9
|
|
11
10
|
__Helpers and Macros that ease the usage of the TWS-API of Interactive Brokers__
|
12
11
|
|
@@ -46,6 +45,8 @@ puts IB::Symbols.Index.estx.eod( duration: '10 d' )
|
|
46
45
|
```
|
47
46
|
Fetch historical data with just one line of code ([documentation](https://ib-ruby.github.io/ib-doc/Historical_data.html) )
|
48
47
|
|
48
|
+
**NEW :: Contract.eod returns a PolarsDataframe **
|
49
|
+
|
49
50
|
## Order Prototypes
|
50
51
|
```
|
51
52
|
require 'ib-api'
|
@@ -62,38 +63,83 @@ More details in the [documentation](https://ib-ruby.github.io/ib-doc/order_proto
|
|
62
63
|
|
63
64
|
## Spread Prototypes
|
64
65
|
|
65
|
-
```
|
66
|
+
``` ruby
|
66
67
|
require 'ib-api'
|
67
68
|
require 'ib/spread-prototypes'
|
68
69
|
```
|
69
70
|
|
70
71
|
Compose most common spreads through
|
71
72
|
|
72
|
-
```
|
73
|
+
``` ruby
|
73
74
|
s = IB::Straddle.build from: IB::Symbols::Index.stoxx,
|
74
|
-
strike:
|
75
|
-
expiry:
|
75
|
+
strike: 4200,
|
76
|
+
expiry: 202112
|
76
77
|
|
77
|
-
|
78
|
+
t = IB::Strangle.build from: IB::Symbols::Index.stoxx,
|
78
79
|
c: 2400, p: 2200,
|
79
80
|
expiry: 202103
|
80
81
|
|
81
|
-
|
82
|
-
|
82
|
+
puts s.as_table
|
83
|
+
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
84
|
+
│ Straddle ESTX50(4200.0)[Dec 2021] │
|
85
|
+
├────────┬────────┬────────────┬──────────┬──────────┬────────────┬───────────────┬───────┬────────┬──────────┤
|
86
|
+
│ │ symbol │ con_id │ exchange │ expiry │ multiplier │ trading-class │ right │ strike │ currency │
|
87
|
+
╞════════╪════════╪════════════╪══════════╪══════════╪════════════╪═══════════════╪═══════╪════════╪══════════╡
|
88
|
+
│ Spread │ ESTX50 │ -532066861 │ DTB │ │ 10 │ │ │ │ EUR │
|
89
|
+
│ Option │ ESTX50 │ 266033438 │ DTB │ 20211217 │ 10 │ OESX │ put │ 4200.0 │ EUR │
|
90
|
+
│ Option │ ESTX50 │ 266033423 │ DTB │ 20211217 │ 10 │ OESX │ call │ 4200.0 │ EUR │
|
91
|
+
└────────┴────────┴────────────┴──────────┴──────────┴────────────┴───────────────┴───────┴────────┴──────────┘
|
92
|
+
```
|
93
|
+
and use the speads like any other contract. ([documentation](https://ib-ruby.github.io/ib-doc/spreads.html))
|
83
94
|
|
84
95
|
## Gateway
|
85
96
|
```
|
86
97
|
require 'ib-gateway'
|
87
98
|
```
|
88
|
-
IB::Gateway is an
|
99
|
+
IB::Gateway is an enhancement of IB::Connection. Upon initialization, it detects active accounts and stores them in thread safe arrays.
|
100
|
+
|
101
|
+
``` ruby
|
102
|
+
g = IB::Gateway.current
|
103
|
+
clients = G.clients
|
104
|
+
puts client.first.portfolio_values.as_table
|
105
|
+
┌───────────┬─────────────────────────────────────────────┬─────┬──────────┬──────────┬───────────┬────────────┬──────────┐
|
106
|
+
│ │ │ pos │ entry │ market │ value │ unrealized │ realized │
|
107
|
+
╞═══════════╪═════════════════════════════════════════════╪═════╪══════════╪══════════╪═══════════╪════════════╪══════════╡
|
108
|
+
│ Uxxxxxxx │ Stock: BEPC USD NYSE │ 200 │ 43.038 │ 41.042 │ 8208.4 │ -399.17 │ │
|
109
|
+
│ Uxxxxxxx │ Option: CNHI 20210819 put 13.0 IDEM EUR │ -2 │ 0.386 │ 0.01 │ -9.63 │ 376.37 │ │
|
110
|
+
│ Uxxxxxxx │ Stock: EQT SEK SFB │ 200 │ 443.8 │ 420.469 │ 84093.85 │ -4666.19 │ -1369.02 │
|
111
|
+
│ Uxxxxxxx │ Future: ESTX50 20210917 EUR │ -1 │ 4145.3 │ 4098.15 │ -40981.5 │ 471.5 │ │
|
112
|
+
│ Uxxxxxxx │ Option: ESTX50 20211217 call 4200.0 DTB EUR │ -4 │ 97.85 │ 99.398 │ -3975.9 │ -61.9 │ │
|
113
|
+
│ Uxxxxxxx │ Option: IWM 20210903 call 230.0 AMEX USD │ -4 │ 1.943 │ 0.124 │ -49.72 │ 727.49 │ │
|
114
|
+
|
115
|
+
```
|
89
116
|
Details in the [documentation](https://ib-ruby.github.io/ib-doc/gateway.html)
|
90
117
|
|
118
|
+
Generally `puts IB::Model.as_table` provides a modern and convient output for the console and notebooks.
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
g.update_orders
|
122
|
+
puts g.clients.first.orders.as_table
|
123
|
+
┌──────────┬───────────┬─────────────────────────────────────────┬──────┬─────┬────────┬────────┬───────┬────────┐
|
124
|
+
│ account │ status │ │ Type │ tif │ action │ amount │ price │ id/fee │
|
125
|
+
╞══════════╪═══════════╪═════════════════════════════════════════╪══════╪═════╪════════╪════════╪═══════╪════════╡
|
126
|
+
│ U123456 │ Submitted │ Option: SLV 20210716 put 24.0 SMART USD │ LMT │ GTC │ sell │ 5.0 │ 0.98 │ 0 │
|
127
|
+
└──────────┴───────────┴─────────────────────────────────────────┴──────┴─────┴────────┴────────┴───────┴────────┘
|
128
|
+
puts g.clients.first.orders.contract.as_table
|
129
|
+
┌────────┬────────┬───────────┬──────────┬──────────┬────────────┬───────────────┬───────┬────────┬──────────┐
|
130
|
+
│ │ symbol │ con_id │ exchange │ expiry │ multiplier │ trading-class │ right │ strike │ currency │
|
131
|
+
╞════════╪════════╪═══════════╪══════════╪══════════╪════════════╪═══════════════╪═══════╪════════╪══════════╡
|
132
|
+
│ Option │ SLV │ 456347029 │ SMART │ 20210716 │ 100 │ SLV │ put │ 24.0 │ USD │
|
133
|
+
└────────┴────────┴───────────┴──────────┴──────────┴────────────┴───────────────┴───────┴────────┴──────────┘
|
134
|
+
```
|
91
135
|
Its used in [Simple Monitor](https://github.com/ib-ruby/simple-monitor)
|
92
136
|
|
93
137
|
|
138
|
+
## Notebooks
|
139
|
+
**`IB-Ruby`** code can be executed in [iruby jupyter notebooks](https://github.com/SciRuby/iruby). A few scripts are included in [IB-Examples](https://github.com/ib-ruby/ib-examples). (*.ipynb- files)
|
94
140
|
|
95
141
|
|
96
|
-
|
142
|
+
```
|
97
143
|
## Contributing
|
98
144
|
|
99
145
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ib-ruby/ib-extensions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[ib-ruby/ib-extensions/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/console
CHANGED
@@ -65,7 +65,8 @@ read_yml = -> (key) do
|
|
65
65
|
|
66
66
|
## The Block takes instructions which are executed after initializing all instance-variables
|
67
67
|
## and prior to the connection-process
|
68
|
-
## Here we just subscribe to some events
|
68
|
+
## Here we just subscribe to some events
|
69
|
+
begin
|
69
70
|
C = Connection.new client_id: client_id, port: port do |c| # future use__ , optional_capacities: "+PACEAPI" do |c|
|
70
71
|
|
71
72
|
c.subscribe( :ContractData, :BondContractData) { |msg| c.logger.info { msg.contract.to_human } }
|
@@ -77,8 +78,8 @@ read_yml = -> (key) do
|
|
77
78
|
# puts
|
78
79
|
# end
|
79
80
|
|
80
|
-
c.subscribe( :OpenOrder){ |msg| "Open Order detected and stored: C.received[:OpenOrders] " }
|
81
|
-
c.logger.level = Logger::INFO
|
81
|
+
c.subscribe( :OpenOrder){ |msg| c.logger.info "Open Order detected and stored: C.received[:OpenOrders] " }
|
82
|
+
c.logger.level = Logger::WARN # set to INFO for more verbose output
|
82
83
|
end
|
83
84
|
unless C.received[:OpenOrder].blank?
|
84
85
|
puts "------------------------------- OpenOrders ----------------------------------"
|
@@ -91,4 +92,10 @@ read_yml = -> (key) do
|
|
91
92
|
puts "some basic Messages are subscribed and accordingly displayed"
|
92
93
|
puts '-'* 45
|
93
94
|
|
95
|
+
rescue IB::TransmissionError => e
|
96
|
+
Connection.logger.fatal e.message
|
97
|
+
Connection.logger.fatal "Aborting"
|
98
|
+
Kernel.exit
|
99
|
+
end
|
100
|
+
|
94
101
|
IRB.start(__FILE__)
|
data/bin/gateway
CHANGED
@@ -64,21 +64,26 @@ read_yml = -> (key) do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
ARGV.clear
|
67
|
-
logger = Logger.new STDOUT
|
68
|
-
logger.formatter = proc do |level, time, prog, msg|
|
69
|
-
"#{time.strftime('%H:%M:%S')} #{msg}\n"
|
70
|
-
end
|
71
|
-
logger.level = Logger::INFO
|
72
67
|
|
73
68
|
## The Block takes instructions which are executed after initializing all instance-variables
|
74
69
|
## and prior to the connection-process
|
75
70
|
## Here we just subscribe to some events
|
76
71
|
begin
|
77
72
|
G = Gateway.new get_account_data: true, serial_array: true,
|
78
|
-
client_id: client_id, port: port ,
|
79
|
-
watchlists: [:Spreads, :Stillhalter, :BuyAndHold]
|
80
|
-
|
81
|
-
|
73
|
+
client_id: client_id, port: port ,
|
74
|
+
watchlists: [:Spreads, :Stillhalter, :BuyAndHold] do |c|
|
75
|
+
c.tws.subscribe( :Alert, :ContractDataEnd, :ManagedAccounts, :OrderStatus ) {| m| c.logger.info { m.to_human } }
|
76
|
+
end
|
77
|
+
rescue IB::TransmissionError => e
|
78
|
+
if e.message =~ /client-id/
|
79
|
+
IB::Connection.logger.fatal "Increasing client_id"
|
80
|
+
client_id +=1
|
81
|
+
retry
|
82
|
+
else
|
83
|
+
puts "E: #{e.inspect}"
|
84
|
+
puts "Please restart"
|
85
|
+
Kernel.exit
|
86
|
+
end
|
82
87
|
end
|
83
88
|
|
84
89
|
C = G.tws
|
data/changelog.md
CHANGED
@@ -35,3 +35,57 @@
|
|
35
35
|
|
36
36
|
* Gateway#connect: Occasionally the request for AccountPositions/AllOrders fails. Then a reconnect is
|
37
37
|
appropriate. This is now implemented.
|
38
|
+
|
39
|
+
* Order.auto_adjust
|
40
|
+
|
41
|
+
Auto Adjust implements a simple algorithm to ensure that an order is accepted
|
42
|
+
|
43
|
+
It reads `contract_detail.min_tick`.
|
44
|
+
|
45
|
+
If min_tick < 0.01, the real tick-increments differ from the min_tick_value
|
46
|
+
|
47
|
+
For J36 (jardines) min tick is 0.001, but the minimal increment is 0.005
|
48
|
+
For Tui1 its the same, min_tick is 0.00001 , minimal increment ist 0.00005
|
49
|
+
|
50
|
+
Thus, for min-tick smaller then 0.01, the value is rounded to the next higher digit.
|
51
|
+
|
52
|
+
| min-tick | round |
|
53
|
+
|--------------|------------|
|
54
|
+
| 10 | 110 |
|
55
|
+
| 1 | 111 |
|
56
|
+
| 0.1 | 111.1 |
|
57
|
+
| 0.001 | 111.11 |
|
58
|
+
| 0.0001 | 111.11 |
|
59
|
+
| 0.00001 | 111.111 |
|
60
|
+
|--------------|------------|
|
61
|
+
|
62
|
+
* Client.place: defaults are
|
63
|
+
* auto_adjust is "true"
|
64
|
+
* convert_size: true
|
65
|
+
|
66
|
+
If a negative value for 'total amount' is used, then Order.action is set to :sell.
|
67
|
+
If a positive value is used, Order.action is kept
|
68
|
+
|
69
|
+
* Client.place raises an `IB::Symbol Error` if the order is not submitted
|
70
|
+
|
71
|
+
* Included Contract#included_in?( an IB::Account ) and Contract#portfolio_value( an IB::Account )
|
72
|
+
|
73
|
+
Suppose, you want to check, if a complex Contract is included in the Portfolio
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
s = Straddle.build symbol: Symbols::Index.stoxx, strike=4200, expiry: 20211217
|
77
|
+
puts s.included__in?(IB::Gateway.current.clients.first).to_human
|
78
|
+
=> "<Straddle ESTX50(4200.0)[Dec 2021]>"
|
79
|
+
puts s.portfolio_value( IB::Gateway.current.clients.first ).to_human
|
80
|
+
=> <PortfolioValue: Uxxxxxx Pos=-4 @ 225.158;Value=-9006.31;PNL=-1812.31 unrealized;<Option: ESTX50 20211217 put 4200.0 DTB EUR>
|
81
|
+
=> <PortfolioValue: Uxxxxxxx Pos=-4 @ 99.398;Value=-3975.9;PNL=-61.9 unrealized;<Option: ESTX50 20211217 call 4200.0 DTB EUR>
|
82
|
+
|
83
|
+
```
|
84
|
+
Both methods are available for IB::Contracts.
|
85
|
+
|
86
|
+
* IB::Gateway.current.get_account_data accepts only one parameter and is not persistent anymore
|
87
|
+
The former second argument (watchlists: ) is defaulted by those initialized through e IB::Gateway.new (IB::Gateway.current.active_watchlists)
|
88
|
+
The method now fetches the account- and portfoliodate, initialises Account#contracts, Account#portfolio_values, Account#account_values , Account#focusses and desubscribes from the TWS. (Before, the subscription to AccountData was permanently active).
|
89
|
+
|
90
|
+
* IB::Gateway.current.add_watchlist( a symbol ) -- Watchlists can added after initialisation
|
91
|
+
|
data/ib-extensions.gemspec
CHANGED
@@ -25,10 +25,12 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
spec.add_dependency "
|
31
|
-
|
28
|
+
spec.add_dependency "ox"
|
29
|
+
spec.add_dependency "prime"
|
30
|
+
spec.add_dependency "distribution"
|
31
|
+
spec.add_dependency "polars-df" , "~> 0.3.1"
|
32
|
+
spec.add_dependency "ib-api", "~> 972.5.2"
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
32
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
33
35
|
spec.add_development_dependency 'rspec-collection_matchers'
|
34
36
|
spec.add_development_dependency 'rspec-its'
|
data/lib/ib/alerts/base-alert.rb
CHANGED
@@ -43,15 +43,15 @@ Important: The class is accessed asynchronically. Be careful while raising inter
|
|
43
43
|
|
44
44
|
def self.method_missing( method_id, msg , *args, &block )
|
45
45
|
if msg.is_a? IB::Messages::Incoming::Alert
|
46
|
-
logger.debug { msg.to_human }
|
46
|
+
# IB::Connection.logger.debug { msg.to_human }
|
47
47
|
else
|
48
|
-
logger.error { "Argument to IB::Alert is not a IB::Messages::Incoming::Alert" }
|
49
|
-
logger.error { "The object: #{msg.inspect} " }
|
48
|
+
IB::Connection.logger.error { "Argument to IB::Alert is not a IB::Messages::Incoming::Alert" }
|
49
|
+
IB::Connection.logger.error { "The object: #{msg.inspect} " }
|
50
50
|
end
|
51
51
|
rescue NoMethodError
|
52
|
-
unless logger.nil?
|
53
|
-
logger.error { "The Argument is not a valid IB::Messages:Incoming::Alert object"}
|
54
|
-
logger.error { "The object: #{msg.inspect} " }
|
52
|
+
unless IB::Connection.logger.nil?
|
53
|
+
IB::Connection.logger.error { "The Argument is not a valid IB::Messages:Incoming::Alert object"}
|
54
|
+
IB::Connection.logger.error { "The object: #{msg.inspect} " }
|
55
55
|
else
|
56
56
|
puts "No Logging-Device specified"
|
57
57
|
puts "The object: #{msg.inspect} "
|
@@ -61,9 +61,6 @@ Important: The class is accessed asynchronically. Be careful while raising inter
|
|
61
61
|
|
62
62
|
|
63
63
|
class << self
|
64
|
-
def logger
|
65
|
-
IB::Connection.logger || IB::Gateway.logger
|
66
|
-
end
|
67
64
|
|
68
65
|
def ignore_alert *codes
|
69
66
|
codes.each do |n|
|
@@ -78,7 +75,7 @@ Important: The class is accessed asynchronically. Be careful while raising inter
|
|
78
75
|
codes.each do |n|
|
79
76
|
class_eval <<-EOD
|
80
77
|
def self.alert_#{n} msg
|
81
|
-
logger.info { msg.to_human }
|
78
|
+
# IB::Connection.logger.info { msg.to_human }
|
82
79
|
end
|
83
80
|
EOD
|
84
81
|
end
|
@@ -87,7 +84,7 @@ Important: The class is accessed asynchronically. Be careful while raising inter
|
|
87
84
|
codes.each do |n|
|
88
85
|
class_eval <<-EOD
|
89
86
|
def self.alert_#{n} msg
|
90
|
-
logger.warn { msg.to_human }
|
87
|
+
# IB::Connection.logger.warn { msg.to_human }
|
91
88
|
end
|
92
89
|
EOD
|
93
90
|
end
|
@@ -98,9 +95,9 @@ Important: The class is accessed asynchronically. Be careful while raising inter
|
|
98
95
|
class_eval <<-EOD
|
99
96
|
def self.alert_#{n} msg
|
100
97
|
if msg.error_id.present? && msg.error_id > 0
|
101
|
-
logger.error { msg.message + ' id: ' + msg.error_id.to_s }
|
98
|
+
# IB::Connection.logger.error { msg.message + ' id: ' + msg.error_id.to_s }
|
102
99
|
else
|
103
|
-
logger.error { msg.message }
|
100
|
+
# IB::Connection.logger.error { msg.message }
|
104
101
|
end
|
105
102
|
end
|
106
103
|
EOD
|