irix 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/irix.rb +1 -0
- data/lib/irix/bitfinex.rb +1 -1
- data/lib/irix/hooks.rb +1 -0
- data/lib/irix/huobi.rb +82 -0
- data/lib/irix/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c95445e49c906a31bbc9e16f2b4b78ca8d023fca73f5d29128d9531ab0112c18
|
4
|
+
data.tar.gz: 79e6e7f4d815726d6624e4d79c0a0d8db2ebed9bda2534645c29b40bbffbf7d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0509583f671a0de4396eaec6ae5cc524e0bf4924afb4186c7efa6487dfff53fcc657eccfdf53158a1e81deb3e24b7937a066a4c0e65669b209fda92c1c507133'
|
7
|
+
data.tar.gz: d77b1f4410a5ff9d7ce1268aa30ea7e16556534f5684b3b14ddb241c6d9774e4c19518d92484d34cb8525818b53c3af72954f48eaf7782c1467bf6d3eef2b8d5
|
data/Gemfile.lock
CHANGED
data/lib/irix.rb
CHANGED
data/lib/irix/bitfinex.rb
CHANGED
data/lib/irix/hooks.rb
CHANGED
data/lib/irix/huobi.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Irix
|
4
|
+
class Huobi < Peatio::Upstream::Base
|
5
|
+
# WS huobi global
|
6
|
+
# websocket: "wss://api.huobi.pro/ws/"
|
7
|
+
# WS for krw markets
|
8
|
+
# websocket: "wss://api-cloud.huobi.co.kr/ws/"
|
9
|
+
|
10
|
+
def initialize(config)
|
11
|
+
super
|
12
|
+
@connection = Faraday.new(url: (config['rest']).to_s) do |builder|
|
13
|
+
builder.response :json
|
14
|
+
builder.response :logger if config['debug']
|
15
|
+
builder.adapter(@adapter)
|
16
|
+
unless config['verify_ssl'].nil?
|
17
|
+
builder.ssl[:verify] = config['verify_ssl']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@ping_set = false
|
21
|
+
@rest = (config['rest']).to_s
|
22
|
+
@ws_url = (config['websocket']).to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def ws_read_message(msg)
|
26
|
+
data = Zlib::GzipReader.new(StringIO.new(msg.data.map(&:chr).join)).read
|
27
|
+
Rails.logger.debug { "received websocket message: #{data}" }
|
28
|
+
|
29
|
+
object = JSON.parse(data)
|
30
|
+
ws_read_public_message(object)
|
31
|
+
end
|
32
|
+
|
33
|
+
def ws_read_public_message(msg)
|
34
|
+
if msg['ping'].present?
|
35
|
+
@ws.send(JSON.dump('pong': msg['ping']))
|
36
|
+
return
|
37
|
+
end
|
38
|
+
|
39
|
+
case msg['ch']
|
40
|
+
when /market\.([^.]+)\.trade\.detail/
|
41
|
+
detect_trade(msg.dig('tick', 'data'))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def detect_trade(msg)
|
46
|
+
msg.map do |t|
|
47
|
+
trade =
|
48
|
+
{
|
49
|
+
'tid' => t['tradeId'],
|
50
|
+
'amount' => t['amount'].to_d,
|
51
|
+
'price' => t['price'].to_d,
|
52
|
+
'date' => t['ts'] / 1000,
|
53
|
+
'taker_type' => t['direction']
|
54
|
+
}
|
55
|
+
notify_public_trade(trade)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def ws_connect
|
60
|
+
super
|
61
|
+
return if @ping_set
|
62
|
+
|
63
|
+
Fiber.new do
|
64
|
+
EM::Synchrony.add_periodic_timer(80) do
|
65
|
+
@ws.send(JSON.dump('ping' => Time.now.to_i))
|
66
|
+
end
|
67
|
+
end.resume
|
68
|
+
@ping_set = true
|
69
|
+
end
|
70
|
+
|
71
|
+
def subscribe_trades(market, ws)
|
72
|
+
sub = {
|
73
|
+
'sub' => "market.#{market}.trade.detail"
|
74
|
+
}
|
75
|
+
|
76
|
+
Rails.logger.info 'Open event' + sub.to_s
|
77
|
+
EM.next_tick do
|
78
|
+
ws.send(JSON.generate(sub))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/irix/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naichuk M.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-synchrony
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- lib/irix.rb
|
257
257
|
- lib/irix/bitfinex.rb
|
258
258
|
- lib/irix/hooks.rb
|
259
|
+
- lib/irix/huobi.rb
|
259
260
|
- lib/irix/railtie.rb
|
260
261
|
- lib/irix/version.rb
|
261
262
|
homepage: https://www.openware.com
|