ib-orientdb 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 +56 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +128 -0
- data/Guardfile +24 -0
- data/LICENSE +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +99 -0
- data/bin/gateway +92 -0
- data/bin/readme.md +1 -0
- data/changelog.md +10 -0
- data/ib-orientdb.gemspec +42 -0
- data/lib/alerts/base-alert.rb +143 -0
- data/lib/alerts/gateway-alerts.rb +16 -0
- data/lib/alerts/order-alerts.rb +68 -0
- data/lib/ib-orientdb.rb +12 -0
- data/lib/ib/account-infos.rb +115 -0
- data/lib/ib/account-init.rb +151 -0
- data/lib/ib/orient-gateway.rb +362 -0
- data/lib/ib/setup-orientdb.rb +112 -0
- data/lib/logging.rb +34 -0
- data/lib/models/hc/d2_f.rb +0 -0
- data/lib/models/hc/grid.rb +0 -0
- data/lib/models/hc/has_portfolio.rb +0 -0
- data/lib/models/hc/has_position.rb +0 -0
- data/lib/models/hc/has_strategy.rb +0 -0
- data/lib/models/hc/hc_grid.rb +0 -0
- data/lib/models/hc/my_user.rb +0 -0
- data/lib/models/hc/p2_u.rb +0 -0
- data/lib/models/hc/portfolio.rb +161 -0
- data/lib/models/ib/account.rb +5 -0
- data/lib/models/ib/account_value.rb +29 -0
- data/lib/models/ib/advisor.rb +0 -0
- data/lib/models/ib/contract.rb +15 -0
- data/lib/models/ib/demo_advisor.rb +0 -0
- data/lib/models/ib/demo_user.rb +0 -0
- data/lib/models/ib/financials.rb +6 -0
- data/lib/models/ib/has_account.rb +0 -0
- data/lib/models/ib/portfolio_value.rb +10 -0
- data/lib/models/ib/spread.rb +0 -0
- data/lib/models/ib/user.rb +0 -0
- data/lib/models/tg/tag.rb +16 -0
- data/lib/support.rb +21 -0
- data/lib/version.rb +5 -0
- data/setup.md +83 -0
- metadata +231 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e494e1dafea622420c17c8b7a2be0138a4e3e194835923604173917b089b729b
|
4
|
+
data.tar.gz: 3c2fa9b54822e5040ca19edaea6df842d41431aa1e075d600c1303ac407d3cff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 73ba905bd86387d657212080e7749bc8d742d16fe1fa806d787560a57b189ad233f2e2f53d857fdb052c6541615b28b96d873fa83d89849fb2bfd15559c23b64
|
7
|
+
data.tar.gz: 42a23d1c472498925861acbbe8e13901f480f20119dbec0c1953a7f770a53647a7cdf4f920877d19825476c4c996a4bb3f3301fbf15f760820b33ab0dc67217b
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
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,12 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in ib-extensions.gemspec
|
4
|
+
gemspec
|
5
|
+
#gem "active-orient", git: "https://github.com/topofocus/active-orient"
|
6
|
+
#gem "active-orient", path: "/home/dev/activeorient/"
|
7
|
+
#gem 'orientdb-time-graph', path: '/home/dev/orientdb_time_graph/'
|
8
|
+
|
9
|
+
#gem 'ib-api', path: '../ib-api/'
|
10
|
+
#gem 'ib-extensions'
|
11
|
+
## move this to gemspec and include as development dependency after the gem is released
|
12
|
+
gem "rake", "~> 12.0"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ib-orientdb (1.0)
|
5
|
+
active-orient (~> 0.8)
|
6
|
+
ib-api (~> 972.1)
|
7
|
+
ib-extensions
|
8
|
+
orientdb-time-graph
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
active-orient (0.80)
|
14
|
+
activemodel
|
15
|
+
activesupport
|
16
|
+
pond
|
17
|
+
rest-client
|
18
|
+
activemodel (6.1.0)
|
19
|
+
activesupport (= 6.1.0)
|
20
|
+
activesupport (6.1.0)
|
21
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
22
|
+
i18n (>= 1.6, < 2)
|
23
|
+
minitest (>= 5.1)
|
24
|
+
tzinfo (~> 2.0)
|
25
|
+
zeitwerk (~> 2.3)
|
26
|
+
coderay (1.1.3)
|
27
|
+
concurrent-ruby (1.1.7)
|
28
|
+
diff-lcs (1.4.4)
|
29
|
+
domain_name (0.5.20190701)
|
30
|
+
unf (>= 0.0.5, < 1.0.0)
|
31
|
+
ffi (1.14.2)
|
32
|
+
formatador (0.2.5)
|
33
|
+
guard (2.16.2)
|
34
|
+
formatador (>= 0.2.4)
|
35
|
+
listen (>= 2.7, < 4.0)
|
36
|
+
lumberjack (>= 1.0.12, < 2.0)
|
37
|
+
nenv (~> 0.1)
|
38
|
+
notiffany (~> 0.0)
|
39
|
+
pry (>= 0.9.12)
|
40
|
+
shellany (~> 0.0)
|
41
|
+
thor (>= 0.18.1)
|
42
|
+
guard-compat (1.2.1)
|
43
|
+
guard-rspec (4.7.3)
|
44
|
+
guard (~> 2.1)
|
45
|
+
guard-compat (~> 1.1)
|
46
|
+
rspec (>= 2.99.0, < 4.0)
|
47
|
+
http-accept (1.7.0)
|
48
|
+
http-cookie (1.0.3)
|
49
|
+
domain_name (~> 0.5)
|
50
|
+
i18n (1.8.5)
|
51
|
+
concurrent-ruby (~> 1.0)
|
52
|
+
ib-api (972.1)
|
53
|
+
activemodel
|
54
|
+
activesupport (>= 6.0)
|
55
|
+
ib-extensions (1.0)
|
56
|
+
ox
|
57
|
+
listen (3.3.3)
|
58
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
59
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
60
|
+
lumberjack (1.2.8)
|
61
|
+
method_source (1.0.0)
|
62
|
+
mime-types (3.3.1)
|
63
|
+
mime-types-data (~> 3.2015)
|
64
|
+
mime-types-data (3.2020.1104)
|
65
|
+
minitest (5.14.2)
|
66
|
+
nenv (0.3.0)
|
67
|
+
netrc (0.11.0)
|
68
|
+
notiffany (0.1.3)
|
69
|
+
nenv (~> 0.1)
|
70
|
+
shellany (~> 0.0)
|
71
|
+
orientdb-time-graph (0.7)
|
72
|
+
active-orient
|
73
|
+
ox (2.14.0)
|
74
|
+
pond (0.5.0)
|
75
|
+
pry (0.13.1)
|
76
|
+
coderay (~> 1.1)
|
77
|
+
method_source (~> 1.0)
|
78
|
+
rake (12.3.3)
|
79
|
+
rb-fsevent (0.10.4)
|
80
|
+
rb-inotify (0.10.1)
|
81
|
+
ffi (~> 1.0)
|
82
|
+
rest-client (2.1.0)
|
83
|
+
http-accept (>= 1.7.0, < 2.0)
|
84
|
+
http-cookie (>= 1.0.2, < 2.0)
|
85
|
+
mime-types (>= 1.16, < 4.0)
|
86
|
+
netrc (~> 0.8)
|
87
|
+
rspec (3.10.0)
|
88
|
+
rspec-core (~> 3.10.0)
|
89
|
+
rspec-expectations (~> 3.10.0)
|
90
|
+
rspec-mocks (~> 3.10.0)
|
91
|
+
rspec-collection_matchers (1.2.0)
|
92
|
+
rspec-expectations (>= 2.99.0.beta1)
|
93
|
+
rspec-core (3.10.0)
|
94
|
+
rspec-support (~> 3.10.0)
|
95
|
+
rspec-expectations (3.10.0)
|
96
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
+
rspec-support (~> 3.10.0)
|
98
|
+
rspec-its (1.3.0)
|
99
|
+
rspec-core (>= 3.0.0)
|
100
|
+
rspec-expectations (>= 3.0.0)
|
101
|
+
rspec-mocks (3.10.0)
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
+
rspec-support (~> 3.10.0)
|
104
|
+
rspec-support (3.10.0)
|
105
|
+
shellany (0.0.1)
|
106
|
+
thor (1.0.1)
|
107
|
+
tzinfo (2.0.4)
|
108
|
+
concurrent-ruby (~> 1.0)
|
109
|
+
unf (0.1.4)
|
110
|
+
unf_ext
|
111
|
+
unf_ext (0.0.7.7)
|
112
|
+
zeitwerk (2.4.2)
|
113
|
+
|
114
|
+
PLATFORMS
|
115
|
+
ruby
|
116
|
+
|
117
|
+
DEPENDENCIES
|
118
|
+
bundler (~> 2.0)
|
119
|
+
guard
|
120
|
+
guard-rspec
|
121
|
+
ib-orientdb!
|
122
|
+
rake (~> 12.0)
|
123
|
+
rspec (~> 3.0)
|
124
|
+
rspec-collection_matchers
|
125
|
+
rspec-its
|
126
|
+
|
127
|
+
BUNDLED WITH
|
128
|
+
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/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 ib-ruby
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# IB-OrientDB
|
2
|
+
|
3
|
+
---
|
4
|
+
__Documentation: [https://ib-ruby.github.io/ib-doc/](https://ib-ruby.github.io/ib-doc/)__
|
5
|
+
|
6
|
+
__Questions, Contributions, Remarks: [Discussions are opened in ib-api](https://github.com/ib-ruby/ib-api/discussions)__
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**[OrientDB](https://orientdb.org/)** is a **N**ot **O**nly **SQL** Database owned and maintained by SAP.
|
11
|
+
|
12
|
+
It aims to be "the first Multi-Model Open Source NOSQL DBMS that brings together the power of graphs and the flexibility of documents into one scalable high-performance operational database."( [source](https://orientdb.org/docs/3.0.x/) )
|
13
|
+
|
14
|
+
**_IB-OrientDB_** connects a running [IB-api-client](https://github.com/ib-ruby/ib-api) to a running _OrientDB-Database-Server_ and provides
|
15
|
+
methods to store data provided by the _Interactive Brokers TWS_ into the database and to retrieve them as well.
|
16
|
+
|
17
|
+
It replaces core functions of **ib-gateway** from the [IB-Extensions-Gem](https://github.com/ib-ruby/ib-extensions)
|
18
|
+
|
19
|
+
|
20
|
+
## Store a contract in the database, query and ask the TWS for historical data
|
21
|
+
|
22
|
+
``` ruby
|
23
|
+
> ge = IB::Stock.new symbol: 'GE'
|
24
|
+
> ge.verify.first.save => <Stock: GE USD NYSE>
|
25
|
+
> puts IB::Stock.where(symbol: 'GE').eod( duration: 5).to_human
|
26
|
+
# INFO->MATCH {class: ib_stock, as: ib_stocks, where: ( symbol = 'GE') } RETURN ib_stocks
|
27
|
+
<Bar: 2020-11-23 wap 10.127 OHLC 9.76 10.27 9.76 10.25 trades 116355 vol 1025063>
|
28
|
+
<Bar: 2020-11-24 wap 10.574 OHLC 10.27 10.85 10.14 10.54 trades 204947 vol 1729882>
|
29
|
+
<Bar: 2020-11-25 wap 10.479 OHLC 10.55 10.6 10.34 10.51 trades 120367 vol 1063415>
|
30
|
+
<Bar: 2020-11-27 wap 10.403 OHLC 10.5 10.65 10.31 10.41 trades 73036 vol 529140>
|
31
|
+
<Bar: 2020-11-30 wap 10.215 OHLC 10.37 10.43 9.96 10.24 trades 134117 vol 1173670>
|
32
|
+
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
**Work in Progress**
|
40
|
+
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,99 @@
|
|
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
|
+
require 'ib-orientdb'
|
13
|
+
require 'logger'
|
14
|
+
|
15
|
+
|
16
|
+
class Array
|
17
|
+
# enables calling members of an array. which are hashes by it name
|
18
|
+
# i.e
|
19
|
+
#
|
20
|
+
# 2.5.0 :006 > C.received[:OpenOrder].local_id
|
21
|
+
# => [16, 17, 21, 20, 19, 8, 7]
|
22
|
+
# 2.5.0 :007 > C.received[:OpenOrder].contract.to_human
|
23
|
+
# => ["<Bag: IECombo SMART USD legs: >", "<Stock: GE USD>", "<Stock: GE USD>", "<Stock: GE USD>", "<Stock: GE USD>", "<Stock: WFC USD>", "<Stock: WFC USD>"]
|
24
|
+
#
|
25
|
+
# its included only in the console, for inspection purposes
|
26
|
+
|
27
|
+
def method_missing(method, *key)
|
28
|
+
unless method == :to_hash || method == :to_str #|| method == :to_int
|
29
|
+
return self.map{|x| x.public_send(method, *key)}
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end # Array
|
34
|
+
|
35
|
+
|
36
|
+
# read items from console.yml
|
37
|
+
read_yml = -> (key) do
|
38
|
+
YAML::load_file( File.expand_path('../../connect.yml',__FILE__))[key]
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
puts
|
43
|
+
puts ">> IB-OrientDB Interactive Console <<"
|
44
|
+
puts '-'* 45
|
45
|
+
puts
|
46
|
+
puts " ... preparing environment"
|
47
|
+
include LogDev
|
48
|
+
include IB
|
49
|
+
require 'irb'
|
50
|
+
|
51
|
+
environment = ARGV[0] || 'Development'
|
52
|
+
environment = case environment
|
53
|
+
when /^[pP]/
|
54
|
+
:production
|
55
|
+
when /^[dD]/
|
56
|
+
:development
|
57
|
+
when /^[tT]/
|
58
|
+
:test
|
59
|
+
end
|
60
|
+
tws = read_yml[:tws][environment]
|
61
|
+
orientdb = read_yml[:orientdb][environment]
|
62
|
+
|
63
|
+
ARGV.clear
|
64
|
+
logger = default_logger # Logger.new STDOUT
|
65
|
+
|
66
|
+
## The Block takes instructions which are executed after initializing all instance-variables
|
67
|
+
## and prior to the connection-process
|
68
|
+
## Here we just subscribe to some events
|
69
|
+
|
70
|
+
module TG; end
|
71
|
+
ActiveOrient::Model.keep_models_without_file = false
|
72
|
+
|
73
|
+
Setup.connect( tws: tws, orientdb: orientdb) do |c|
|
74
|
+
puts '-'* 83
|
75
|
+
print '-'* 35
|
76
|
+
print " TWS Connect "
|
77
|
+
puts '-'* 35
|
78
|
+
c.subscribe( :ContractData, :BondContractData) { |msg| logger.info { msg.contract.to_human } }
|
79
|
+
c.subscribe( :Alert, :ContractDataEnd, :ManagedAccounts, :OrderStatus ) {| m| logger.info { m.to_human } }
|
80
|
+
c.subscribe( :PortfolioValue, :AccountValue, :OrderStatus, :OpenOrderEnd, :ExecutionData ) {| m| logger.info { m.to_human }}
|
81
|
+
|
82
|
+
c.logger.level = Logger::INFO
|
83
|
+
end
|
84
|
+
|
85
|
+
C = IB::Connection.current
|
86
|
+
puts ActiveOrient::show_classes
|
87
|
+
|
88
|
+
|
89
|
+
puts ">> IB-OrientDB Interactive Console is ready -- using #{environment.to_s.upcase} environment <<"
|
90
|
+
puts '-'* 45
|
91
|
+
puts
|
92
|
+
puts "Namespace is IB ! "
|
93
|
+
puts
|
94
|
+
puts "----> C points to the Connection-Instance"
|
95
|
+
puts
|
96
|
+
puts "some basic Messages are subscribed and accordingly displayed"
|
97
|
+
puts
|
98
|
+
puts '-'* 45
|
99
|
+
IRB.start(__FILE__)
|