bibox 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +6 -0
- data/bibox.gemspec +36 -0
- data/bin/console +31 -0
- data/bin/setup +8 -0
- data/bin/websocket +71 -0
- data/credentials.yml.example +7 -0
- data/lib/.DS_Store +0 -0
- data/lib/bibox.rb +74 -0
- data/lib/bibox/.DS_Store +0 -0
- data/lib/bibox/configuration.rb +21 -0
- data/lib/bibox/constants.rb +6 -0
- data/lib/bibox/errors.rb +17 -0
- data/lib/bibox/extensions/string.rb +13 -0
- data/lib/bibox/models/asset.rb +29 -0
- data/lib/bibox/models/base.rb +26 -0
- data/lib/bibox/models/bill.rb +26 -0
- data/lib/bibox/models/ohlcv.rb +16 -0
- data/lib/bibox/models/order.rb +38 -0
- data/lib/bibox/models/order_book.rb +29 -0
- data/lib/bibox/models/pair.rb +24 -0
- data/lib/bibox/models/ticker.rb +18 -0
- data/lib/bibox/models/trade.rb +13 -0
- data/lib/bibox/models/transfer.rb +26 -0
- data/lib/bibox/models/user_assets.rb +23 -0
- data/lib/bibox/rest/client.rb +97 -0
- data/lib/bibox/rest/errors.rb +16 -0
- data/lib/bibox/rest/private/assets.rb +33 -0
- data/lib/bibox/rest/private/bills.rb +31 -0
- data/lib/bibox/rest/private/order_book.rb +21 -0
- data/lib/bibox/rest/private/orders.rb +131 -0
- data/lib/bibox/rest/private/transfers.rb +49 -0
- data/lib/bibox/rest/public/klines.rb +22 -0
- data/lib/bibox/rest/public/order_book.rb +16 -0
- data/lib/bibox/rest/public/pairs.rb +23 -0
- data/lib/bibox/rest/public/ticker.rb +16 -0
- data/lib/bibox/rest/public/trades.rb +16 -0
- data/lib/bibox/utilities.rb +68 -0
- data/lib/bibox/version.rb +3 -0
- data/lib/bibox/websocket/client.rb +149 -0
- metadata +232 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 890b2879833d6aa42b6dda649ff4416546cff574309ff7fa802b5d649f9bb629
|
4
|
+
data.tar.gz: '082c82088f461bc47a329e546a113a842c2226ac4a6c9e4613e80982a18c8c3b'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f15d9758d9d59cd95b2c40e7268d937777256d5e2ea5fb957218c58df0bf21101eba42e3fcfff96d15a6da76d50e238da326cef97177eff12c8d395dc6eaaaa
|
7
|
+
data.tar.gz: e4da3aea086d11511e130baa678136e924d11df2991943ea1a31473e3e69c22e9ac1053d40b8b989746675758fea35d198b4f5389c363f47a2387bab57670638
|
data/.DS_Store
ADDED
Binary file
|
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 sebastian.johnsson@gmail.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 [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bibox (0.1.0)
|
5
|
+
eventmachine (>= 1.2.5)
|
6
|
+
faraday (>= 0.13)
|
7
|
+
faraday_middleware (>= 0.12.2)
|
8
|
+
faye-websocket (>= 0.10.7)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.5.2)
|
14
|
+
public_suffix (>= 2.0.2, < 4.0)
|
15
|
+
crack (0.4.3)
|
16
|
+
safe_yaml (~> 1.0.0)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
eventmachine (1.2.5)
|
19
|
+
faraday (0.14.0)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
faraday_middleware (0.12.2)
|
22
|
+
faraday (>= 0.7.4, < 1.0)
|
23
|
+
faye-websocket (0.10.7)
|
24
|
+
eventmachine (>= 0.12.0)
|
25
|
+
websocket-driver (>= 0.5.1)
|
26
|
+
hashdiff (0.3.7)
|
27
|
+
multipart-post (2.0.0)
|
28
|
+
public_suffix (3.0.1)
|
29
|
+
rake (10.5.0)
|
30
|
+
rdoc (6.0.1)
|
31
|
+
rspec (3.7.0)
|
32
|
+
rspec-core (~> 3.7.0)
|
33
|
+
rspec-expectations (~> 3.7.0)
|
34
|
+
rspec-mocks (~> 3.7.0)
|
35
|
+
rspec-core (3.7.1)
|
36
|
+
rspec-support (~> 3.7.0)
|
37
|
+
rspec-expectations (3.7.0)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.7.0)
|
40
|
+
rspec-mocks (3.7.0)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.7.0)
|
43
|
+
rspec-support (3.7.1)
|
44
|
+
safe_yaml (1.0.4)
|
45
|
+
vcr (4.0.0)
|
46
|
+
webmock (3.3.0)
|
47
|
+
addressable (>= 2.3.6)
|
48
|
+
crack (>= 0.3.2)
|
49
|
+
hashdiff
|
50
|
+
websocket-driver (0.7.0)
|
51
|
+
websocket-extensions (>= 0.1.0)
|
52
|
+
websocket-extensions (0.1.3)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
bibox!
|
59
|
+
bundler (~> 1.16)
|
60
|
+
rake (~> 10.0)
|
61
|
+
rdoc (~> 6.0)
|
62
|
+
rspec (~> 3.0)
|
63
|
+
vcr (~> 4.0)
|
64
|
+
webmock (~> 3.1)
|
65
|
+
|
66
|
+
BUNDLED WITH
|
67
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Sebastian
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Bibox REST + Websocket client in Ruby
|
2
|
+
|
3
|
+
This gem provides a REST client and a Websocket client to interact with the crypto currency exchange Bibox. Bibox is an up and coming exchange that's very similar to Binance and KuCoin.
|
4
|
+
|
5
|
+
## Getting started
|
6
|
+
|
7
|
+
First you'll need to get an account on Bibox, [click here to get one](https://www.bibox.com/login/register?id=11154920&lang=en).
|
8
|
+
|
9
|
+
After setting up your account, head to "Account Information", locate the "API" section and click on "Add".
|
10
|
+
Enter a name/comment for your key, e.g. "Bibox Ruby", and proceed to click on "Create".
|
11
|
+
Copy the API key and the secret that was just created for you.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'bibox'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install bibox
|
28
|
+
|
29
|
+
## Setup
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Bibox.configure do |config|
|
33
|
+
config.key = YOUR_API_KEY
|
34
|
+
config.secret = YOUR_API_SECRET
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
REST Client (see specs/source code for available methods/endpoints):
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
client = Bibox::Rest::Client.new
|
44
|
+
client.pairs
|
45
|
+
```
|
46
|
+
|
47
|
+
Websocket client
|
48
|
+
|
49
|
+
See bin/websocket for a reference implementation of websockets.
|
50
|
+
|
51
|
+
## Development
|
52
|
+
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
54
|
+
|
55
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bibox. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
64
|
+
|
65
|
+
## Code of Conduct
|
66
|
+
|
67
|
+
Everyone interacting in the Bibox project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/bibox/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bibox.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "bibox/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bibox"
|
8
|
+
spec.version = Bibox::VERSION
|
9
|
+
spec.authors = ["Sebastian Johnsson"]
|
10
|
+
spec.email = ["sebastian.johnsson@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby client for Bibox's API'}
|
13
|
+
spec.description = %q{Ruby REST client for crypto currency exchange Bibox}
|
14
|
+
spec.homepage = "https://github.com/SebastianJ/bibox"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "faraday", ">= 0.13"
|
25
|
+
spec.add_dependency "faraday_middleware", ">= 0.12.2"
|
26
|
+
|
27
|
+
spec.add_dependency "faye-websocket", ">= 0.10.7"
|
28
|
+
spec.add_dependency "eventmachine", ">= 1.2.5"
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
spec.add_development_dependency "rdoc", "~> 6.0"
|
34
|
+
spec.add_development_dependency "vcr", "~> 4.0"
|
35
|
+
spec.add_development_dependency "webmock", "~> 3.1"
|
36
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bibox"
|
5
|
+
require "yaml"
|
6
|
+
|
7
|
+
cfg_path = File.join(File.dirname(__FILE__), "../credentials.yml")
|
8
|
+
|
9
|
+
if ::File.exists?(cfg_path)
|
10
|
+
cfg = YAML.load_file(cfg_path).fetch("full_permissions", {})
|
11
|
+
|
12
|
+
Bibox.configure do |config|
|
13
|
+
config.key = cfg["key"]
|
14
|
+
config.secret = cfg["secret"]
|
15
|
+
|
16
|
+
config.faraday = {
|
17
|
+
user_agent: "Bibox Ruby",
|
18
|
+
verbose: true
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
24
|
+
# with your gem easier. You can also use a different console, if you like.
|
25
|
+
|
26
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
27
|
+
# require "pry"
|
28
|
+
# Pry.start
|
29
|
+
|
30
|
+
require "irb"
|
31
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/websocket
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bibox"
|
5
|
+
|
6
|
+
# Example implementation of websockets
|
7
|
+
|
8
|
+
class WebsocketWrapper
|
9
|
+
attr_accessor :client
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
self.client = ::Bibox::Websocket::Client.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def run!
|
16
|
+
begin
|
17
|
+
self.set_callbacks
|
18
|
+
self.client.start!
|
19
|
+
ensure
|
20
|
+
self.client.stop!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_callbacks
|
25
|
+
# Subscription callback
|
26
|
+
self.client.callbacks[:subscribe] = -> { subscribe! }
|
27
|
+
|
28
|
+
# Received messages callbacks
|
29
|
+
self.client.callbacks[:trading_pairs] = -> (data) { trading_pairs(data) }
|
30
|
+
self.client.callbacks[:order_book] = -> (data) { order_book(data) }
|
31
|
+
self.client.callbacks[:trades] = -> (data) { trades(data) }
|
32
|
+
self.client.callbacks[:ticker] = -> (data) { ticker(data) }
|
33
|
+
self.client.callbacks[:klines] = -> (data) { klines(data) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def subscribe!(pairs: ["BIX_ETH", "BIX_BTC"])
|
37
|
+
self.client.subscribe_to_trading_pairs!
|
38
|
+
self.client.subscribe_to_order_book!(pairs: pairs)
|
39
|
+
self.client.subscribe_to_trades!(pairs: pairs)
|
40
|
+
self.client.subscribe_to_ticker!(pairs: pairs)
|
41
|
+
self.client.subscribe_to_klines!(pairs: pairs, periods: ["5min"])
|
42
|
+
end
|
43
|
+
|
44
|
+
def trading_pairs(data)
|
45
|
+
puts "\nReceived trading pairs message!"
|
46
|
+
pp data
|
47
|
+
end
|
48
|
+
|
49
|
+
def order_book(data)
|
50
|
+
puts "\nReceived order book message!"
|
51
|
+
pp data
|
52
|
+
end
|
53
|
+
|
54
|
+
def trades(data)
|
55
|
+
puts "\nReceived trades message!"
|
56
|
+
pp data
|
57
|
+
end
|
58
|
+
|
59
|
+
def ticker(data)
|
60
|
+
puts "\nReceived ticker message!"
|
61
|
+
pp data
|
62
|
+
end
|
63
|
+
|
64
|
+
def klines(data)
|
65
|
+
puts "\nReceived klines message!"
|
66
|
+
pp data
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
WebsocketWrapper.new.run!
|