binance-connector-ruby 1.0.1
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 +7 -0
- data/CHANGELOG.md +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +224 -0
- data/lib/binance/authentication.rb +13 -0
- data/lib/binance/error.rb +28 -0
- data/lib/binance/session.rb +106 -0
- data/lib/binance/spot/blvt.rb +104 -0
- data/lib/binance/spot/bswap.rb +217 -0
- data/lib/binance/spot/c2c.rb +27 -0
- data/lib/binance/spot/fiat.rb +49 -0
- data/lib/binance/spot/futures.rb +357 -0
- data/lib/binance/spot/loan.rb +26 -0
- data/lib/binance/spot/margin.rb +676 -0
- data/lib/binance/spot/market.rb +220 -0
- data/lib/binance/spot/mining.rb +243 -0
- data/lib/binance/spot/savings.rb +269 -0
- data/lib/binance/spot/stream.rb +61 -0
- data/lib/binance/spot/subaccount.rb +553 -0
- data/lib/binance/spot/trade.rb +294 -0
- data/lib/binance/spot/wallet.rb +316 -0
- data/lib/binance/spot/websocket.rb +147 -0
- data/lib/binance/spot.rb +61 -0
- data/lib/binance/utils/faraday/custom_params_encoder.rb +78 -0
- data/lib/binance/utils/faraday/middleware/signature.rb +21 -0
- data/lib/binance/utils/faraday/middleware/timestamp.rb +20 -0
- data/lib/binance/utils/faraday/middleware.rb +4 -0
- data/lib/binance/utils/url.rb +26 -0
- data/lib/binance/utils/validation.rb +26 -0
- data/lib/binance/version.rb +5 -0
- data/lib/binance/websocket_base.rb +84 -0
- data/lib/binance.rb +5 -0
- metadata +161 -0
@@ -0,0 +1,553 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Binance
|
4
|
+
class Spot
|
5
|
+
# all sub-account endpoints
|
6
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#sub-account-endpoints
|
7
|
+
module Subaccount
|
8
|
+
# Create a Virtual Sub-account(For Master Account)
|
9
|
+
#
|
10
|
+
# POST /sapi/v1/sub-account/virtualSubAccount
|
11
|
+
#
|
12
|
+
# This request will generate a virtual sub account under your master account.<br>
|
13
|
+
# You need to enable "trade" option for the api key which requests this endpoint.
|
14
|
+
#
|
15
|
+
# @param subAccountString [String]
|
16
|
+
# @param kwargs [Hash]
|
17
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
18
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#create-a-virtual-sub-account-for-master-account
|
19
|
+
def create_virtual_sub_account(subAccountString:, **kwargs)
|
20
|
+
Binance::Utils::Validation.require_param('subAccountString', subAccountString)
|
21
|
+
|
22
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/virtualSubAccount', params: kwargs.merge(
|
23
|
+
subAccountString: subAccountString
|
24
|
+
))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Query Sub-account List (For Master Account)
|
28
|
+
#
|
29
|
+
# GET /sapi/v1/sub-account/list
|
30
|
+
#
|
31
|
+
# @param kwargs [Hash]
|
32
|
+
# @option kwargs [String] :email Sub-account email
|
33
|
+
# @option kwargs [String] :isFreeze true or false
|
34
|
+
# @option kwargs [Integer] :page
|
35
|
+
# @option kwargs [Integer] :limit
|
36
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
37
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-list-for-master-account
|
38
|
+
def get_sub_account_list(**kwargs)
|
39
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/list', params: kwargs)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Query Sub-account Spot Asset Transfer History (For Master Account)
|
43
|
+
#
|
44
|
+
# GET /sapi/v1/sub-account/sub/transfer/history
|
45
|
+
#
|
46
|
+
# fromEmail and toEmail cannot be sent at the same time.<br>
|
47
|
+
# Return fromEmail equal master account email by default.
|
48
|
+
#
|
49
|
+
# @param kwargs [Hash]
|
50
|
+
# @option kwargs [String] :fromEmail Sub-account email
|
51
|
+
# @option kwargs [String] :toEmail Sub-account email
|
52
|
+
# @option kwargs [Integer] :startTime
|
53
|
+
# @option kwargs [Integer] :endTime
|
54
|
+
# @option kwargs [Integer] :page Default value: 1
|
55
|
+
# @option kwargs [Integer] :limit Default value: 500
|
56
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
57
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-spot-asset-transfer-history-for-master-account
|
58
|
+
def get_sub_account_spot_transfer_history(**kwargs)
|
59
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/sub/transfer/history', params: kwargs)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Query Sub-account Futures Asset Transfer History (For Master Account)
|
63
|
+
#
|
64
|
+
# GET /sapi/v1/sub-account/futures/internalTransfer
|
65
|
+
#
|
66
|
+
# @param email [String]
|
67
|
+
# @param futuresType [Integer] 1:USDT-margined Futures, 2: Coin-margined Futures
|
68
|
+
# @param kwargs [Hash]
|
69
|
+
# @option kwargs [Integer] :startTime Default return the history with in 100 days
|
70
|
+
# @option kwargs [Integer] :endTime Default return the history with in 100 days
|
71
|
+
# @option kwargs [Integer] :page Default value: 1
|
72
|
+
# @option kwargs [Integer] :limit Default value: 50, Max value: 500
|
73
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
74
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-futures-asset-transfer-history-for-master-account
|
75
|
+
def get_sub_account_futures_transfer_history(email:, futuresType:, **kwargs)
|
76
|
+
Binance::Utils::Validation.require_param('email', email)
|
77
|
+
Binance::Utils::Validation.require_param('futuresType', futuresType)
|
78
|
+
|
79
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/futures/internalTransfer', params: kwargs.merge(
|
80
|
+
email: email,
|
81
|
+
futuresType: futuresType
|
82
|
+
))
|
83
|
+
end
|
84
|
+
|
85
|
+
# Sub-account Futures Asset Transfer (For Master Account)
|
86
|
+
#
|
87
|
+
# POST /sapi/v1/sub-account/futures/internalTransfer
|
88
|
+
#
|
89
|
+
# @param fromEmail [String]
|
90
|
+
# @param toEmail [String]
|
91
|
+
# @param futuresType [Integer] 1:USDT-margined Futures, 2: Coin-margined Futures
|
92
|
+
# @param asset [String]
|
93
|
+
# @param amount [Float]
|
94
|
+
# @param kwargs [Hash]
|
95
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
96
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#sub-account-futures-asset-transfer-for-master-account
|
97
|
+
def sub_account_futures_internal_transfer(fromEmail:, toEmail:, futuresType:, asset:, amount:, **kwargs)
|
98
|
+
Binance::Utils::Validation.require_param('fromEmail', fromEmail)
|
99
|
+
Binance::Utils::Validation.require_param('toEmail', toEmail)
|
100
|
+
Binance::Utils::Validation.require_param('futuresType', futuresType)
|
101
|
+
Binance::Utils::Validation.require_param('asset', asset)
|
102
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
103
|
+
|
104
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/futures/internalTransfer', params: kwargs.merge(
|
105
|
+
fromEmail: fromEmail,
|
106
|
+
toEmail: toEmail,
|
107
|
+
futuresType: futuresType,
|
108
|
+
asset: asset,
|
109
|
+
amount: amount
|
110
|
+
))
|
111
|
+
end
|
112
|
+
|
113
|
+
# Query Sub-account Assets (For Master Account)
|
114
|
+
#
|
115
|
+
# GET /sapi/v3/sub-account/assets
|
116
|
+
#
|
117
|
+
# @param email [String]
|
118
|
+
# @param kwargs [Hash]
|
119
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
120
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-assets-for-master-account
|
121
|
+
def get_sub_account_assets(email:, **kwargs)
|
122
|
+
Binance::Utils::Validation.require_param('email', email)
|
123
|
+
|
124
|
+
@session.sign_request(:get, '/sapi/v3/sub-account/assets', params: kwargs.merge(email: email))
|
125
|
+
end
|
126
|
+
|
127
|
+
# Query Sub-account Spot Assets Summary (For Master Account)
|
128
|
+
#
|
129
|
+
# GET /sapi/v1/sub-account/spotSummary
|
130
|
+
#
|
131
|
+
# Get BTC valued asset summary of subaccounts.
|
132
|
+
#
|
133
|
+
# @param kwargs [Hash]
|
134
|
+
# @option kwargs [String] :email
|
135
|
+
# @option kwargs [Integer] :page Default value: 1
|
136
|
+
# @option kwargs [Integer] :size default 10, max 20
|
137
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
138
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#query-sub-account-spot-assets-summary-for-master-account
|
139
|
+
def get_sub_account_spot_summary(**kwargs)
|
140
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/spotSummary', params: kwargs)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Get Sub-account Deposit Address (For Master Account)
|
144
|
+
#
|
145
|
+
# GET /sapi/v1/capital/deposit/subAddress
|
146
|
+
#
|
147
|
+
# Fetch sub-account deposit address
|
148
|
+
#
|
149
|
+
# @param email [String]
|
150
|
+
# @param coin [String]
|
151
|
+
# @param kwargs [Hash]
|
152
|
+
# @option kwargs [String] :network
|
153
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
154
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-sub-account-deposit-address-for-master-account
|
155
|
+
def sub_account_deposit_address(email:, coin:, **kwargs)
|
156
|
+
Binance::Utils::Validation.require_param('email', email)
|
157
|
+
Binance::Utils::Validation.require_param('coin', coin)
|
158
|
+
|
159
|
+
@session.sign_request(:get, '/sapi/v1/capital/deposit/subAddress', params: kwargs.merge(
|
160
|
+
email: email,
|
161
|
+
coin: coin
|
162
|
+
))
|
163
|
+
end
|
164
|
+
|
165
|
+
# Get Sub-account Deposit History (For Master Account)
|
166
|
+
#
|
167
|
+
# GET /sapi/v1/capital/deposit/subHisrec
|
168
|
+
#
|
169
|
+
# Fetch sub-account deposit history
|
170
|
+
#
|
171
|
+
# @param email [String]
|
172
|
+
# @param kwargs [Hash]
|
173
|
+
# @option kwargs [String] :coin
|
174
|
+
# @option kwargs [String] :status
|
175
|
+
# @option kwargs [String] :startTime
|
176
|
+
# @option kwargs [String] :endTime
|
177
|
+
# @option kwargs [String] :limit
|
178
|
+
# @option kwargs [String] :offset
|
179
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
180
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-sub-account-deposit-history-for-master-account
|
181
|
+
def sub_account_deposit_history(email:, **kwargs)
|
182
|
+
Binance::Utils::Validation.require_param('email', email)
|
183
|
+
|
184
|
+
@session.sign_request(:get, '/sapi/v1/capital/deposit/subHisrec', params: kwargs.merge(
|
185
|
+
email: email
|
186
|
+
))
|
187
|
+
end
|
188
|
+
|
189
|
+
# Get Sub-account's Status on Margin/Futures(For Master Account)
|
190
|
+
#
|
191
|
+
# GET /sapi/v1/sub-account/status
|
192
|
+
#
|
193
|
+
# @param kwargs [Hash]
|
194
|
+
# @option kwargs [String] :email
|
195
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
196
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-sub-account-39-s-status-on-margin-futures-for-master-account
|
197
|
+
def sub_account_status(**kwargs)
|
198
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/status', params: kwargs)
|
199
|
+
end
|
200
|
+
|
201
|
+
# Enable Margin for Sub-account (For Master Account)
|
202
|
+
#
|
203
|
+
# POST /sapi/v1/sub-account/margin/enable
|
204
|
+
#
|
205
|
+
# @param kwargs [Hash]
|
206
|
+
# @option kwargs [String] :email
|
207
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
208
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-sub-account-39-s-status-on-margin-futures-for-master-account
|
209
|
+
def sub_account_enable_margin(email:, **kwargs)
|
210
|
+
Binance::Utils::Validation.require_param('email', email)
|
211
|
+
|
212
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/margin/enable', params: kwargs.merge(
|
213
|
+
email: email
|
214
|
+
))
|
215
|
+
end
|
216
|
+
|
217
|
+
# Get Detail on Sub-account's Margin Account (For Master Account)
|
218
|
+
#
|
219
|
+
# GET /sapi/v1/sub-account/margin/account
|
220
|
+
#
|
221
|
+
# @param email [String]
|
222
|
+
# @param kwargs [Hash]
|
223
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
224
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-detail-on-sub-account-39-s-margin-account-for-master-account
|
225
|
+
def sub_account_margin_account(email:, **kwargs)
|
226
|
+
Binance::Utils::Validation.require_param('email', email)
|
227
|
+
|
228
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/margin/account', params: kwargs.merge(
|
229
|
+
email: email
|
230
|
+
))
|
231
|
+
end
|
232
|
+
|
233
|
+
# Get Summary of Sub-account's Margin Account (For Master Account)
|
234
|
+
#
|
235
|
+
# GET /sapi/v1/sub-account/margin/accountSummary
|
236
|
+
#
|
237
|
+
# @param kwargs [Hash]
|
238
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
239
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-summary-of-sub-account-39-s-margin-account-for-master-account
|
240
|
+
def sub_account_margin_account_summary(**kwargs)
|
241
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/margin/accountSummary', params: kwargs)
|
242
|
+
end
|
243
|
+
|
244
|
+
# Enable Futures for Sub-account (For Master Account)
|
245
|
+
#
|
246
|
+
# POST /sapi/v1/sub-account/futures/enable
|
247
|
+
#
|
248
|
+
# @param email [String]
|
249
|
+
# @param kwargs [Hash]
|
250
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
251
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#enable-futures-for-sub-account-for-master-account
|
252
|
+
def sub_account_enable_futures(email:, **kwargs)
|
253
|
+
Binance::Utils::Validation.require_param('email', email)
|
254
|
+
|
255
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/futures/enable', params: kwargs.merge(
|
256
|
+
email: email
|
257
|
+
))
|
258
|
+
end
|
259
|
+
|
260
|
+
# Get Detail on Sub-account's Futures Account (For Master Account)
|
261
|
+
#
|
262
|
+
# GET /sapi/v2/sub-account/futures/account
|
263
|
+
#
|
264
|
+
# @param email [String]
|
265
|
+
# @param futuresType [Integer] 1:USDT Margined Futures, 2:COIN Margined Futures
|
266
|
+
# @param kwargs [Hash]
|
267
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
268
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-detail-on-sub-account-39-s-futures-account-v2-for-master-account
|
269
|
+
def sub_account_futures_account(email:, futuresType:, **kwargs)
|
270
|
+
Binance::Utils::Validation.require_param('email', email)
|
271
|
+
Binance::Utils::Validation.require_param('futuresType', futuresType)
|
272
|
+
|
273
|
+
@session.sign_request(:get, '/sapi/v2/sub-account/futures/account', params: kwargs.merge(
|
274
|
+
email: email,
|
275
|
+
futuresType: futuresType
|
276
|
+
))
|
277
|
+
end
|
278
|
+
|
279
|
+
# Get Summary of Sub-account's Futures Account (For Master Account)
|
280
|
+
#
|
281
|
+
# GET /sapi/v2/sub-account/futures/accountSummary
|
282
|
+
#
|
283
|
+
# @param futuresType [Integer] 1:USDT Margined Futures, 2:COIN Margined Futures
|
284
|
+
# @param kwargs [Hash]
|
285
|
+
# @option kwargs [Integer] :page default:1
|
286
|
+
# @option kwargs [Integer] :limit default:10, max:20
|
287
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
288
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-summary-of-sub-account-39-s-futures-account-v2-for-master-account
|
289
|
+
def sub_account_futures_account_summary(futuresType:, **kwargs)
|
290
|
+
Binance::Utils::Validation.require_param('futuresType', futuresType)
|
291
|
+
|
292
|
+
@session.sign_request(:get, '/sapi/v2/sub-account/futures/accountSummary', params: kwargs.merge(
|
293
|
+
futuresType: futuresType
|
294
|
+
))
|
295
|
+
end
|
296
|
+
|
297
|
+
# Get Futures Position-Risk of Sub-account (For Master Account)
|
298
|
+
#
|
299
|
+
# GET /sapi/v2/sub-account/futures/positionRisk
|
300
|
+
#
|
301
|
+
# @param email [String]
|
302
|
+
# @param futuresType [Integer] 1:USDT Margined Futures, 2:COIN Margined Futures
|
303
|
+
# @param kwargs [Hash]
|
304
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
305
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#get-futures-position-risk-of-sub-account-v2-for-master-account
|
306
|
+
def sub_account_futures_position_risk(email:, futuresType:, **kwargs)
|
307
|
+
Binance::Utils::Validation.require_param('email', email)
|
308
|
+
Binance::Utils::Validation.require_param('futuresType', futuresType)
|
309
|
+
|
310
|
+
@session.sign_request(:get, '/sapi/v2/sub-account/futures/positionRisk', params: kwargs.merge(
|
311
|
+
email: email,
|
312
|
+
futuresType: futuresType
|
313
|
+
))
|
314
|
+
end
|
315
|
+
|
316
|
+
# Futures Transfer for Sub-account(For Master Account)
|
317
|
+
#
|
318
|
+
# POST /sapi/v1/sub-account/futures/transfer
|
319
|
+
#
|
320
|
+
# @param email [String]
|
321
|
+
# @param asset [String]
|
322
|
+
# @param amount [Float]
|
323
|
+
# @param type [Integer] 1: transfer from subaccount's spot account to its USDT-margined futures account<br>
|
324
|
+
# 2: transfer from subaccount's USDT-margined futures account to its spot account<br>
|
325
|
+
# 3: transfer from subaccount's spot account to its COIN-margined futures account<br>
|
326
|
+
# 4:transfer from subaccount's COIN-margined futures account to its spot account
|
327
|
+
# @param kwargs [Hash]
|
328
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
329
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#futures-transfer-for-sub-account-for-master-account
|
330
|
+
def sub_account_futures_transfer(email:, asset:, amount:, type:, **kwargs)
|
331
|
+
Binance::Utils::Validation.require_param('email', email)
|
332
|
+
Binance::Utils::Validation.require_param('asset', asset)
|
333
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
334
|
+
Binance::Utils::Validation.require_param('type', type)
|
335
|
+
|
336
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/futures/transfer', params: kwargs.merge(
|
337
|
+
email: email,
|
338
|
+
asset: asset,
|
339
|
+
amount: amount,
|
340
|
+
type: type
|
341
|
+
))
|
342
|
+
end
|
343
|
+
|
344
|
+
# Margin Transfer for Sub-account(For Master Account)
|
345
|
+
#
|
346
|
+
# POST /sapi/v1/sub-account/margin/transfer
|
347
|
+
#
|
348
|
+
# @param email [String]
|
349
|
+
# @param asset [String]
|
350
|
+
# @param amount [Float]
|
351
|
+
# @param type [Integer] 1: transfer from subaccount's spot account to margin account<br>
|
352
|
+
# 2: transfer from subaccount's margin account to its spot account
|
353
|
+
# @param kwargs [Hash]
|
354
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
355
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#margin-transfer-for-sub-account-for-master-account
|
356
|
+
def sub_account_margin_transfer(email:, asset:, amount:, type:, **kwargs)
|
357
|
+
Binance::Utils::Validation.require_param('email', email)
|
358
|
+
Binance::Utils::Validation.require_param('asset', asset)
|
359
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
360
|
+
Binance::Utils::Validation.require_param('type', type)
|
361
|
+
|
362
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/margin/transfer', params: kwargs.merge(
|
363
|
+
email: email,
|
364
|
+
asset: asset,
|
365
|
+
amount: amount,
|
366
|
+
type: type
|
367
|
+
))
|
368
|
+
end
|
369
|
+
|
370
|
+
# Transfer to Sub-account of Same Master(For Sub-account)
|
371
|
+
#
|
372
|
+
# POST /sapi/v1/sub-account/transfer/subToSub
|
373
|
+
#
|
374
|
+
# @param toEmail [String]
|
375
|
+
# @param asset [String]
|
376
|
+
# @param amount [String]
|
377
|
+
# @param kwargs [Hash]
|
378
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
379
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#transfer-to-sub-account-of-same-master-for-sub-account
|
380
|
+
def sub_account_transfer_to_sub(toEmail:, asset:, amount:, **kwargs)
|
381
|
+
Binance::Utils::Validation.require_param('toEmail', toEmail)
|
382
|
+
Binance::Utils::Validation.require_param('asset', asset)
|
383
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
384
|
+
|
385
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/transfer/subToSub', params: kwargs.merge(
|
386
|
+
toEmail: toEmail,
|
387
|
+
asset: asset,
|
388
|
+
amount: amount
|
389
|
+
))
|
390
|
+
end
|
391
|
+
|
392
|
+
# Transfer to Sub-account of Same Master(For Sub-account)
|
393
|
+
#
|
394
|
+
# POST /sapi/v1/sub-account/transfer/subToMaster
|
395
|
+
#
|
396
|
+
# @param asset [String]
|
397
|
+
# @param amount [Float]
|
398
|
+
# @param kwargs [Hash]
|
399
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
400
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#transfer-to-master-for-sub-account
|
401
|
+
def sub_account_transfer_to_master(asset:, amount:, **kwargs)
|
402
|
+
Binance::Utils::Validation.require_param('asset', asset)
|
403
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
404
|
+
|
405
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/transfer/subToMaster', params: kwargs.merge(
|
406
|
+
asset: asset,
|
407
|
+
amount: amount
|
408
|
+
))
|
409
|
+
end
|
410
|
+
|
411
|
+
# Sub-account Transfer History (For Sub-account)
|
412
|
+
#
|
413
|
+
# GET /sapi/v1/sub-account/transfer/subUserHistory
|
414
|
+
#
|
415
|
+
# @param kwargs [Hash]
|
416
|
+
# @option kwargs [String] :asset
|
417
|
+
# @option kwargs [Integer] :type 1: transfer in, 2: transfer out
|
418
|
+
# @option kwargs [Integer] :startTime
|
419
|
+
# @option kwargs [Integer] :endTime
|
420
|
+
# @option kwargs [Integer] :limit
|
421
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
422
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#sub-account-transfer-history-for-sub-account
|
423
|
+
def sub_account_transfer_sub_account_history(**kwargs)
|
424
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/transfer/subUserHistory', params: kwargs)
|
425
|
+
end
|
426
|
+
|
427
|
+
# Universal Transfer (For Master Account)
|
428
|
+
#
|
429
|
+
# POST /sapi/v1/sub-account/universalTransfer
|
430
|
+
#
|
431
|
+
# You need to enable "internal transfer" option for the api key which requests this endpoint.<br>
|
432
|
+
# Transfer between futures accounts is not supported.
|
433
|
+
#
|
434
|
+
# @param fromAccountType [String] "SPOT","USDT_FUTURE","COIN_FUTURE"
|
435
|
+
# @param toAccountType [String] "SPOT","USDT_FUTURE","COIN_FUTURE"
|
436
|
+
# @param asset [String]
|
437
|
+
# @param amount [Float]
|
438
|
+
# @param kwargs [Hash]
|
439
|
+
# @option kwargs [String] :fromEmail Transfer from master account by default if fromEmail is not sent.
|
440
|
+
# @option kwargs [String] :toEmail Transfer to master account by default if toEmail is not sent.
|
441
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
442
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#universal-transfer-for-master-account
|
443
|
+
def universal_transfer(fromAccountType:, toAccountType:, asset:, amount:, **kwargs)
|
444
|
+
Binance::Utils::Validation.require_param('fromAccountType', fromAccountType)
|
445
|
+
Binance::Utils::Validation.require_param('toAccountType', toAccountType)
|
446
|
+
Binance::Utils::Validation.require_param('asset', asset)
|
447
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
448
|
+
|
449
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/universalTransfer', params: kwargs.merge(
|
450
|
+
fromAccountType: fromAccountType,
|
451
|
+
toAccountType: toAccountType,
|
452
|
+
asset: asset,
|
453
|
+
amount: amount
|
454
|
+
))
|
455
|
+
end
|
456
|
+
|
457
|
+
# Query Universal Transfer History (For Master Account)
|
458
|
+
#
|
459
|
+
# GET /sapi/v1/sub-account/universalTransfer
|
460
|
+
#
|
461
|
+
# @param kwargs [Hash]
|
462
|
+
# @option kwargs [String] :fromEmail
|
463
|
+
# @option kwargs [String] :toEmail
|
464
|
+
# @option kwargs [Integer] :startTime
|
465
|
+
# @option kwargs [Integer] :endTime
|
466
|
+
# @option kwargs [Integer] :page
|
467
|
+
# @option kwargs [Integer] :limit Default 500, Max 500
|
468
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
469
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#query-universal-transfer-history-for-master-account
|
470
|
+
def universal_transfer_history(**kwargs)
|
471
|
+
@session.sign_request(:get, '/sapi/v1/sub-account/universalTransfer', params: kwargs)
|
472
|
+
end
|
473
|
+
|
474
|
+
# Enable Leverage Token for Sub-account (For Master Account)
|
475
|
+
#
|
476
|
+
# POST /sapi/v1/sub-account/blvt/enable
|
477
|
+
#
|
478
|
+
# @param email [String]
|
479
|
+
# @param enableBlvt [Boolean] Only true for now
|
480
|
+
# @param kwargs [Hash]
|
481
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
482
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#enable-leverage-token-for-sub-account-for-master-account
|
483
|
+
def sub_account_enable_blvt(email:, enableBlvt:, **kwargs)
|
484
|
+
Binance::Utils::Validation.require_param('email', email)
|
485
|
+
Binance::Utils::Validation.require_param('enableBlvt', enableBlvt)
|
486
|
+
|
487
|
+
@session.sign_request(:post, '/sapi/v1/sub-account/blvt/enable', params: kwargs.merge(
|
488
|
+
email: email,
|
489
|
+
enableBlvt: enableBlvt
|
490
|
+
))
|
491
|
+
end
|
492
|
+
|
493
|
+
# Deposit assets into the managed sub-account (For Investor Master Account)
|
494
|
+
#
|
495
|
+
# POST /sapi/v1/managed-subaccount/deposit
|
496
|
+
#
|
497
|
+
# @param toEmail [String]
|
498
|
+
# @param asset [String]
|
499
|
+
# @param amount [Float]
|
500
|
+
# @param kwargs [Hash]
|
501
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
502
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#deposit-assets-into-the-managed-sub-account-for-investor-master-account
|
503
|
+
def deposit_to_sub_account(toEmail:, asset:, amount:, **kwargs)
|
504
|
+
Binance::Utils::Validation.require_param('toEmail', toEmail)
|
505
|
+
Binance::Utils::Validation.require_param('asset', asset)
|
506
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
507
|
+
|
508
|
+
@session.sign_request(:post, '/sapi/v1/managed-subaccount/deposit', params: kwargs.merge(
|
509
|
+
toEmail: toEmail,
|
510
|
+
asset: asset,
|
511
|
+
amount: amount
|
512
|
+
))
|
513
|
+
end
|
514
|
+
|
515
|
+
# Query managed sub-account asset details (For Investor Master Account)
|
516
|
+
#
|
517
|
+
# GET /sapi/v1/managed-subaccount/asset
|
518
|
+
#
|
519
|
+
# @param email [String]
|
520
|
+
# @param kwargs [Hash]
|
521
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
522
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#query-managed-sub-account-asset-details-for-investor-master-account
|
523
|
+
def sub_account_asset_details(email:, **kwargs)
|
524
|
+
Binance::Utils::Validation.require_param('email', email)
|
525
|
+
|
526
|
+
@session.sign_request(:get, '/sapi/v1/managed-subaccount/asset', params: kwargs.merge(email: email))
|
527
|
+
end
|
528
|
+
|
529
|
+
# Withdrawl assets from the managed sub-account (For Investor Master Account)
|
530
|
+
#
|
531
|
+
# POST /sapi/v1/managed-subaccount/withdraw
|
532
|
+
#
|
533
|
+
# @param fromEmail [String]
|
534
|
+
# @param asset [String]
|
535
|
+
# @param amount [Float]
|
536
|
+
# @param kwargs [Hash]
|
537
|
+
# @option kwargs [Integer] :transferDate
|
538
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
539
|
+
# @see https://binance-docs.github.io/apidocs/spot/en/#withdrawl-assets-from-the-managed-sub-account-for-investor-master-account
|
540
|
+
def withdraw_from_sub_account(fromEmail:, asset:, amount:, **kwargs)
|
541
|
+
Binance::Utils::Validation.require_param('fromEmail', fromEmail)
|
542
|
+
Binance::Utils::Validation.require_param('asset', asset)
|
543
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
544
|
+
|
545
|
+
@session.sign_request(:post, '/sapi/v1/managed-subaccount/withdraw', params: kwargs.merge(
|
546
|
+
fromEmail: fromEmail,
|
547
|
+
asset: asset,
|
548
|
+
amount: amount
|
549
|
+
))
|
550
|
+
end
|
551
|
+
end
|
552
|
+
end
|
553
|
+
end
|