ib-extensions 1.0
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +112 -0
- data/Guardfile +24 -0
- data/README.md +99 -0
- data/Rakefile +6 -0
- data/bin/console +96 -0
- data/bin/console.yml +3 -0
- data/bin/gateway.rb +97 -0
- data/bin/setup +8 -0
- data/changelog.md +31 -0
- data/examples/cancel_orders +74 -0
- data/examples/eod +35 -0
- data/examples/input.rb +475 -0
- data/examples/market_price +57 -0
- data/examples/option_chain +67 -0
- data/examples/place_and_modify_order +162 -0
- data/examples/place_bracket_order +62 -0
- data/examples/place_butterfly_order +104 -0
- data/examples/place_combo_order +70 -0
- data/examples/place_limit_order +82 -0
- data/examples/place_the_limit_order +145 -0
- data/examples/volatility_research +139 -0
- data/examples/what_if_order +90 -0
- data/ib-extensions.gemspec +37 -0
- data/lib/ib-gateway.rb +5 -0
- data/lib/ib/alerts/base-alert.rb +128 -0
- data/lib/ib/alerts/gateway-alerts.rb +15 -0
- data/lib/ib/alerts/order-alerts.rb +68 -0
- data/lib/ib/eod.rb +152 -0
- data/lib/ib/extensions.rb +9 -0
- data/lib/ib/extensions/contract.rb +37 -0
- data/lib/ib/extensions/version.rb +5 -0
- data/lib/ib/flex.rb +150 -0
- data/lib/ib/gateway.rb +425 -0
- data/lib/ib/gateway/account-infos.rb +115 -0
- data/lib/ib/gateway/order-handling.rb +150 -0
- data/lib/ib/market-price.rb +134 -0
- data/lib/ib/models/account.rb +329 -0
- data/lib/ib/models/spread.rb +159 -0
- data/lib/ib/option-chain.rb +198 -0
- data/lib/ib/option-greeks.rb +88 -0
- data/lib/ib/order-prototypes.rb +110 -0
- data/lib/ib/order_prototypes/abstract.rb +67 -0
- data/lib/ib/order_prototypes/combo.rb +46 -0
- data/lib/ib/order_prototypes/forex.rb +40 -0
- data/lib/ib/order_prototypes/limit.rb +177 -0
- data/lib/ib/order_prototypes/market.rb +116 -0
- data/lib/ib/order_prototypes/pegged.rb +173 -0
- data/lib/ib/order_prototypes/premarket.rb +31 -0
- data/lib/ib/order_prototypes/stop.rb +202 -0
- data/lib/ib/order_prototypes/volatility.rb +39 -0
- data/lib/ib/spread-prototypes.rb +62 -0
- data/lib/ib/spread_prototypes/butterfly.rb +79 -0
- data/lib/ib/spread_prototypes/calendar.rb +85 -0
- data/lib/ib/spread_prototypes/stock-spread.rb +48 -0
- data/lib/ib/spread_prototypes/straddle.rb +75 -0
- data/lib/ib/spread_prototypes/strangle.rb +96 -0
- data/lib/ib/spread_prototypes/vertical.rb +84 -0
- data/lib/ib/verify.rb +226 -0
- metadata +206 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b31bb7c59e25916c0ebc180446628175867a793e0c1020c7937b4226d67bc6da
|
4
|
+
data.tar.gz: f3dbe5677eb8551819595134ed91fa08027d677863a0be778fe3a5011ca41235
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9238aac43cf451bfc78e6afade296423b48d0b7c361a38338d3cd3e121a22df5e5b216296f890fbbaeb9647fc7d96c2a2e86e55321ac09f538844f3f8cc13ea6
|
7
|
+
data.tar.gz: 477b5078b89583fcf8856a966e05558c53b85f0d746e036c11e4fd4ff8c08c0aca23c617044c3eea1f4f068b054d02622155aae7e4ebf9954c4dfc52da60b62b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at topofocus@gmaiol.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in ib-extensions.gemspec
|
4
|
+
gemspec
|
5
|
+
gem "ib-api", path: "../ib-api/"
|
6
|
+
## move this to gemspec and include as development dependency after the gem is released
|
7
|
+
gem "ib-symbols", path: "../ib-symbols/"
|
8
|
+
#gem "ib-api", :git=> 'https://github.com/ib-ruby/ib-api.git'
|
9
|
+
gem "rake", "~> 12.0"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../ib-api
|
3
|
+
specs:
|
4
|
+
ib-api (972.0)
|
5
|
+
activemodel
|
6
|
+
activesupport (>= 6.0)
|
7
|
+
|
8
|
+
PATH
|
9
|
+
remote: ../ib-symbols
|
10
|
+
specs:
|
11
|
+
ib-symbols (1.0)
|
12
|
+
ib-api
|
13
|
+
ox
|
14
|
+
|
15
|
+
PATH
|
16
|
+
remote: .
|
17
|
+
specs:
|
18
|
+
ib-extensions (1.0)
|
19
|
+
ox
|
20
|
+
|
21
|
+
GEM
|
22
|
+
remote: https://rubygems.org/
|
23
|
+
specs:
|
24
|
+
activemodel (6.0.3.4)
|
25
|
+
activesupport (= 6.0.3.4)
|
26
|
+
activesupport (6.0.3.4)
|
27
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
|
+
i18n (>= 0.7, < 2)
|
29
|
+
minitest (~> 5.1)
|
30
|
+
tzinfo (~> 1.1)
|
31
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
32
|
+
coderay (1.1.3)
|
33
|
+
concurrent-ruby (1.1.7)
|
34
|
+
diff-lcs (1.4.4)
|
35
|
+
ffi (1.13.1)
|
36
|
+
formatador (0.2.5)
|
37
|
+
guard (2.16.2)
|
38
|
+
formatador (>= 0.2.4)
|
39
|
+
listen (>= 2.7, < 4.0)
|
40
|
+
lumberjack (>= 1.0.12, < 2.0)
|
41
|
+
nenv (~> 0.1)
|
42
|
+
notiffany (~> 0.0)
|
43
|
+
pry (>= 0.9.12)
|
44
|
+
shellany (~> 0.0)
|
45
|
+
thor (>= 0.18.1)
|
46
|
+
guard-compat (1.2.1)
|
47
|
+
guard-rspec (4.7.3)
|
48
|
+
guard (~> 2.1)
|
49
|
+
guard-compat (~> 1.1)
|
50
|
+
rspec (>= 2.99.0, < 4.0)
|
51
|
+
i18n (1.8.5)
|
52
|
+
concurrent-ruby (~> 1.0)
|
53
|
+
listen (3.3.1)
|
54
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
55
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
56
|
+
lumberjack (1.2.8)
|
57
|
+
method_source (1.0.0)
|
58
|
+
minitest (5.14.2)
|
59
|
+
nenv (0.3.0)
|
60
|
+
notiffany (0.1.3)
|
61
|
+
nenv (~> 0.1)
|
62
|
+
shellany (~> 0.0)
|
63
|
+
ox (2.13.4)
|
64
|
+
pry (0.13.1)
|
65
|
+
coderay (~> 1.1)
|
66
|
+
method_source (~> 1.0)
|
67
|
+
rake (12.3.3)
|
68
|
+
rb-fsevent (0.10.4)
|
69
|
+
rb-inotify (0.10.1)
|
70
|
+
ffi (~> 1.0)
|
71
|
+
rspec (3.10.0)
|
72
|
+
rspec-core (~> 3.10.0)
|
73
|
+
rspec-expectations (~> 3.10.0)
|
74
|
+
rspec-mocks (~> 3.10.0)
|
75
|
+
rspec-collection_matchers (1.2.0)
|
76
|
+
rspec-expectations (>= 2.99.0.beta1)
|
77
|
+
rspec-core (3.10.0)
|
78
|
+
rspec-support (~> 3.10.0)
|
79
|
+
rspec-expectations (3.10.0)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.10.0)
|
82
|
+
rspec-its (1.3.0)
|
83
|
+
rspec-core (>= 3.0.0)
|
84
|
+
rspec-expectations (>= 3.0.0)
|
85
|
+
rspec-mocks (3.10.0)
|
86
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
+
rspec-support (~> 3.10.0)
|
88
|
+
rspec-support (3.10.0)
|
89
|
+
shellany (0.0.1)
|
90
|
+
thor (1.0.1)
|
91
|
+
thread_safe (0.3.6)
|
92
|
+
tzinfo (1.2.8)
|
93
|
+
thread_safe (~> 0.1)
|
94
|
+
zeitwerk (2.4.1)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
bundler (~> 2.0)
|
101
|
+
guard
|
102
|
+
guard-rspec
|
103
|
+
ib-api!
|
104
|
+
ib-extensions!
|
105
|
+
ib-symbols!
|
106
|
+
rake (~> 12.0)
|
107
|
+
rspec (~> 3.0)
|
108
|
+
rspec-collection_matchers
|
109
|
+
rspec-its
|
110
|
+
|
111
|
+
BUNDLED WITH
|
112
|
+
2.1.4
|
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
5
|
+
require "ostruct"
|
6
|
+
|
7
|
+
# Generic Ruby apps
|
8
|
+
rspec = OpenStruct.new
|
9
|
+
rspec.spec = ->(m) { "spec/#{m}_spec.rb" }
|
10
|
+
rspec.spec_dir = "spec"
|
11
|
+
rspec.spec_helper = "spec/spec_helper.rb"
|
12
|
+
|
13
|
+
|
14
|
+
# watch(%r{^lib/models/ib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
15
|
+
# watch(%r{^lib/ib/messages/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
16
|
+
# watch(%r{^lib/ib/symbols/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
17
|
+
|
18
|
+
watch(%r{^ib/(.+)\.rb$}) { |m| "spec/ib/#{m[1]}_spec.rb" }
|
19
|
+
# watch(%r{^models/(.+)\.rb$}) { |m| "spec/models/#{m[1]}_spec.rb" }
|
20
|
+
watch(%r{^spec/.+_spec\.rb$})
|
21
|
+
watch('spec/spec_helper.rb') { "spec" }
|
22
|
+
# watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
23
|
+
end
|
24
|
+
|
data/README.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# IB/Extensions
|
2
|
+
|
3
|
+
Helpers and Macros that ease the usage of the TWS-API of Interactive Brokers
|
4
|
+
|
5
|
+
**status:** A stable Gem-Release is in preparation.
|
6
|
+
|
7
|
+
__Documentation: [https://ib-ruby.github.io/ib-doc/](https://ib-ruby.github.io/ib-doc/)__
|
8
|
+
|
9
|
+
to activate use
|
10
|
+
```
|
11
|
+
gem 'ib-extensions', git: 'https://github.com/ib-ruby/ib-extensions.git'
|
12
|
+
```
|
13
|
+
in the Gemfile and require the extensions as needed
|
14
|
+
|
15
|
+
## Include all
|
16
|
+
```
|
17
|
+
require 'ib-api'
|
18
|
+
require 'ib/extensions'
|
19
|
+
```
|
20
|
+
|
21
|
+
## Verify
|
22
|
+
```
|
23
|
+
require 'ib-api'
|
24
|
+
require 'ib/verify'
|
25
|
+
```
|
26
|
+
Verifies a given contract, for details refer to the [documentation](https://ib-ruby.github.io/ib-doc/Verify_contracts.html )
|
27
|
+
|
28
|
+
## Market Price
|
29
|
+
```
|
30
|
+
require 'ib-api'
|
31
|
+
require 'ib/market-price'
|
32
|
+
```
|
33
|
+
Returns the most recent market-price of a given contract ( [documentation](https://ib-ruby.github.io/ib-doc/market_price.html) )
|
34
|
+
|
35
|
+
## Historical Data (EOD)
|
36
|
+
```
|
37
|
+
require 'ib-api'
|
38
|
+
require 'ib/eod'
|
39
|
+
|
40
|
+
puts IB::Symbols.Index.estx.eod( duration: '10 d' )
|
41
|
+
```
|
42
|
+
Fetch historical data with just one line of code ([documentation](https://ib-ruby.github.io/ib-doc/Historical_data.html) )
|
43
|
+
|
44
|
+
## Order Prototypes
|
45
|
+
```
|
46
|
+
require 'ib-api'
|
47
|
+
require 'ib/order-prototypes'
|
48
|
+
|
49
|
+
order = IB::Limit.order size: 100, price: 10, action: :buy
|
50
|
+
order = IB::StopLimit.order size: 100, price: 10, stop_price: 9.5
|
51
|
+
```
|
52
|
+
|
53
|
+
then transmit the order through the [place_order](https://ib-ruby.github.io/ib-doc/order_placement.html) method of IB::Connection or Account-based preview, place, modify and cancel methods of [IB::Gateway](https://ib-ruby.github.io/ib-doc/order_placement.html).
|
54
|
+
|
55
|
+
More details in the [documentation](https://ib-ruby.github.io/ib-doc/order_prototypes.html)
|
56
|
+
|
57
|
+
|
58
|
+
## Spread Prototypes
|
59
|
+
|
60
|
+
```
|
61
|
+
require 'ib-api'
|
62
|
+
require 'ib/spread-prototypes'
|
63
|
+
```
|
64
|
+
|
65
|
+
Compose most common spreads through
|
66
|
+
|
67
|
+
```
|
68
|
+
s = IB::Straddle.build from: IB::Symbols::Index.stoxx,
|
69
|
+
strike: 2400,
|
70
|
+
expiry: 202103
|
71
|
+
|
72
|
+
s = IB::Strangle.build from: IB::Symbols::Index.stoxx,
|
73
|
+
c: 2400, p: 2200,
|
74
|
+
expiry: 202103
|
75
|
+
|
76
|
+
```
|
77
|
+
and use the speads like any other contract. ([documentation](https://ib-ruby.github.io/ib-doc/spreads.html)
|
78
|
+
|
79
|
+
## Gateway
|
80
|
+
```
|
81
|
+
require 'ib-gateway'
|
82
|
+
```
|
83
|
+
IB::Gateway is an alternative to IB::Connection. Upon initialization, it detects active accounts and stores them in a thread safe array.
|
84
|
+
Details in the [documentation](https://ib-ruby.github.io/ib-doc/gateway.html)
|
85
|
+
|
86
|
+
Its used in [Simple Monitor](https://github.com/ib-ruby/simple-monitor)
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
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/[USERNAME]/ib-extensions/blob/master/CODE_OF_CONDUCT.md).
|
95
|
+
|
96
|
+
|
97
|
+
## Code of Conduct
|
98
|
+
|
99
|
+
Everyone interacting in the Ib::Extensions project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ib-extensions/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
### loads the active-orient environment
|
3
|
+
### and starts an interactive shell
|
4
|
+
###
|
5
|
+
### Parameter: t)ws | g)ateway (or number of port ) Default: Gateway ,
|
6
|
+
### client_id , Default 2000
|
7
|
+
###
|
8
|
+
### Define Parameter in file console.yml
|
9
|
+
###
|
10
|
+
require 'bundler/setup'
|
11
|
+
require 'yaml'
|
12
|
+
|
13
|
+
require 'logger'
|
14
|
+
require "ib-api"
|
15
|
+
require 'ib/extensions'
|
16
|
+
require 'ib/symbols'
|
17
|
+
|
18
|
+
class Array
|
19
|
+
# enables calling members of an array. which are hashes by it name
|
20
|
+
# i.e
|
21
|
+
#
|
22
|
+
# 2.5.0 :006 > C.received[:OpenOrder].local_id
|
23
|
+
# => [16, 17, 21, 20, 19, 8, 7]
|
24
|
+
# 2.5.0 :007 > C.received[:OpenOrder].contract.to_human
|
25
|
+
# => ["<Bag: IECombo SMART USD legs: >", "<Stock: GE USD>", "<Stock: GE USD>", "<Stock: GE USD>", "<Stock: GE USD>", "<Stock: WFC USD>", "<Stock: WFC USD>"]
|
26
|
+
#
|
27
|
+
# its included only in the console, for inspection purposes
|
28
|
+
|
29
|
+
def method_missing(method, *key)
|
30
|
+
unless method == :to_hash || method == :to_str #|| method == :to_int
|
31
|
+
return self.map{|x| x.public_send(method, *key)}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end # Array
|
36
|
+
|
37
|
+
|
38
|
+
# read items from console.yml
|
39
|
+
read_yml = -> (key) do
|
40
|
+
YAML::load_file( File.expand_path('../console.yml',__FILE__))[key]
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
puts
|
45
|
+
puts ">> IB-Ruby Interactive Console <<"
|
46
|
+
puts '-'* 45
|
47
|
+
puts
|
48
|
+
puts "Namespace is IB ! "
|
49
|
+
puts
|
50
|
+
puts '-'* 45
|
51
|
+
include LogDev
|
52
|
+
include IB
|
53
|
+
require 'irb'
|
54
|
+
client_id = ARGV[1] || read_yml[:client_id]
|
55
|
+
specified_port = ARGV[0] || 'Gateway'
|
56
|
+
port = case specified_port
|
57
|
+
when Integer
|
58
|
+
specified_port # just use the number
|
59
|
+
when /^[gG]/
|
60
|
+
read_yml[:gateway]
|
61
|
+
when /^[Tt]/
|
62
|
+
read_yml[:tws]
|
63
|
+
end
|
64
|
+
|
65
|
+
ARGV.clear
|
66
|
+
logger = default_logger # Logger.new STDOUT
|
67
|
+
|
68
|
+
## The Block takes instructions which are executed after initializing all instance-variables
|
69
|
+
## and prior to the connection-process
|
70
|
+
## Here we just subscribe to some events
|
71
|
+
C = Connection.new client_id: client_id, port: port do |c| # future use__ , optional_capacities: "+PACEAPI" do |c|
|
72
|
+
|
73
|
+
c.subscribe( :ContractData, :BondContractData) { |msg| logger.info { msg.contract.to_human } }
|
74
|
+
c.subscribe( :Alert, :ContractDataEnd, :ManagedAccounts, :OrderStatus ) {| m| logger.info { m.to_human } }
|
75
|
+
c.subscribe( :PortfolioValue, :AccountValue, :OrderStatus, :OpenOrderEnd, :ExecutionData ) {| m| logger.info { m.to_human }}
|
76
|
+
# c.subscribe :ManagedAccounts do |msg|
|
77
|
+
# puts "------------------------------- Managed Accounts ----------------------------------"
|
78
|
+
# puts "Detected Accounts: #{msg.accounts.account.join(' -- ')} "
|
79
|
+
# puts
|
80
|
+
# end
|
81
|
+
|
82
|
+
c.subscribe( :OpenOrder){ |msg| "Open Order detected and stored: C.received[:OpenOrders] " }
|
83
|
+
c.logger.level = Logger::INFO
|
84
|
+
end
|
85
|
+
unless C.received[:OpenOrder].blank?
|
86
|
+
puts "------------------------------- OpenOrders ----------------------------------"
|
87
|
+
puts C.received[:OpenOrder].to_human.join "\n"
|
88
|
+
end
|
89
|
+
puts "Connection established on Port #{port}, client_id #{client_id} used"
|
90
|
+
puts
|
91
|
+
puts "----> C points to the connection-instance"
|
92
|
+
puts
|
93
|
+
puts "some basic Messages are subscribed and accordingly displayed"
|
94
|
+
puts '-'* 45
|
95
|
+
|
96
|
+
IRB.start(__FILE__)
|