binance-connector-ruby 1.5.2 → 1.6.0
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/CHANGELOG.md +52 -0
- data/lib/binance/spot/c2c.rb +2 -2
- data/lib/binance/spot/convert.rb +2 -2
- data/lib/binance/spot/fiat.rb +3 -3
- data/lib/binance/spot/loan.rb +2 -2
- data/lib/binance/spot/margin.rb +34 -246
- data/lib/binance/spot/market.rb +14 -14
- data/lib/binance/spot/mining.rb +13 -13
- data/lib/binance/spot/simple_earn.rb +24 -24
- data/lib/binance/spot/stream.rb +1 -1
- data/lib/binance/spot/subaccount.rb +39 -59
- data/lib/binance/spot/trade.rb +17 -17
- data/lib/binance/spot/wallet.rb +22 -22
- data/lib/binance/spot/websocket.rb +11 -11
- data/lib/binance/spot.rb +1 -5
- data/lib/binance/version.rb +1 -1
- metadata +6 -8
- data/lib/binance/spot/blvt.rb +0 -104
- data/lib/binance/spot/futures.rb +0 -357
data/lib/binance/spot/margin.rb
CHANGED
@@ -3,107 +3,13 @@
|
|
3
3
|
module Binance
|
4
4
|
class Spot
|
5
5
|
# Margin endpoints
|
6
|
-
# @see https://binance
|
6
|
+
# @see https://developers.binance.com/docs/margin_trading/Introduction
|
7
7
|
module Margin
|
8
|
-
# Cross Margin Account Transfer (MARGIN)
|
9
|
-
#
|
10
|
-
# POST /sapi/v1/margin/transfer
|
11
|
-
#
|
12
|
-
# Execute transfer between spot account and cross margin account.
|
13
|
-
#
|
14
|
-
# @param asset [String]
|
15
|
-
# @param amount [Float]
|
16
|
-
# @param type [Integer]
|
17
|
-
# @param kwargs [Hash]
|
18
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
19
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#cross-margin-account-transfer-margin
|
20
|
-
def margin_transfer(asset:, amount:, type:, **kwargs)
|
21
|
-
Binance::Utils::Validation.require_param('asset', asset)
|
22
|
-
Binance::Utils::Validation.require_param('amount', amount)
|
23
|
-
Binance::Utils::Validation.require_param('type', type)
|
24
|
-
|
25
|
-
@session.sign_request(:post, '/sapi/v1/margin/transfer', params: kwargs.merge(
|
26
|
-
asset: asset,
|
27
|
-
amount: amount,
|
28
|
-
type: type
|
29
|
-
))
|
30
|
-
end
|
31
|
-
|
32
|
-
# Margin Account Borrow (MARGIN)
|
33
|
-
#
|
34
|
-
# POST /sapi/v1/margin/loan
|
35
|
-
#
|
36
|
-
# Apply for a loan.
|
37
|
-
#
|
38
|
-
# @param asset [String]
|
39
|
-
# @param amount [Float]
|
40
|
-
# @param kwargs [Hash]
|
41
|
-
# @option kwargs [String] :isIsolated for isolated margin or not, "TRUE", "FALSE"; default "FALSE"
|
42
|
-
# @option kwargs [String] :symbol isolated symbol
|
43
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
44
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-borrow-margin
|
45
|
-
def margin_borrow(asset:, amount:, **kwargs)
|
46
|
-
Binance::Utils::Validation.require_param('asset', asset)
|
47
|
-
Binance::Utils::Validation.require_param('amount', amount)
|
48
|
-
|
49
|
-
@session.sign_request(:post, '/sapi/v1/margin/loan', params: kwargs.merge(
|
50
|
-
asset: asset,
|
51
|
-
amount: amount
|
52
|
-
))
|
53
|
-
end
|
54
|
-
|
55
|
-
# Margin Account Repay (MARGIN)
|
56
|
-
#
|
57
|
-
# POST /sapi/v1/margin/repay
|
58
|
-
#
|
59
|
-
# Repay loan for margin account.
|
60
|
-
#
|
61
|
-
# @param asset [String]
|
62
|
-
# @param amount [Float]
|
63
|
-
# @param kwargs [Hash]
|
64
|
-
# @option kwargs [String] :isIsolated for isolated margin or not, "TRUE", "FALSE"; default "FALSE"
|
65
|
-
# @option kwargs [String] :symbol isolated symbol
|
66
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
67
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#margin-account-repay-margin
|
68
|
-
def margin_repay(asset:, amount:, **kwargs)
|
69
|
-
Binance::Utils::Validation.require_param('asset', asset)
|
70
|
-
Binance::Utils::Validation.require_param('amount', amount)
|
71
|
-
|
72
|
-
@session.sign_request(:post, '/sapi/v1/margin/repay', params: kwargs.merge(
|
73
|
-
asset: asset,
|
74
|
-
amount: amount
|
75
|
-
))
|
76
|
-
end
|
77
|
-
|
78
|
-
# Query Margin Asset (MARKET_DATA)
|
79
|
-
#
|
80
|
-
# GET /sapi/v1/margin/asset
|
81
|
-
#
|
82
|
-
# @param asset [String]
|
83
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-asset-market_data
|
84
|
-
def margin_asset(asset:)
|
85
|
-
Binance::Utils::Validation.require_param('asset', asset)
|
86
|
-
|
87
|
-
@session.limit_request(path: '/sapi/v1/margin/asset', params: { asset: asset })
|
88
|
-
end
|
89
|
-
|
90
|
-
# Query Margin Pair (MARKET_DATA)
|
91
|
-
#
|
92
|
-
# GET /sapi/v1/margin/pair
|
93
|
-
#
|
94
|
-
# @param symbol [String]
|
95
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#query-margin-pair-market_data
|
96
|
-
def margin_pair(symbol:)
|
97
|
-
Binance::Utils::Validation.require_param('symbol', symbol)
|
98
|
-
|
99
|
-
@session.limit_request(path: '/sapi/v1/margin/pair', params: { symbol: symbol })
|
100
|
-
end
|
101
|
-
|
102
8
|
# Get All Margin Assets (MARKET_DATA)
|
103
9
|
#
|
104
10
|
# GET /sapi/v1/margin/allAssets
|
105
11
|
#
|
106
|
-
# @see https://binance
|
12
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Margin-Assets
|
107
13
|
def margin_all_assets
|
108
14
|
@session.limit_request(path: '/sapi/v1/margin/allAssets')
|
109
15
|
end
|
@@ -112,7 +18,7 @@ module Binance
|
|
112
18
|
#
|
113
19
|
# GET /sapi/v1/margin/allPairs
|
114
20
|
#
|
115
|
-
# @see https://binance
|
21
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Cross-Margin-Pairs
|
116
22
|
def margin_all_pairs
|
117
23
|
@session.limit_request(path: '/sapi/v1/margin/allPairs')
|
118
24
|
end
|
@@ -121,7 +27,7 @@ module Binance
|
|
121
27
|
#
|
122
28
|
# GET /sapi/v1/margin/priceIndex
|
123
29
|
#
|
124
|
-
# @see https://binance
|
30
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Query-Margin-PriceIndex
|
125
31
|
def margin_price_index(symbol:)
|
126
32
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
127
33
|
@session.limit_request(path: '/sapi/v1/margin/priceIndex', params: { symbol: symbol })
|
@@ -146,7 +52,7 @@ module Binance
|
|
146
52
|
# @option kwargs [String] :sideEffectType NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
|
147
53
|
# @option kwargs [String] :timeInForce GTC,IOC,FOK
|
148
54
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
149
|
-
# @see https://binance
|
55
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-Order
|
150
56
|
def margin_new_order(symbol:, side:, type:, **kwargs)
|
151
57
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
152
58
|
Binance::Utils::Validation.require_param('side', side)
|
@@ -170,7 +76,7 @@ module Binance
|
|
170
76
|
# @option kwargs [String] :origClientOrderId
|
171
77
|
# @option kwargs [String] :newClientOrderId
|
172
78
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
173
|
-
# @see https://binance
|
79
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-Order
|
174
80
|
def margin_cancel_order(symbol:, **kwargs)
|
175
81
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
176
82
|
|
@@ -187,7 +93,7 @@ module Binance
|
|
187
93
|
# @param kwargs [Hash]
|
188
94
|
# @option kwargs [String] :isIsolated for isolated margin or not, "TRUE", "FALSE", default "FALSE"
|
189
95
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
190
|
-
# @see https://binance
|
96
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-All-Open-Orders
|
191
97
|
def margin_cancel_all_order(symbol:, **kwargs)
|
192
98
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
193
99
|
|
@@ -209,53 +115,11 @@ module Binance
|
|
209
115
|
# @option kwargs [Integer] :size Default:10 Max:100
|
210
116
|
# @option kwargs [String] :archived Default: false. Set to true for archived data from 6 months ago
|
211
117
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
212
|
-
# @see https://binance
|
118
|
+
# @see https://developers.binance.com/docs/margin_trading/transfer/Get-Cross-Margin-Transfer-History
|
213
119
|
def margin_transfer_history(**kwargs)
|
214
120
|
@session.sign_request(:get, '/sapi/v1/margin/transfer', params: kwargs)
|
215
121
|
end
|
216
122
|
|
217
|
-
# Query Loan Record (USER_DATA)
|
218
|
-
#
|
219
|
-
# GET /sapi/v1/margin/loan
|
220
|
-
#
|
221
|
-
# @param asset [String]
|
222
|
-
# @param kwargs [Hash]
|
223
|
-
# @option kwargs [String] :isolatedSymbol
|
224
|
-
# @option kwargs [String] :txId
|
225
|
-
# @option kwargs [Integer] :startTime
|
226
|
-
# @option kwargs [Integer] :endTime
|
227
|
-
# @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
|
228
|
-
# @option kwargs [Integer] :size Default:10 Max:100
|
229
|
-
# @option kwargs [String] :archived Default: false. Set to true for archived data from 6 months ago
|
230
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
231
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#query-loan-record-user_data
|
232
|
-
def margin_load_record(asset:, **kwargs)
|
233
|
-
Binance::Utils::Validation.require_param('asset', asset)
|
234
|
-
|
235
|
-
@session.sign_request(:get, '/sapi/v1/margin/loan', params: kwargs.merge(asset: asset))
|
236
|
-
end
|
237
|
-
|
238
|
-
# Query Repay Record (USER_DATA)
|
239
|
-
#
|
240
|
-
# GET /sapi/v1/margin/repay
|
241
|
-
#
|
242
|
-
# @param asset [String]
|
243
|
-
# @param kwargs [Hash]
|
244
|
-
# @option kwargs [String] :isolatedSymbol
|
245
|
-
# @option kwargs [String] :txId
|
246
|
-
# @option kwargs [Integer] :startTime
|
247
|
-
# @option kwargs [Integer] :endTime
|
248
|
-
# @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
|
249
|
-
# @option kwargs [Integer] :size Default:10 Max:100
|
250
|
-
# @option kwargs [String] :archived Default: false. Set to true for archived data from 6 months ago
|
251
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
252
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#query-repay-record-user_data
|
253
|
-
def margin_repay_record(asset:, **kwargs)
|
254
|
-
Binance::Utils::Validation.require_param('asset', asset)
|
255
|
-
|
256
|
-
@session.sign_request(:get, '/sapi/v1/margin/repay', params: kwargs.merge(asset: asset))
|
257
|
-
end
|
258
|
-
|
259
123
|
# Get Interest History (USER_DATA)
|
260
124
|
#
|
261
125
|
# GET /sapi/v1/margin/interestHistory
|
@@ -269,7 +133,7 @@ module Binance
|
|
269
133
|
# @option kwargs [Integer] :size Default:10 Max:100
|
270
134
|
# @option kwargs [String] :archived Default: false. Set to true for archived data from 6 months ago
|
271
135
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
272
|
-
# @see https://binance
|
136
|
+
# @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
|
273
137
|
def margin_interest_history(**kwargs)
|
274
138
|
@session.sign_request(:get, '/sapi/v1/margin/interestHistory', params: kwargs)
|
275
139
|
end
|
@@ -285,7 +149,7 @@ module Binance
|
|
285
149
|
# @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
|
286
150
|
# @option kwargs [Integer] :size Default:10 Max:100
|
287
151
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
288
|
-
# @see https://binance
|
152
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Get-Force-Liquidation-Record
|
289
153
|
def margin_force_liquidation_record(**kwargs)
|
290
154
|
@session.sign_request(:get, '/sapi/v1/margin/forceLiquidationRec', params: kwargs)
|
291
155
|
end
|
@@ -296,7 +160,7 @@ module Binance
|
|
296
160
|
#
|
297
161
|
# @param kwargs [Hash]
|
298
162
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
299
|
-
# @see https://binance
|
163
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Account-Details
|
300
164
|
def margin_account(**kwargs)
|
301
165
|
@session.sign_request(:get, '/sapi/v1/margin/account', params: kwargs)
|
302
166
|
end
|
@@ -311,7 +175,7 @@ module Binance
|
|
311
175
|
# @option kwargs [Integer] :orderId
|
312
176
|
# @option kwargs [String] :origClientOrderId
|
313
177
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
314
|
-
# @see https://binance
|
178
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Order
|
315
179
|
def margin_order(symbol:, **kwargs)
|
316
180
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
317
181
|
|
@@ -326,7 +190,7 @@ module Binance
|
|
326
190
|
# @option kwargs [String] :symbol
|
327
191
|
# @option kwargs [String] :isIsolated for isolated margin or not, "TRUE", "FALSE", default "FALSE"
|
328
192
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
329
|
-
# @see https://binance
|
193
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-Orders
|
330
194
|
def margin_open_orders(**kwargs)
|
331
195
|
@session.sign_request(:get, '/sapi/v1/margin/openOrders', params: kwargs)
|
332
196
|
end
|
@@ -343,7 +207,7 @@ module Binance
|
|
343
207
|
# @option kwargs [Integer] :endTime
|
344
208
|
# @option kwargs [Integer] :limit Default 500; max 1000.
|
345
209
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
346
|
-
# @see https://binance
|
210
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
|
347
211
|
def margin_all_orders(symbol:, **kwargs)
|
348
212
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
349
213
|
|
@@ -371,7 +235,7 @@ module Binance
|
|
371
235
|
# @option kwargs [String] :newOrderRespType
|
372
236
|
# @option kwargs [String] :sideEffectType NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
|
373
237
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
374
|
-
# @see https://binance
|
238
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-OCO
|
375
239
|
def margin_oco_order(symbol:, side:, quantity:, price:, stopPrice:, **kwargs)
|
376
240
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
377
241
|
Binance::Utils::Validation.require_param('side', side)
|
@@ -401,7 +265,7 @@ module Binance
|
|
401
265
|
# @option kwargs [String] :listClientOrderId Either orderListId or listClientOrderId must be provided
|
402
266
|
# @option kwargs [String] :newClientOrderId
|
403
267
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
404
|
-
# @see https://binance
|
268
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-OCO
|
405
269
|
def margin_cancel_oco(symbol:, **kwargs)
|
406
270
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
407
271
|
|
@@ -420,7 +284,7 @@ module Binance
|
|
420
284
|
# @option kwargs [Integer] :orderListId Either orderListId or origClientOrderId must be provided
|
421
285
|
# @option kwargs [String] :origClientOrderId Either orderListId or origClientOrderId must be provided
|
422
286
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
423
|
-
# @see https://binance
|
287
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-OCO
|
424
288
|
def margin_get_oco(**kwargs)
|
425
289
|
@session.sign_request(:get, '/sapi/v1/margin/orderList', params: kwargs)
|
426
290
|
end
|
@@ -437,7 +301,7 @@ module Binance
|
|
437
301
|
# @option kwargs [Integer] :endTime
|
438
302
|
# @option kwargs [Integer] :limit
|
439
303
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
440
|
-
# @see https://binance
|
304
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-OCO
|
441
305
|
def margin_get_all_oco(**kwargs)
|
442
306
|
@session.sign_request(:get, '/sapi/v1/margin/allOrderList', params: kwargs)
|
443
307
|
end
|
@@ -450,7 +314,7 @@ module Binance
|
|
450
314
|
# @option kwargs [String] :symbol
|
451
315
|
# @option kwargs [String] :isIsolated
|
452
316
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
453
|
-
# @see https://binance
|
317
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-OCO
|
454
318
|
def margin_get_open_oco(**kwargs)
|
455
319
|
@session.sign_request(:get, '/sapi/v1/margin/openOrderList', params: kwargs)
|
456
320
|
end
|
@@ -466,7 +330,7 @@ module Binance
|
|
466
330
|
# @option kwargs [String] :orderfromIdId
|
467
331
|
# @option kwargs [Integer] :limit Default 500; max 1000.
|
468
332
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
469
|
-
# @see https://binance
|
333
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List
|
470
334
|
def margin_my_trades(symbol:, **kwargs)
|
471
335
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
472
336
|
|
@@ -481,7 +345,7 @@ module Binance
|
|
481
345
|
# @param kwargs [Hash]
|
482
346
|
# @option kwargs [String] :isolatedSymbol
|
483
347
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
484
|
-
# @see https://binance
|
348
|
+
# @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Max-Borrow
|
485
349
|
def margin_max_borrowable(asset:, **kwargs)
|
486
350
|
Binance::Utils::Validation.require_param('asset', asset)
|
487
351
|
|
@@ -496,62 +360,13 @@ module Binance
|
|
496
360
|
# @param kwargs [Hash]
|
497
361
|
# @option kwargs [String] :isolatedSymbol
|
498
362
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
499
|
-
# @see https://binance
|
363
|
+
# @see https://developers.binance.com/docs/margin_trading/transfer/Query-Max-Transfer-Out-Amount
|
500
364
|
def margin_max_transferable(asset:, **kwargs)
|
501
365
|
Binance::Utils::Validation.require_param('asset', asset)
|
502
366
|
|
503
367
|
@session.sign_request(:get, '/sapi/v1/margin/maxTransferable', params: kwargs.merge(asset: asset))
|
504
368
|
end
|
505
369
|
|
506
|
-
# Isolated Margin Account Transfer (MARGIN)
|
507
|
-
#
|
508
|
-
# POST /sapi/v1/margin/isolated/transfer
|
509
|
-
#
|
510
|
-
# @param asset [String]
|
511
|
-
# @param symbol [String]
|
512
|
-
# @param transFrom [String] "SPOT", "ISOLATED_MARGIN"
|
513
|
-
# @param transTo [String] "SPOT", "ISOLATED_MARGIN"
|
514
|
-
# @param amount [Float]
|
515
|
-
# @param kwargs [Hash]
|
516
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
517
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#isolated-margin-account-transfer-margin
|
518
|
-
def isolated_margin_transfer(asset:, symbol:, transFrom:, transTo:, amount:, **kwargs)
|
519
|
-
Binance::Utils::Validation.require_param('asset', asset)
|
520
|
-
Binance::Utils::Validation.require_param('symbol', symbol)
|
521
|
-
Binance::Utils::Validation.require_param('transFrom', transFrom)
|
522
|
-
Binance::Utils::Validation.require_param('transTo', transTo)
|
523
|
-
Binance::Utils::Validation.require_param('amount', amount)
|
524
|
-
|
525
|
-
@session.sign_request(:post, '/sapi/v1/margin/isolated/transfer', params: kwargs.merge(
|
526
|
-
asset: asset,
|
527
|
-
symbol: symbol,
|
528
|
-
transFrom: transFrom,
|
529
|
-
transTo: transTo,
|
530
|
-
amount: amount
|
531
|
-
))
|
532
|
-
end
|
533
|
-
|
534
|
-
# Get Isolated Margin Transfer History (USER_DATA)
|
535
|
-
#
|
536
|
-
# GET /sapi/v1/margin/isolated/transfer
|
537
|
-
#
|
538
|
-
# @param symbol [String]
|
539
|
-
# @param kwargs [Hash]
|
540
|
-
# @option kwargs [String] :asset
|
541
|
-
# @option kwargs [String] :transFrom "SPOT", "ISOLATED_MARGIN"
|
542
|
-
# @option kwargs [String] :transTo "SPOT", "ISOLATED_MARGIN"
|
543
|
-
# @option kwargs [Integer] :startTime
|
544
|
-
# @option kwargs [Integer] :endTime
|
545
|
-
# @option kwargs [Integer] :current Current page, default 1
|
546
|
-
# @option kwargs [Integer] :size Default 10, max 100
|
547
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
548
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#get-isolated-margin-transfer-history-user_data
|
549
|
-
def get_isolated_margin_transfer(symbol:, **kwargs)
|
550
|
-
Binance::Utils::Validation.require_param('symbol', symbol)
|
551
|
-
|
552
|
-
@session.sign_request(:get, '/sapi/v1/margin/isolated/transfer', params: kwargs.merge(symbol: symbol))
|
553
|
-
end
|
554
|
-
|
555
370
|
# Query Isolated Margin Account Info (USER_DATA)
|
556
371
|
#
|
557
372
|
# GET /sapi/v1/margin/isolated/account
|
@@ -559,7 +374,7 @@ module Binance
|
|
559
374
|
# @param kwargs [Hash]
|
560
375
|
# @option kwargs [String] :symbols Max 5 symbols can be sent; separated by ",". e.g. "BTCUSDT,BNBUSDT,ADAUSDT"
|
561
376
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
562
|
-
# @see https://binance
|
377
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Account-Info
|
563
378
|
def get_isolated_margin_account(**kwargs)
|
564
379
|
@session.sign_request(:get, '/sapi/v1/margin/isolated/account', params: kwargs)
|
565
380
|
end
|
@@ -571,7 +386,7 @@ module Binance
|
|
571
386
|
# @param symbol [String]
|
572
387
|
# @param kwargs [Hash]
|
573
388
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
574
|
-
# @see https://binance
|
389
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Disable-Isolated-Margin-Account
|
575
390
|
def disable_isolated_margin_account(symbol:, **kwargs)
|
576
391
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
577
392
|
|
@@ -585,7 +400,7 @@ module Binance
|
|
585
400
|
# @param symbol [String]
|
586
401
|
# @param kwargs [Hash]
|
587
402
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
588
|
-
# @see https://binance
|
403
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Enable-Isolated-Margin-Account
|
589
404
|
def enable_isolated_margin_account(symbol:, **kwargs)
|
590
405
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
591
406
|
|
@@ -598,32 +413,18 @@ module Binance
|
|
598
413
|
#
|
599
414
|
# @param kwargs [Hash]
|
600
415
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
601
|
-
# @see https://binance
|
416
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Enabled-Isolated-Margin-Account-Limit
|
602
417
|
def get_isolated_margin_account_limit(**kwargs)
|
603
418
|
@session.sign_request(:get, '/sapi/v1/margin/isolated/accountLimit', params: kwargs)
|
604
419
|
end
|
605
420
|
|
606
|
-
# Query Isolated Margin Symbol (USER_DATA)
|
607
|
-
#
|
608
|
-
# GET /sapi/v1/margin/isolated/pair
|
609
|
-
#
|
610
|
-
# @param symbol [String]
|
611
|
-
# @param kwargs [Hash]
|
612
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
613
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-symbol-user_data
|
614
|
-
def get_isolated_margin_pair(symbol:, **kwargs)
|
615
|
-
Binance::Utils::Validation.require_param('symbol', symbol)
|
616
|
-
|
617
|
-
@session.sign_request(:get, '/sapi/v1/margin/isolated/pair', params: kwargs.merge(symbol: symbol))
|
618
|
-
end
|
619
|
-
|
620
421
|
# Get All Isolated Margin Symbol(USER_DATA)
|
621
422
|
#
|
622
423
|
# GET /sapi/v1/margin/isolated/allPairs
|
623
424
|
#
|
624
425
|
# @param kwargs [Hash]
|
625
426
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
626
|
-
# @see https://binance
|
427
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Isolated-Margin-Symbol
|
627
428
|
def get_all_isolated_margin_pairs(**kwargs)
|
628
429
|
@session.sign_request(:get, '/sapi/v1/margin/isolated/allPairs', params: kwargs)
|
629
430
|
end
|
@@ -638,7 +439,7 @@ module Binance
|
|
638
439
|
# @option kwargs [String] :spotBNBBurn "true" or "false"; Determines whether to use BNB to pay for trading fees on SPOT
|
639
440
|
# @option kwargs [String] :interestBNBBurn "true" or "false"; Determines whether to use BNB to pay for margin loan's interest
|
640
441
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
641
|
-
# @see https://binance
|
442
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Toggle-BNB-Burn-On-Spot-Trade-And-Margin-Interest
|
642
443
|
def toggle_bnb_burn(**kwargs)
|
643
444
|
@session.sign_request(:post, '/sapi/v1/bnbBurn', params: kwargs)
|
644
445
|
end
|
@@ -649,7 +450,7 @@ module Binance
|
|
649
450
|
#
|
650
451
|
# @param kwargs [Hash]
|
651
452
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
652
|
-
# @see https://binance
|
453
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Get-BNB-Burn-Status
|
653
454
|
def get_bnb_burn(**kwargs)
|
654
455
|
@session.sign_request(:get, '/sapi/v1/bnbBurn', params: kwargs)
|
655
456
|
end
|
@@ -665,7 +466,7 @@ module Binance
|
|
665
466
|
# @option endTime [Integer] Default: present. Maximum range: 3 months.
|
666
467
|
# @option limit [Integer] Default: 20. Maximum: 100
|
667
468
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
668
|
-
# @see https://binance
|
469
|
+
# @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History
|
669
470
|
def get_margin_interest_rate_history(asset:, **kwargs)
|
670
471
|
Binance::Utils::Validation.require_param('asset', asset)
|
671
472
|
|
@@ -680,7 +481,7 @@ module Binance
|
|
680
481
|
# @option vipLevel [Integer] Default: user's vip level
|
681
482
|
# @option coin [String]
|
682
483
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
683
|
-
# @see https://binance
|
484
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Fee-Data
|
684
485
|
def get_cross_margin_data(**kwargs)
|
685
486
|
@session.sign_request(:get, '/sapi/v1/margin/crossMarginData', params: kwargs)
|
686
487
|
end
|
@@ -693,7 +494,7 @@ module Binance
|
|
693
494
|
# @option vipLevel [Integer] Default: user's vip level
|
694
495
|
# @option symbol [String]
|
695
496
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
696
|
-
# @see https://binance
|
497
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data
|
697
498
|
def get_isolated_margin_data(**kwargs)
|
698
499
|
@session.sign_request(:get, '/sapi/v1/margin/isolatedMarginData', params: kwargs)
|
699
500
|
end
|
@@ -706,7 +507,7 @@ module Binance
|
|
706
507
|
# @param kwargs [Hash]
|
707
508
|
# @option tier [Integer]
|
708
509
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
709
|
-
# @see https://binance
|
510
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Query-Isolated-Margin-Tier-Data
|
710
511
|
def get_isolated_margin_tier(symbol:, **kwargs)
|
711
512
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
712
513
|
|
@@ -721,23 +522,10 @@ module Binance
|
|
721
522
|
# @option isIsolated [String]
|
722
523
|
# @option symbol [String]
|
723
524
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
724
|
-
# @see https://binance
|
525
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data
|
725
526
|
def get_margin_order_usage(**kwargs)
|
726
527
|
@session.sign_request(:get, '/sapi/v1/margin/rateLimit/order', params: kwargs)
|
727
528
|
end
|
728
|
-
|
729
|
-
# Margin Dustlog (USER_DATA)
|
730
|
-
#
|
731
|
-
# GET /sapi/v1/margin/dribblet
|
732
|
-
#
|
733
|
-
# @param kwargs [Hash]
|
734
|
-
# @option kwargs [String] :startTime
|
735
|
-
# @option kwargs [String] :endTime
|
736
|
-
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
737
|
-
# @see https://binance-docs.github.io/apidocs/spot/en/#margin-dustlog-user_data
|
738
|
-
def get_margin_dust_log(**kwargs)
|
739
|
-
@session.sign_request(:get, '/sapi/v1/margin/dribblet', params: kwargs)
|
740
|
-
end
|
741
529
|
end
|
742
530
|
end
|
743
531
|
end
|
data/lib/binance/spot/market.rb
CHANGED
@@ -9,13 +9,13 @@ module Binance
|
|
9
9
|
# - trades
|
10
10
|
# - orderbook
|
11
11
|
# - etc
|
12
|
-
# @see https://binance
|
12
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#market-data-endpoints
|
13
13
|
module Market
|
14
14
|
# Test Connectivity
|
15
15
|
#
|
16
16
|
# GET /api/v3/ping
|
17
17
|
#
|
18
|
-
# @see https://binance
|
18
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#test-connectivity
|
19
19
|
def ping
|
20
20
|
@session.public_request(path: '/api/v3/ping')
|
21
21
|
end
|
@@ -24,7 +24,7 @@ module Binance
|
|
24
24
|
#
|
25
25
|
# GET /api/v3/time
|
26
26
|
#
|
27
|
-
# @see https://binance
|
27
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#check-server-time
|
28
28
|
def time
|
29
29
|
@session.public_request(path: '/api/v3/time')
|
30
30
|
end
|
@@ -36,7 +36,7 @@ module Binance
|
|
36
36
|
# @option kwargs [string] :symbol
|
37
37
|
# @option kwargs [string] :symbols
|
38
38
|
# @option kwargs [string] :permissions
|
39
|
-
# @see https://binance
|
39
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#exchange-information
|
40
40
|
def exchange_info(symbol: nil, symbols: nil, permissions: nil)
|
41
41
|
if symbols.is_a?(Array)
|
42
42
|
symbols = symbols.map { |v| "%22#{v}%22" }.join(',')
|
@@ -59,7 +59,7 @@ module Binance
|
|
59
59
|
# @param symbol [String] the symbol
|
60
60
|
# @param kwargs [Hash]
|
61
61
|
# @option kwargs [Integer] :limit Default 100; max 1000. Valid limits:[5, 10, 20, 50, 100, 500, 1000, 5000]
|
62
|
-
# @see https://binance
|
62
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#order-book
|
63
63
|
def depth(symbol:, **kwargs)
|
64
64
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
65
65
|
|
@@ -76,7 +76,7 @@ module Binance
|
|
76
76
|
# @param symbol [String] the symbol
|
77
77
|
# @param kwargs [Hash]
|
78
78
|
# @option kwargs [Integer] :limit Default 500; max 1000.
|
79
|
-
# @see https://binance
|
79
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#recent-trades-list
|
80
80
|
def trades(symbol:, **kwargs)
|
81
81
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
82
82
|
|
@@ -96,7 +96,7 @@ module Binance
|
|
96
96
|
# @param kwargs [Hash]
|
97
97
|
# @option kwargs [Integer] :limit Default 500; max 1000.
|
98
98
|
# @option kwargs [Integer] :fromId Trade id to fetch from. Default gets most recent trades.
|
99
|
-
# @see https://binance
|
99
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#old-trade-lookup
|
100
100
|
def historical_trades(symbol:, **kwargs)
|
101
101
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
102
102
|
|
@@ -118,7 +118,7 @@ module Binance
|
|
118
118
|
# @option kwargs [Integer] :endTime Timestamp in ms to get aggregate trades until INCLUSIVE.
|
119
119
|
# @option kwargs [Integer] :fromId Trade id to fetch from. Default gets most recent trades.
|
120
120
|
# @option kwargs [Integer] :limit Default 500; max 1000.
|
121
|
-
# @see https://binance
|
121
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#compressedaggregate-trades-list
|
122
122
|
def agg_trades(symbol:, **kwargs)
|
123
123
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
124
124
|
|
@@ -141,7 +141,7 @@ module Binance
|
|
141
141
|
# @option kwargs [Integer] :startTime Timestamp in ms to get aggregate trades from INCLUSIVE.
|
142
142
|
# @option kwargs [Integer] :endTime Timestamp in ms to get aggregate trades until INCLUSIVE.
|
143
143
|
# @option kwargs [Integer] :limit Default 500; max 1000.
|
144
|
-
# @see https://binance
|
144
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#klinecandlestick-data
|
145
145
|
def klines(symbol:, interval:, **kwargs)
|
146
146
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
147
147
|
Binance::Utils::Validation.require_param('interval', interval)
|
@@ -162,7 +162,7 @@ module Binance
|
|
162
162
|
# GET /api/v3/avgPrice
|
163
163
|
#
|
164
164
|
# @param symbol [String] the symbol
|
165
|
-
# @see https://binance
|
165
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#current-average-price
|
166
166
|
def avg_price(symbol:)
|
167
167
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
168
168
|
|
@@ -179,7 +179,7 @@ module Binance
|
|
179
179
|
# GET /api/v3/ticker/24hr
|
180
180
|
#
|
181
181
|
# @param symbol [String] the symbol
|
182
|
-
# @see https://binance
|
182
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#24hr-ticker-price-change-statistics
|
183
183
|
def ticker_24hr(symbol: nil)
|
184
184
|
@session.public_request(
|
185
185
|
path: '/api/v3/ticker/24hr',
|
@@ -194,7 +194,7 @@ module Binance
|
|
194
194
|
# GET /api/v3/ticker/price
|
195
195
|
#
|
196
196
|
# @param symbol [String] the symbol
|
197
|
-
# @see https://binance
|
197
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#symbol-price-ticker
|
198
198
|
def ticker_price(symbol: nil)
|
199
199
|
@session.public_request(
|
200
200
|
path: '/api/v3/ticker/price',
|
@@ -209,7 +209,7 @@ module Binance
|
|
209
209
|
# GET /api/v3/ticker/bookTicker
|
210
210
|
#
|
211
211
|
# @param symbol [String] the symbol
|
212
|
-
# @see https://binance
|
212
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#symbol-order-book-ticker
|
213
213
|
def book_ticker(symbol: nil)
|
214
214
|
@session.public_request(
|
215
215
|
path: '/api/v3/ticker/bookTicker',
|
@@ -224,7 +224,7 @@ module Binance
|
|
224
224
|
# GET /api/v3/ticker/bookTicker
|
225
225
|
#
|
226
226
|
# @param symbol [String] the symbol
|
227
|
-
# @see https://binance
|
227
|
+
# @see https://developers.binance.com/docs/binance-spot-api-docs/rest-api#symbol-order-book-ticker
|
228
228
|
def ticker(symbol: nil, symbols: nil, windowSize: '1d')
|
229
229
|
raise Binance::DuplicatedParametersError.new('symbol', 'symbols') unless symbols.nil? || symbol.nil?
|
230
230
|
|