binance 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/binance/client/rest.rb +59 -20
- data/lib/binance/client/rest/account_api.rb +36 -32
- data/lib/binance/client/rest/api_endpoints.rb +24 -26
- data/lib/binance/client/rest/public_api.rb +15 -33
- data/lib/binance/client/rest/withdraw_api.rb +6 -29
- data/lib/binance/version.rb +1 -1
- metadata +8 -9
- data/lib/binance/client/rest/user_data_api.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b8366cc935a0035bd2e70601ee916f1cfdbc22d
|
4
|
+
data.tar.gz: 01a47ff596c0ebbc7c466a75ea6d0e831c584bc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 272b026095a34ec596cb50b1b9a37fa8e08324e8acf2285fd8829aa48498ad192a8452df21e4dd72827b53c19f96bda8ce9f9acc209ad63ac2a39b62afdc75d9
|
7
|
+
data.tar.gz: 0abed3c7a6528027df5228a010c674d2bca0712838dfb2c688212ef80813266d8ed098f81dbf079ae326825f48b3106e1d6da2d70fd6dec21ea2f0449ad11aeb
|
data/lib/binance/client/rest.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
|
2
2
|
require 'faraday'
|
3
|
-
|
3
|
+
require 'faraday_middleware'
|
4
|
+
|
5
|
+
require_relative 'rest/sign_request_middleware'
|
6
|
+
require_relative 'rest/timestamp_request_middleware'
|
7
|
+
|
4
8
|
require_relative 'rest/public_api'
|
5
9
|
require_relative 'rest/account_api'
|
6
10
|
require_relative 'rest/withdraw_api'
|
7
|
-
|
11
|
+
|
12
|
+
require_relative 'rest/api_endpoints'
|
8
13
|
|
9
14
|
module Binance
|
10
15
|
module Client
|
@@ -13,14 +18,9 @@ module Binance
|
|
13
18
|
# Public: String base url for REST client to use
|
14
19
|
BASE_URL = 'https://www.binance.com'.freeze
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
class << self
|
20
|
-
attr_accessor :api
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_reader :api_key, :secret_key, :adapter
|
21
|
+
include PublicAPI
|
22
|
+
include AccountAPI
|
23
|
+
include WithdrawAPI
|
24
24
|
|
25
25
|
# Public: Initialize a REST Client
|
26
26
|
#
|
@@ -32,18 +32,58 @@ module Binance
|
|
32
32
|
# (Default = Faraday.default_adapter).
|
33
33
|
def initialize(api_key: '', secret_key: '',
|
34
34
|
adapter: Faraday.default_adapter)
|
35
|
-
@
|
36
|
-
|
37
|
-
@
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
@library = {}
|
36
|
+
# Endpoint doesn't require an api_key or secret_key
|
37
|
+
@library[:public] = public_client adapter
|
38
|
+
# Endpoint requires an api_key
|
39
|
+
@library[:verified] = verified_client api_key, adapter
|
40
|
+
# Endpoint requires an api_key and secret_key
|
41
|
+
@library[:signed] = signed_client api_key, secret_key, adapter
|
42
|
+
# Endpoint requires an api_key and secret_key - for the Withdraw API
|
43
|
+
@library[:withdraw] = withdraw_client api_key, secret_key, adapter
|
44
|
+
|
43
45
|
end
|
44
46
|
|
45
47
|
private
|
46
48
|
|
49
|
+
def public_client(adapter)
|
50
|
+
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
51
|
+
conn.request :json
|
52
|
+
conn.response :json, content_type: /\bjson$/
|
53
|
+
conn.adapter adapter
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def signed_client(api_key, secret_key, adapter)
|
58
|
+
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
59
|
+
conn.request :json
|
60
|
+
conn.response :json, content_type: /\bjson$/
|
61
|
+
conn.headers['X-MBX-APIKEY'] = api_key
|
62
|
+
conn.use TimestampRequestMiddleware
|
63
|
+
conn.use SignRequestMiddleware, secret_key
|
64
|
+
conn.adapter adapter
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def withdraw_client(api_key, secret_key, adapter)
|
69
|
+
Faraday.new(url: "#{BASE_URL}/wapi") do |conn|
|
70
|
+
conn.request :url_encoded
|
71
|
+
conn.response :json, content_type: /\bjson$/
|
72
|
+
conn.headers['X-MBX-APIKEY'] = api_key
|
73
|
+
conn.use TimestampRequestMiddleware
|
74
|
+
conn.use SignRequestMiddleware, secret_key
|
75
|
+
conn.adapter adapter
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def verified_client(api_key, adapter)
|
80
|
+
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
81
|
+
conn.response :json, content_type: /\bjson$/
|
82
|
+
conn.headers['X-MBX-APIKEY'] = api_key
|
83
|
+
conn.adapter adapter
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
47
87
|
# Internal: Create a request that hits one of the REST APIs
|
48
88
|
#
|
49
89
|
# api - The Symbol that represents which API to use.
|
@@ -57,8 +97,7 @@ module Binance
|
|
57
97
|
# Each endpoint will have their own required and optional
|
58
98
|
# params.
|
59
99
|
def request(api, method, endpoint, options = {})
|
60
|
-
|
61
|
-
response = conn.send(method) do |req|
|
100
|
+
response = @library[api].send(method) do |req|
|
62
101
|
req.url API_ENDPOINTS[endpoint]
|
63
102
|
req.params.merge! options
|
64
103
|
end
|
@@ -1,32 +1,9 @@
|
|
1
1
|
|
2
|
-
require 'faraday'
|
3
|
-
require 'faraday_middleware'
|
4
|
-
require_relative 'sign_request_middleware'
|
5
|
-
require_relative 'timestamp_request_middleware'
|
6
|
-
|
7
2
|
module Binance
|
8
3
|
module Client
|
9
4
|
class REST
|
10
5
|
# Public: A module containing all of the Account API endpoints
|
11
|
-
module
|
12
|
-
# Internal: Create Lambda that returns a new Faraday client instance
|
13
|
-
# and add it to the REST class instance variable @api. This is called
|
14
|
-
# while a new instance of the REST class is created.
|
15
|
-
#
|
16
|
-
# base - The base class that is being extended into
|
17
|
-
def self.extended(base)
|
18
|
-
REST.api[:account] = lambda do
|
19
|
-
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
20
|
-
conn.request :json
|
21
|
-
conn.response :json, content_type: /\bjson$/
|
22
|
-
conn.headers['X-MBX-APIKEY'] = base.api_key
|
23
|
-
conn.use TimestampRequestMiddleware
|
24
|
-
conn.use SignRequestMiddleware, base.secret_key
|
25
|
-
conn.adapter base.adapter
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
6
|
+
module AccountAPI
|
30
7
|
# Public: Create a new order on the specified symbol for the
|
31
8
|
# authenticated account
|
32
9
|
#
|
@@ -55,7 +32,7 @@ module Binance
|
|
55
32
|
#
|
56
33
|
# Returns a Hash of the request response
|
57
34
|
def create_order(options)
|
58
|
-
request :
|
35
|
+
request :signed, :post, :order, options
|
59
36
|
end
|
60
37
|
|
61
38
|
# Public: Create a test order on the specified symbol for the
|
@@ -86,7 +63,7 @@ module Binance
|
|
86
63
|
#
|
87
64
|
# Returns a Hash of the request response
|
88
65
|
def create_test_order(options)
|
89
|
-
request :
|
66
|
+
request :signed, :post, :order_test, options
|
90
67
|
end
|
91
68
|
|
92
69
|
# Public: Query an orders status on the specified symbol for the
|
@@ -105,7 +82,7 @@ module Binance
|
|
105
82
|
#
|
106
83
|
# Returns a Hash of the request response
|
107
84
|
def query_order(options)
|
108
|
-
request :
|
85
|
+
request :signed, :get, :order, options
|
109
86
|
end
|
110
87
|
|
111
88
|
# Public: Cancel the order specified for the authenticated account.
|
@@ -125,7 +102,7 @@ module Binance
|
|
125
102
|
#
|
126
103
|
# Returns a Hash with the request response
|
127
104
|
def cancel_order(options)
|
128
|
-
request :
|
105
|
+
request :signed, :delete, :order, options
|
129
106
|
end
|
130
107
|
|
131
108
|
# Public: Retrieve open orders for the authenticated account
|
@@ -138,7 +115,7 @@ module Binance
|
|
138
115
|
#
|
139
116
|
# Returns a Hash with the request response
|
140
117
|
def open_orders(options)
|
141
|
-
request :
|
118
|
+
request :signed, :get, :openOrders, options
|
142
119
|
end
|
143
120
|
|
144
121
|
# Public: Retrieve all orders of the specified symbol for the
|
@@ -154,7 +131,7 @@ module Binance
|
|
154
131
|
#
|
155
132
|
# Returns a Hash with the request response
|
156
133
|
def all_orders(options)
|
157
|
-
request :
|
134
|
+
request :signed, :get, :allOrders, options
|
158
135
|
end
|
159
136
|
|
160
137
|
# Public: Retrieve account information for the authenticated account
|
@@ -165,7 +142,7 @@ module Binance
|
|
165
142
|
#
|
166
143
|
# Returns a Hash with the request response
|
167
144
|
def account_info(options = {})
|
168
|
-
request :
|
145
|
+
request :signed, :get, :account, options
|
169
146
|
end
|
170
147
|
|
171
148
|
# Public: Retrieve trade data of the specified symbol for the
|
@@ -180,7 +157,34 @@ module Binance
|
|
180
157
|
#
|
181
158
|
# Returns a Hash with the request response
|
182
159
|
def account_trade_list(options)
|
183
|
-
request :
|
160
|
+
request :signed, :get, :myTrades, options
|
161
|
+
end
|
162
|
+
|
163
|
+
# Public: Retrieve the listen key for the given api key
|
164
|
+
#
|
165
|
+
# Returns a Hash with the request response
|
166
|
+
def listen_key
|
167
|
+
request :verified, :post, :userDataStream
|
168
|
+
end
|
169
|
+
|
170
|
+
# Public: Ping the server to keep User Data stream alive
|
171
|
+
#
|
172
|
+
# options - The Hash which hosts various REST query params.
|
173
|
+
# :listen_key - The String of which stream to keep alive
|
174
|
+
#
|
175
|
+
# Returns a Hash with the request response
|
176
|
+
def keep_stream_alive(options)
|
177
|
+
request :verified, :put, :userDataStream, options
|
178
|
+
end
|
179
|
+
|
180
|
+
# Public: Close the User Data stream associated with the listen key
|
181
|
+
#
|
182
|
+
# options - The Hash which hosts various REST query params.
|
183
|
+
# :listen_key - The String of which stream to close
|
184
|
+
#
|
185
|
+
# Returns a Hash with the request response
|
186
|
+
def close_stream(options)
|
187
|
+
request :verified, :delete, :userDataStream, options
|
184
188
|
end
|
185
189
|
end
|
186
190
|
end
|
@@ -4,36 +4,34 @@ module Binance
|
|
4
4
|
class REST
|
5
5
|
API_ENDPOINTS = {
|
6
6
|
# Public API Endpoints
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
ping: 'v1/ping',
|
8
|
+
time: 'v1/time',
|
9
|
+
exchangeInfo: 'v1/exchangeInfo',
|
10
|
+
products: '/exchange/public/products',
|
11
|
+
depth: 'v1/depth',
|
12
|
+
trades: 'v1/trades',
|
13
|
+
historicalTrades: 'v1/historicalTrades',
|
14
|
+
aggTrades: 'v1/aggTrades',
|
15
|
+
klines: 'v1/klines',
|
16
|
+
twenty_four_hour: 'v1/ticker/24hr',
|
17
|
+
price: 'v3/ticker/price',
|
18
|
+
bookTicker: 'v3/ticker/bookTicker',
|
19
19
|
|
20
20
|
# Account API Endpoints
|
21
|
-
|
22
|
-
'
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
order: 'v3/order',
|
22
|
+
order_test: 'v3/order/test',
|
23
|
+
openOrders: 'v3/openOrders',
|
24
|
+
allOrders: 'v3/allOrders',
|
25
|
+
account: 'v3/account',
|
26
|
+
myTrades: 'v3/myTrades',
|
27
|
+
userDataStream: 'v1/userDataStream',
|
27
28
|
|
28
29
|
# Withdraw API Endpoints
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
# User Data Stream API Endpoints
|
36
|
-
'userDataStream' => 'v1/userDataStream'
|
30
|
+
withdraw: 'v3/withdraw.html',
|
31
|
+
depositHistory: 'v3/depositHistory.html',
|
32
|
+
withdrawHistory: 'v3/withdrawHistory.html',
|
33
|
+
depositAddress: 'v3/depositAddress.html',
|
34
|
+
accountStatus: 'v3/accountStatus.html'
|
37
35
|
}.freeze
|
38
36
|
end
|
39
37
|
end
|
@@ -1,46 +1,28 @@
|
|
1
1
|
|
2
|
-
require 'faraday'
|
3
|
-
require 'faraday_middleware'
|
4
|
-
|
5
2
|
module Binance
|
6
3
|
module Client
|
7
4
|
class REST
|
8
5
|
# Public: A Module containing all of the Public API endpoints
|
9
|
-
module
|
10
|
-
# Internal: Create Lambda that returns a new Faraday client instance
|
11
|
-
# and add it to the REST class instance variable @api. This is called
|
12
|
-
# while a new instance of the REST class is created.
|
13
|
-
#
|
14
|
-
# base - The base class that is being extended into.
|
15
|
-
def self.extended(base)
|
16
|
-
REST.api[:public] = lambda do
|
17
|
-
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
18
|
-
conn.request :json
|
19
|
-
conn.response :json, content_type: /\bjson$/
|
20
|
-
conn.adapter base.adapter
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
6
|
+
module PublicAPI
|
25
7
|
# Public: Ping the server to test connectivity
|
26
8
|
#
|
27
9
|
# Returns a Hash with the request response
|
28
10
|
def ping
|
29
|
-
request :public, :get,
|
11
|
+
request :public, :get, :ping
|
30
12
|
end
|
31
13
|
|
32
14
|
# Public: Retrieve the server time in milliseconds
|
33
15
|
#
|
34
16
|
# Returns a Hash with the request response
|
35
17
|
def time
|
36
|
-
request :public, :get,
|
18
|
+
request :public, :get, :time
|
37
19
|
end
|
38
20
|
|
39
21
|
# Public: Retrieve current exchange trading rules and symbol information
|
40
22
|
#
|
41
23
|
# Returns a Hash with the request response
|
42
24
|
def exchange_info
|
43
|
-
request :public, :get,
|
25
|
+
request :public, :get, :exchangeInfo
|
44
26
|
end
|
45
27
|
|
46
28
|
# Public: Retrieve current exchange asset information. This is an
|
@@ -48,7 +30,7 @@ module Binance
|
|
48
30
|
#
|
49
31
|
# Returns a Hash with the request response
|
50
32
|
def products
|
51
|
-
request :public, :get,
|
33
|
+
request :public, :get, :products
|
52
34
|
end
|
53
35
|
|
54
36
|
# Public: Retrieve depth information for the specified symbol
|
@@ -59,7 +41,7 @@ module Binance
|
|
59
41
|
#
|
60
42
|
# Returns a Hash with the request response
|
61
43
|
def depth(options)
|
62
|
-
request :public, :get,
|
44
|
+
request :public, :get, :depth, options
|
63
45
|
end
|
64
46
|
|
65
47
|
# Public: Retrieve recent trades for the specified symbol
|
@@ -70,7 +52,7 @@ module Binance
|
|
70
52
|
#
|
71
53
|
# Returns a Hash with the request response
|
72
54
|
def trades(options)
|
73
|
-
request :public, :get,
|
55
|
+
request :public, :get, :trades, options
|
74
56
|
end
|
75
57
|
|
76
58
|
# Public: Retrieve old trade data for the specified symbol
|
@@ -82,7 +64,7 @@ module Binance
|
|
82
64
|
#
|
83
65
|
# Returns a Hash with the request response
|
84
66
|
def historical_trades(options)
|
85
|
-
request :
|
67
|
+
request :verified, :get, :historicalTrades, options
|
86
68
|
end
|
87
69
|
|
88
70
|
# Public: Retrieve aggregate trade data for the specified symbol
|
@@ -98,7 +80,7 @@ module Binance
|
|
98
80
|
#
|
99
81
|
# Returns a Hash with the request response
|
100
82
|
def agg_trades(options)
|
101
|
-
request :public, :get,
|
83
|
+
request :public, :get, :aggTrades, options
|
102
84
|
end
|
103
85
|
|
104
86
|
# Public: Retrieve kline data for the specified symbol
|
@@ -115,7 +97,7 @@ module Binance
|
|
115
97
|
#
|
116
98
|
# Returns a Hash with the request response
|
117
99
|
def klines(options)
|
118
|
-
request :public, :get,
|
100
|
+
request :public, :get, :klines, options
|
119
101
|
end
|
120
102
|
|
121
103
|
# Public: Retrieve 24 hour ticker price data
|
@@ -125,7 +107,7 @@ module Binance
|
|
125
107
|
#
|
126
108
|
# Returns a Hash with the request response
|
127
109
|
def twenty_four_hour(options)
|
128
|
-
request :public, :get,
|
110
|
+
request :public, :get, :twenty_four_hour, options
|
129
111
|
end
|
130
112
|
|
131
113
|
# Public: Retrieve price ticker data for the specified symbol
|
@@ -135,14 +117,14 @@ module Binance
|
|
135
117
|
#
|
136
118
|
# Returns a Hash with the request response
|
137
119
|
def price(options)
|
138
|
-
request :public, :get,
|
120
|
+
request :public, :get, :price, options
|
139
121
|
end
|
140
122
|
|
141
123
|
# Public: Retrieve all price ticker data
|
142
124
|
#
|
143
125
|
# Returns a Hash with the request response
|
144
126
|
def all_prices
|
145
|
-
request :public, :get,
|
127
|
+
request :public, :get, :price
|
146
128
|
end
|
147
129
|
|
148
130
|
# Public: Retrieve best price per quantity on the order book
|
@@ -152,14 +134,14 @@ module Binance
|
|
152
134
|
#
|
153
135
|
# Returns a Hash with the request response
|
154
136
|
def book_ticker(options)
|
155
|
-
request :public, :get,
|
137
|
+
request :public, :get, :bookTicker, options
|
156
138
|
end
|
157
139
|
|
158
140
|
# Public: Retrieve all book ticker data for all symbols
|
159
141
|
#
|
160
142
|
# Returns a Hash with the request response
|
161
143
|
def all_book_tickers
|
162
|
-
request :public, :get,
|
144
|
+
request :public, :get, :bookTicker
|
163
145
|
end
|
164
146
|
end
|
165
147
|
end
|
@@ -1,32 +1,9 @@
|
|
1
1
|
|
2
|
-
require 'faraday'
|
3
|
-
require 'faraday_middleware'
|
4
|
-
require_relative 'sign_request_middleware'
|
5
|
-
require_relative 'timestamp_request_middleware'
|
6
|
-
|
7
2
|
module Binance
|
8
3
|
module Client
|
9
4
|
class REST
|
10
5
|
# Public: A Module containing all of the Withdraw API endpoints
|
11
|
-
module
|
12
|
-
# Internal: Create Lambda that returns a new Faraday client instance
|
13
|
-
# and add it to the REST class instance variable @api. This is called
|
14
|
-
# while a new instance of the REST class is created.
|
15
|
-
#
|
16
|
-
# base - The base class that is being extended into.
|
17
|
-
def self.extended(base)
|
18
|
-
REST.api[:withdraw] = lambda do
|
19
|
-
Faraday.new(url: "#{BASE_URL}/wapi") do |conn|
|
20
|
-
conn.request :url_encoded
|
21
|
-
conn.response :json, content_type: /\bjson$/
|
22
|
-
conn.headers['X-MBX-APIKEY'] = base.api_key
|
23
|
-
conn.use TimestampRequestMiddleware
|
24
|
-
conn.use SignRequestMiddleware, base.secret_key
|
25
|
-
conn.adapter base.adapter
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
6
|
+
module WithdrawAPI
|
30
7
|
# Public: Withdraw the specified asset to the given address using
|
31
8
|
# the authenticated account
|
32
9
|
#
|
@@ -41,7 +18,7 @@ module Binance
|
|
41
18
|
#
|
42
19
|
# Returns a Hash with the request response
|
43
20
|
def withdraw(options)
|
44
|
-
request :withdraw, :post,
|
21
|
+
request :withdraw, :post, :withdraw, options
|
45
22
|
end
|
46
23
|
|
47
24
|
# Public: Retrieve the deposit history for the authenticated account
|
@@ -58,7 +35,7 @@ module Binance
|
|
58
35
|
#
|
59
36
|
# Returns a Hash with the request response
|
60
37
|
def deposit_history(options = {})
|
61
|
-
request :withdraw, :get,
|
38
|
+
request :withdraw, :get, :depositHistory, options
|
62
39
|
end
|
63
40
|
|
64
41
|
# Public: Retrieve the withdraw history for the authenticated account
|
@@ -75,7 +52,7 @@ module Binance
|
|
75
52
|
#
|
76
53
|
# Returns a Hash with the request response
|
77
54
|
def withdraw_history(options = {})
|
78
|
-
request :withdraw, :get,
|
55
|
+
request :withdraw, :get, :withdrawHistory, options
|
79
56
|
end
|
80
57
|
|
81
58
|
# Public: Retrieve the deposit address for a specific asset
|
@@ -87,7 +64,7 @@ module Binance
|
|
87
64
|
#
|
88
65
|
# Returns a Hash with the request response
|
89
66
|
def deposit_address(options)
|
90
|
-
request :withdraw, :get,
|
67
|
+
request :withdraw, :get, :depositAddress, options
|
91
68
|
end
|
92
69
|
|
93
70
|
# Public: Retrieve current account status
|
@@ -98,7 +75,7 @@ module Binance
|
|
98
75
|
#
|
99
76
|
# Returns a Hash with the request response
|
100
77
|
def account_status(options)
|
101
|
-
request :withdraw, :get,
|
78
|
+
request :withdraw, :get, :accountStatus, options
|
102
79
|
end
|
103
80
|
end
|
104
81
|
end
|
data/lib/binance/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Ray Shisler III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,42 +58,42 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.12
|
61
|
+
version: '0.12'
|
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: 0.12
|
68
|
+
version: '0.12'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: faraday_middleware
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.12
|
75
|
+
version: '0.12'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.12
|
82
|
+
version: '0.12'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: faye-websocket
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.10
|
89
|
+
version: '0.10'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.10
|
96
|
+
version: '0.10'
|
97
97
|
description:
|
98
98
|
email:
|
99
99
|
- charles@cray.io
|
@@ -110,7 +110,6 @@ files:
|
|
110
110
|
- lib/binance/client/rest/public_api.rb
|
111
111
|
- lib/binance/client/rest/sign_request_middleware.rb
|
112
112
|
- lib/binance/client/rest/timestamp_request_middleware.rb
|
113
|
-
- lib/binance/client/rest/user_data_api.rb
|
114
113
|
- lib/binance/client/rest/withdraw_api.rb
|
115
114
|
- lib/binance/client/websocket.rb
|
116
115
|
- lib/binance/version.rb
|
@@ -1,54 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'faraday'
|
3
|
-
require 'faraday_middleware'
|
4
|
-
|
5
|
-
module Binance
|
6
|
-
module Client
|
7
|
-
class REST
|
8
|
-
# Public: A Module containing all of the User Data API endpoints
|
9
|
-
module UserData_API
|
10
|
-
# Internal: Create Lambda that returns a new Faraday client instance
|
11
|
-
# and add it to the REST class instance variable @api. This is called
|
12
|
-
# while a new instance of the REST class is created.
|
13
|
-
#
|
14
|
-
# base - The base class that is being extended into.
|
15
|
-
def self.extended(base)
|
16
|
-
REST.api[:user_data] = lambda do
|
17
|
-
Faraday.new(url: "#{BASE_URL}/api") do |conn|
|
18
|
-
conn.response :json, content_type: /\bjson$/
|
19
|
-
conn.headers['X-MBX-APIKEY'] = base.api_key
|
20
|
-
conn.adapter base.adapter
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Public: Retrieve the listen key for the given api key
|
26
|
-
#
|
27
|
-
# Returns a Hash with the request response
|
28
|
-
def listen_key
|
29
|
-
request :user_data, :post, 'userDataStream'
|
30
|
-
end
|
31
|
-
|
32
|
-
# Public: Ping the server to keep User Data stream alive
|
33
|
-
#
|
34
|
-
# options - The Hash which hosts various REST query params.
|
35
|
-
# :listen_key - The String of which stream to keep alive
|
36
|
-
#
|
37
|
-
# Returns a Hash with the request response
|
38
|
-
def keep_stream_alive(options)
|
39
|
-
request :user_data, :put, 'userDataStream', options
|
40
|
-
end
|
41
|
-
|
42
|
-
# Public: Close the User Data stream associated with the listen key
|
43
|
-
#
|
44
|
-
# options - The Hash which hosts various REST query params.
|
45
|
-
# :listen_key - The String of which stream to close
|
46
|
-
#
|
47
|
-
# Returns a Hash with the request response
|
48
|
-
def close_stream(options)
|
49
|
-
request :user_data, :delete, 'userDataStream', options
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|