bingx 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +8 -0
- data/lib/bingx/client.rb +36 -13
- data/lib/bingx/requests/trade.rb +11 -0
- data/lib/bingx/version.rb +1 -1
- data/lib/bingx.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 378b4b73c5b70f16d39d8976ac1d4705d610e1d0ffb6eaa57dc118cedf781b2e
|
4
|
+
data.tar.gz: 83083f8b07415306daafbacb1b8c808332b0f6b367908cfd42a391a1974915bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3be52016430bb2b913f5b5875af3cc1d32b8b92846e1da8d9a6e6067a30c798421cdd9e94fabff22c3b170aee2cf783d2c9fe1aab6653754754806f16be03934
|
7
|
+
data.tar.gz: cfa2f02647825ae9cebb3b3da396c96a84484cf0e6c4ffb4aee9b8083c92c18acaf9f3d559b682cadd5963aec6b6cbcf44a03a9071d233fdb5f4c22a86c3337d
|
data/README.md
CHANGED
data/lib/bingx/client.rb
CHANGED
@@ -4,38 +4,61 @@ module Bingx
|
|
4
4
|
class Client
|
5
5
|
include HTTParty
|
6
6
|
include Requests::Account
|
7
|
+
include Requests::Trade
|
7
8
|
|
8
|
-
attr_accessor :api_key, :secret_key, :
|
9
|
+
attr_accessor :api_key, :secret_key, :base_url
|
9
10
|
|
10
11
|
base_uri 'https://open-api.bingx.com'
|
11
12
|
debug_output $stdout
|
12
13
|
|
13
|
-
def initialize(api_key:, secret_key
|
14
|
+
def initialize(api_key:, secret_key:)
|
14
15
|
@api_key = api_key
|
15
16
|
@secret_key = secret_key
|
16
|
-
@
|
17
|
+
@base_url = 'https://open-api.bingx.com'
|
17
18
|
end
|
18
19
|
|
19
20
|
def request(method, endpoint, payload = {})
|
21
|
+
public_send(method, endpoint, payload)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get(endpoint, payload = {})
|
20
25
|
headers = { 'X-BX-APIKEY': api_key }
|
21
|
-
|
22
|
-
|
26
|
+
|
27
|
+
payload.merge!(timestamp: DateTime.now.strftime('%Q'))
|
28
|
+
payload = HTTParty::HashConversions.to_params(payload)
|
29
|
+
payload += "&signature=#{signature(payload)}"
|
30
|
+
|
31
|
+
response = self.class.get(endpoint, query: payload, headers: headers)
|
23
32
|
response.body
|
24
33
|
end
|
25
34
|
|
26
|
-
|
35
|
+
# rubocop:disable Metrics/AbcSize
|
36
|
+
def post(endpoint, payload = {})
|
37
|
+
payload.merge!(timestamp: DateTime.now.strftime('%Q'))
|
38
|
+
params = parse_params(payload)
|
39
|
+
full_url = URI("#{base_url}#{endpoint}?#{params}&signature=#{signature(params)}")
|
27
40
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
)
|
33
|
-
|
34
|
-
|
41
|
+
https = Net::HTTP.new(full_url.host, full_url.port)
|
42
|
+
https.set_debug_output($stdout)
|
43
|
+
https.use_ssl = true
|
44
|
+
|
45
|
+
request = Net::HTTP::Post.new(full_url)
|
46
|
+
request['X-BX-APIKEY'] = api_key
|
47
|
+
request['Content-Type'] = 'application/json'
|
48
|
+
|
49
|
+
response = https.request(request)
|
50
|
+
puts response.read_body
|
35
51
|
end
|
52
|
+
# rubocop:enable Metrics/AbcSize
|
53
|
+
|
54
|
+
private
|
36
55
|
|
37
56
|
def signature(payload)
|
38
57
|
OpenSSL::HMAC.hexdigest('sha256', secret_key, payload)
|
39
58
|
end
|
59
|
+
|
60
|
+
def parse_params(params)
|
61
|
+
params.keys.sort.map { |x| "#{x}=#{params[x]}" }.join('&')
|
62
|
+
end
|
40
63
|
end
|
41
64
|
end
|
data/lib/bingx/version.rb
CHANGED
data/lib/bingx.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bingx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georgy Yuriev
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/bingx.rb
|
40
40
|
- lib/bingx/client.rb
|
41
41
|
- lib/bingx/requests/account.rb
|
42
|
+
- lib/bingx/requests/trade.rb
|
42
43
|
- lib/bingx/version.rb
|
43
44
|
- sig/bingx.rbs
|
44
45
|
homepage: https://rubygems.org/gems/bingx
|