bridgetown-ib-ruby 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +75 -0
- data/Rakefile +11 -0
- data/bridgetown-ib-ruby.gemspec +27 -0
- data/lib/bridgetown-ib-ruby/initializer.rb +33 -0
- data/lib/bridgetown-ib-ruby/version.rb +5 -0
- data/lib/bridgetown-ib-ruby.rb +4 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5b1a4dcf5b93c877b42a689cc199cf4bcd46cdc7fe79dc1d7d39cb77671e9ce0
|
4
|
+
data.tar.gz: 5066cb22b59f38c87875a114a62297b6d3d3e89ed282f77cca32a5d952b2cdd3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 232d45f1e452b2c0520db7d83c3cc18f12dd245b0171aad478d76f4c9d789ac78eb74f7de30affbb93df8438fcf4930b7c91a4816f5082e994ae27c299d45670
|
7
|
+
data.tar.gz: a213a3bd5fa50333c1d62585c5e25d8826dca36a2c269bdb1e7d5e6728bc95f4b7f6409ce8c78416f1c2f70ba23f34685e7d7b093fe337da30015021daced9f5
|
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/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## 0.2 - 2023-01-16
|
9
|
+
|
10
|
+
Clarify Readme and push Gem to RubyGems
|
11
|
+
|
12
|
+
## 0.1 - 2023-01-11
|
13
|
+
|
14
|
+
- First version
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Hartmut Bischoff
|
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/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022-present Jared White and Bridgetown Contributors
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Bridgetown IB-Ruby plugin
|
2
|
+
|
3
|
+
This plugin enables the interaction with the TWS-API of Interactive Brokers
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
$ bundle add bridgetown-ib-ruby
|
9
|
+
```
|
10
|
+
|
11
|
+
Then add a file `tws.yml` to the config directory. This is an example:
|
12
|
+
|
13
|
+
```
|
14
|
+
# TWS/Gateway
|
15
|
+
#
|
16
|
+
# Its assumed, that the TWS/IbGateway is running on localhost.
|
17
|
+
# Enter Port values
|
18
|
+
# 4001/7696 for active accounts
|
19
|
+
# 4002/7697 for demo accounts
|
20
|
+
---
|
21
|
+
get_account_data: true
|
22
|
+
serial_array: false
|
23
|
+
port: 4002
|
24
|
+
watchlists:
|
25
|
+
- :Spreads
|
26
|
+
- :Stillhalter
|
27
|
+
- :BuyAndHold
|
28
|
+
:client_id: 2001
|
29
|
+
|
30
|
+
```
|
31
|
+
|
32
|
+
## Include in the Initializer
|
33
|
+
|
34
|
+
The Bridgetown-Initializer parses `config/initializers` for each environment. If the console (`bin/bt c`) is run,
|
35
|
+
the file is parsed once. If the development-server is used (`bin/bt s`) the initializer is parsed to render static pages
|
36
|
+
and once again in server-mode. We have to prevent the first run:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
# in config/initialisers.rb
|
40
|
+
only :server, :console do
|
41
|
+
init :"bridgetown-ib-ruby"
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
If IB-Ruby-Objects should be present in `server` and `static` mode, **omit the setting of client_id**. Then `IB::Connection`
|
46
|
+
connects with an arbitrary client-id and `Bridgetown` runs two instances of the software.
|
47
|
+
|
48
|
+
## Access ib-ruby-Objects
|
49
|
+
|
50
|
+
`IB::Gateway`-methods are present via `IB::Gateway.current`.
|
51
|
+
To rely on [ib-api](https://github.com/ib-ruby/ib-api) the `IB::Connection`-object is present via `IB::Connection.current`.
|
52
|
+
|
53
|
+
IB::Contracts (IB::Stock, IB::Option, IB::Future, IB::Forex, ...) and IB::Spreads (IB::Strangle, IB::Straddle, IB::Calendar ...)
|
54
|
+
are available.
|
55
|
+
IB::Symbols and Watchlists are present as well as enhanced order-types ( IB::Limit.order, IB::Stop.order ...)
|
56
|
+
|
57
|
+
## Limitations
|
58
|
+
|
59
|
+
Bridgetown depends on the outdated `terminal-table` Version 1.8. IB-Ruby uses features of
|
60
|
+
the actual version in the `.as_table`-method. This is not available for now. Just use the
|
61
|
+
fallback `.to_human`.
|
62
|
+
|
63
|
+
## Additional Infos
|
64
|
+
There is a blog entry on [topofocus.de](https://topofocus.de) (in german): https://topofocus.de/blog/bridgtown-plugin/
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it (https://github.com/bridgetownrb/bridgetown-activerecord/fork)
|
71
|
+
2. Clone the fork using `git clone` to your local development machine.
|
72
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
74
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
75
|
+
6. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/bridgetown-ib-ruby/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bridgetown-ib-ruby"
|
7
|
+
spec.version = BridgetownIbRuby::VERSION
|
8
|
+
spec.author = "Dr. Hartmut Bischoff"
|
9
|
+
spec.email = "topofocus@gmail.com"
|
10
|
+
spec.summary = "Plugin to access the Interactive Brokers TWS-API from Bridgetown"
|
11
|
+
spec.homepage = "https://github.com/topofocus/bridgetown-ib-ruby"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
|
15
|
+
spec.test_files = spec.files.grep(%r!^test/!)
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
# spec.required_ruby_version = ">= 3.1.2"
|
19
|
+
|
20
|
+
spec.add_dependency "bridgetown", ">= 1.2.0.beta4", "< 2.0"
|
21
|
+
spec.add_dependency "ib-api"
|
22
|
+
spec.add_dependency "ib-symbols"
|
23
|
+
spec.add_dependency "ib-extensions"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler"
|
26
|
+
spec.add_development_dependency "rake", ">= 13.0"
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ib-gateway'
|
4
|
+
require 'ib/market-price'
|
5
|
+
require 'ib/option-chain'
|
6
|
+
require 'ib/eod'
|
7
|
+
require 'ib/symbols'
|
8
|
+
|
9
|
+
module BridgetownIbRuby
|
10
|
+
|
11
|
+
def self.gateway_configuration(config)
|
12
|
+
# Reads a YAML configuration file, evaluating any ERB, then parsing the resulting YAML.
|
13
|
+
ActiveSupport::ConfigurationFile.parse(File.join(config.root_dir, "config", "tws.yml")).merge( logger: log_writer )
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.the_gateway config
|
17
|
+
IB::Gateway.new **BridgetownIbRuby.gateway_configuration(config) do |gw|
|
18
|
+
gw.logger.level = Logger::INFO
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.log_writer
|
23
|
+
Bridgetown::LogWriter.new.tap(&:enable_prefix)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Bridgetown.initializer :"bridgetown-ib-ruby" do | config |
|
28
|
+
begin
|
29
|
+
BridgetownIbRuby.the_gateway( config )
|
30
|
+
rescue IB::TransmissionError, Errno::ECONNRESET => e
|
31
|
+
puts "END Through Error"
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bridgetown-ib-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dr. Hartmut Bischoff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bridgetown
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0.beta4
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.2.0.beta4
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ib-api
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: ib-symbols
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: ib-extensions
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: bundler
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '13.0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '13.0'
|
103
|
+
description:
|
104
|
+
email: topofocus@gmail.com
|
105
|
+
executables: []
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- ".gitignore"
|
110
|
+
- CHANGELOG.md
|
111
|
+
- Gemfile
|
112
|
+
- LICENSE
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- bridgetown-ib-ruby.gemspec
|
117
|
+
- lib/bridgetown-ib-ruby.rb
|
118
|
+
- lib/bridgetown-ib-ruby/initializer.rb
|
119
|
+
- lib/bridgetown-ib-ruby/version.rb
|
120
|
+
homepage: https://github.com/topofocus/bridgetown-ib-ruby
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubygems_version: 3.3.7
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Plugin to access the Interactive Brokers TWS-API from Bridgetown
|
143
|
+
test_files: []
|