bibox 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +24 -24
- data/bibox.gemspec +3 -3
- data/bin/websocket +2 -2
- data/lib/bibox.rb +5 -0
- data/lib/bibox/version.rb +1 -1
- data/lib/bibox/websocket/client.rb +31 -15
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8986db1d579aa17da50d2dee9f419d81f9e3fb26f63de03fd830241c357be27c
|
4
|
+
data.tar.gz: b4e51c4e0990379d2906ca5970240e57e9c66439fadd7d4d9883cbab5746c0f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 011ab93a271422c1725c07427720fe177a7d5ed56c02133b63eec2c26664f081bc8aea9977cbffa839bcac6281083af9f64734384c50223db00fbd7b9f7979b9
|
7
|
+
data.tar.gz: 99cf68663a13a8090b204211c4dcce82bb08df89b7cc5ca597d8103606e1e566da346453f4625804653ca039ed257ad94c6c74dfdbe7e6ec034e097e6600dd75
|
data/Gemfile.lock
CHANGED
@@ -2,48 +2,48 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
bibox (0.1.2)
|
5
|
-
eventmachine (>= 1.2.
|
6
|
-
faraday (>= 0.
|
7
|
-
faraday_middleware (>= 0.
|
5
|
+
eventmachine (>= 1.2.7)
|
6
|
+
faraday (>= 0.15.4)
|
7
|
+
faraday_middleware (>= 0.13.1)
|
8
8
|
faye-websocket (>= 0.10.7)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
addressable (2.
|
13
|
+
addressable (2.6.0)
|
14
14
|
public_suffix (>= 2.0.2, < 4.0)
|
15
15
|
crack (0.4.3)
|
16
16
|
safe_yaml (~> 1.0.0)
|
17
17
|
diff-lcs (1.3)
|
18
|
-
eventmachine (1.2.
|
19
|
-
faraday (0.
|
18
|
+
eventmachine (1.2.7)
|
19
|
+
faraday (0.15.4)
|
20
20
|
multipart-post (>= 1.2, < 3)
|
21
|
-
faraday_middleware (0.
|
21
|
+
faraday_middleware (0.13.1)
|
22
22
|
faraday (>= 0.7.4, < 1.0)
|
23
23
|
faye-websocket (0.10.7)
|
24
24
|
eventmachine (>= 0.12.0)
|
25
25
|
websocket-driver (>= 0.5.1)
|
26
|
-
hashdiff (0.3.
|
26
|
+
hashdiff (0.3.8)
|
27
27
|
multipart-post (2.0.0)
|
28
|
-
public_suffix (3.0.
|
28
|
+
public_suffix (3.0.3)
|
29
29
|
rake (10.5.0)
|
30
|
-
rdoc (6.
|
31
|
-
rspec (3.
|
32
|
-
rspec-core (~> 3.
|
33
|
-
rspec-expectations (~> 3.
|
34
|
-
rspec-mocks (~> 3.
|
35
|
-
rspec-core (3.
|
36
|
-
rspec-support (~> 3.
|
37
|
-
rspec-expectations (3.
|
30
|
+
rdoc (6.1.1)
|
31
|
+
rspec (3.8.0)
|
32
|
+
rspec-core (~> 3.8.0)
|
33
|
+
rspec-expectations (~> 3.8.0)
|
34
|
+
rspec-mocks (~> 3.8.0)
|
35
|
+
rspec-core (3.8.0)
|
36
|
+
rspec-support (~> 3.8.0)
|
37
|
+
rspec-expectations (3.8.2)
|
38
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
-
rspec-support (~> 3.
|
40
|
-
rspec-mocks (3.
|
39
|
+
rspec-support (~> 3.8.0)
|
40
|
+
rspec-mocks (3.8.0)
|
41
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
-
rspec-support (~> 3.
|
43
|
-
rspec-support (3.
|
44
|
-
safe_yaml (1.0.
|
42
|
+
rspec-support (~> 3.8.0)
|
43
|
+
rspec-support (3.8.0)
|
44
|
+
safe_yaml (1.0.5)
|
45
45
|
vcr (4.0.0)
|
46
|
-
webmock (3.
|
46
|
+
webmock (3.5.1)
|
47
47
|
addressable (>= 2.3.6)
|
48
48
|
crack (>= 0.3.2)
|
49
49
|
hashdiff
|
@@ -64,4 +64,4 @@ DEPENDENCIES
|
|
64
64
|
webmock (~> 3.1)
|
65
65
|
|
66
66
|
BUNDLED WITH
|
67
|
-
1.
|
67
|
+
1.17.2
|
data/bibox.gemspec
CHANGED
@@ -21,11 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "faraday", ">= 0.
|
25
|
-
spec.add_dependency "faraday_middleware", ">= 0.
|
24
|
+
spec.add_dependency "faraday", ">= 0.15.4"
|
25
|
+
spec.add_dependency "faraday_middleware", ">= 0.13.1"
|
26
26
|
|
27
27
|
spec.add_dependency "faye-websocket", ">= 0.10.7"
|
28
|
-
spec.add_dependency "eventmachine", ">= 1.2.
|
28
|
+
spec.add_dependency "eventmachine", ">= 1.2.7"
|
29
29
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 1.16"
|
31
31
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/bin/websocket
CHANGED
@@ -33,8 +33,8 @@ class WebsocketWrapper
|
|
33
33
|
self.client.callbacks[:klines] = -> (data) { klines(data) }
|
34
34
|
end
|
35
35
|
|
36
|
-
def subscribe!(pairs: ["
|
37
|
-
self.client.subscribe_to_trading_pairs!
|
36
|
+
def subscribe!(pairs: ["4ETH_USDT"])
|
37
|
+
#self.client.subscribe_to_trading_pairs!
|
38
38
|
self.client.subscribe_to_order_book!(pairs: pairs)
|
39
39
|
self.client.subscribe_to_trades!(pairs: pairs)
|
40
40
|
self.client.subscribe_to_ticker!(pairs: pairs)
|
data/lib/bibox.rb
CHANGED
data/lib/bibox/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Bibox
|
2
2
|
module Websocket
|
3
|
-
# Websocket client for
|
3
|
+
# Websocket client for Bibox
|
4
4
|
class Client
|
5
5
|
attr_accessor :url, :prefix, :keepalive, :socket, :reactor_owner, :matchers, :callbacks
|
6
6
|
|
@@ -10,11 +10,11 @@ module Bibox
|
|
10
10
|
self.keepalive = options.fetch(:keepalive, false)
|
11
11
|
|
12
12
|
self.matchers = {
|
13
|
-
trading_pairs:
|
14
|
-
order_book:
|
15
|
-
trades:
|
16
|
-
ticker:
|
17
|
-
klines:
|
13
|
+
trading_pairs: /\d?[A-Z]+_[A-Z]+_market/,
|
14
|
+
order_book: /\d?[A-Z]+_[A-Z]+_depth$/,
|
15
|
+
trades: /\d?[A-Z]+_[A-Z]+_deals$/,
|
16
|
+
ticker: /\d?[A-Z]+_[A-Z]+_ticker$/,
|
17
|
+
klines: /\d?[A-Z]+_[A-Z]+_kline_(?<period>.*)$/
|
18
18
|
}
|
19
19
|
|
20
20
|
self.callbacks = {
|
@@ -55,14 +55,6 @@ module Bibox
|
|
55
55
|
self.socket.onclose = method(:on_close)
|
56
56
|
self.socket.onerror = method(:on_error)
|
57
57
|
end
|
58
|
-
|
59
|
-
def subscribe!
|
60
|
-
subscribe_to_trading_pairs!
|
61
|
-
subscribe_to_order_book!(pairs: ["BIX_BTC", "BIX_ETH"])
|
62
|
-
subscribe_to_trades!(pair: ["BIX_BTC", "BIX_ETH"])
|
63
|
-
subscribe_to_ticker!(pair: ["BIX_BTC", "BIX_ETH"])
|
64
|
-
subscribe_to_klines!(pair: ["BIX_BTC", "BIX_ETH"], periods: ["5min"])
|
65
|
-
end
|
66
58
|
|
67
59
|
def subscribe_to_trading_pairs!
|
68
60
|
subscribe_to! channel_name("ALL_ALL_market")
|
@@ -123,13 +115,37 @@ module Bibox
|
|
123
115
|
rescue => err
|
124
116
|
return data
|
125
117
|
end
|
118
|
+
|
119
|
+
def decode_and_inflate(data)
|
120
|
+
Zlib::GzipReader.new(StringIO.new(Base64.decode64(data))).read
|
121
|
+
end
|
122
|
+
|
123
|
+
def send_pong(timestamp)
|
124
|
+
self.socket.send({pong: timestamp}.to_json)
|
125
|
+
end
|
126
126
|
|
127
127
|
def on_open(_event)
|
128
128
|
self.callbacks[:subscribe].call
|
129
129
|
end
|
130
130
|
|
131
131
|
def on_message(event)
|
132
|
-
|
132
|
+
parsed = parse(event.data)
|
133
|
+
|
134
|
+
if parsed
|
135
|
+
if parsed.is_a?(Hash)
|
136
|
+
send_pong(parsed["ping"]) unless parsed.fetch("ping", nil).to_s.empty?
|
137
|
+
elsif parsed.is_a?(Array)
|
138
|
+
parsed = parsed.first
|
139
|
+
end
|
140
|
+
|
141
|
+
is_binary = parsed.fetch("binary", nil)&.eql?("1")
|
142
|
+
|
143
|
+
if is_binary && !parsed.fetch("data", nil).to_s.empty?
|
144
|
+
parsed["data"] = parse(decode_and_inflate(parsed["data"]))
|
145
|
+
end
|
146
|
+
|
147
|
+
self.callbacks[:message].call(parsed)
|
148
|
+
end
|
133
149
|
end
|
134
150
|
|
135
151
|
def on_close(_event)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Johnsson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.15.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.15.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday_middleware
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.13.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.13.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faye-websocket
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.2.
|
61
|
+
version: 1.2.7
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.2.
|
68
|
+
version: 1.2.7
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -224,8 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
- !ruby/object:Gem::Version
|
225
225
|
version: '0'
|
226
226
|
requirements: []
|
227
|
-
|
228
|
-
rubygems_version: 2.7.4
|
227
|
+
rubygems_version: 3.0.1
|
229
228
|
signing_key:
|
230
229
|
specification_version: 4
|
231
230
|
summary: Ruby REST + Websocket clients for Bibox's API'
|