binance-connector-ruby 1.5.2 → 1.7.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 +128 -0
- data/lib/binance/session.rb +2 -1
- data/lib/binance/spot/c2c.rb +2 -2
- data/lib/binance/spot/convert.rb +134 -2
- data/lib/binance/spot/fiat.rb +3 -3
- data/lib/binance/spot/loan.rb +221 -7
- data/lib/binance/spot/margin.rb +104 -231
- data/lib/binance/spot/market.rb +73 -14
- data/lib/binance/spot/mining.rb +13 -13
- data/lib/binance/spot/simple_earn.rb +44 -24
- data/lib/binance/spot/stream.rb +1 -1
- data/lib/binance/spot/subaccount.rb +205 -52
- data/lib/binance/spot/trade.rb +94 -30
- data/lib/binance/spot/wallet.rb +140 -22
- data/lib/binance/spot/websocket.rb +23 -11
- data/lib/binance/spot.rb +1 -5
- data/lib/binance/version.rb +1 -1
- metadata +2 -4
- 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,12 +27,33 @@ 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 })
|
128
34
|
end
|
129
35
|
|
36
|
+
# Query Margin Available Inventory(USER_DATA)
|
37
|
+
#
|
38
|
+
# GET /sapi/v1/margin/available-inventory
|
39
|
+
#
|
40
|
+
# @param type [String] MARGIN or ISOLATED
|
41
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Query-margin-avaliable-inventory
|
42
|
+
def margin_available_inventory(type:)
|
43
|
+
Binance::Utils::Validation.require_param('type', type)
|
44
|
+
|
45
|
+
@session.sign_request(:get, '/sapi/v1/margin/available-inventory', params: { type: type })
|
46
|
+
end
|
47
|
+
|
48
|
+
# Query Liability Coin Leverage Bracket in Cross Margin Pro Mode(MARKET_DATA)
|
49
|
+
#
|
50
|
+
# GET /sapi/v1/margin/leverageBracket
|
51
|
+
#
|
52
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Query-Liability-Coin-Leverage-Bracket-in-Cross-Margin-Pro-Mode
|
53
|
+
def margin_leverage_bracket
|
54
|
+
@session.limit_request(path: '/sapi/v1/margin/leverageBracket')
|
55
|
+
end
|
56
|
+
|
130
57
|
# Margin Account New Order (TRADE)
|
131
58
|
#
|
132
59
|
# POST /sapi/v1/margin/order
|
@@ -146,7 +73,7 @@ module Binance
|
|
146
73
|
# @option kwargs [String] :sideEffectType NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
|
147
74
|
# @option kwargs [String] :timeInForce GTC,IOC,FOK
|
148
75
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
149
|
-
# @see https://binance
|
76
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-Order
|
150
77
|
def margin_new_order(symbol:, side:, type:, **kwargs)
|
151
78
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
152
79
|
Binance::Utils::Validation.require_param('side', side)
|
@@ -170,7 +97,7 @@ module Binance
|
|
170
97
|
# @option kwargs [String] :origClientOrderId
|
171
98
|
# @option kwargs [String] :newClientOrderId
|
172
99
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
173
|
-
# @see https://binance
|
100
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-Order
|
174
101
|
def margin_cancel_order(symbol:, **kwargs)
|
175
102
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
176
103
|
|
@@ -187,7 +114,7 @@ module Binance
|
|
187
114
|
# @param kwargs [Hash]
|
188
115
|
# @option kwargs [String] :isIsolated for isolated margin or not, "TRUE", "FALSE", default "FALSE"
|
189
116
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
190
|
-
# @see https://binance
|
117
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-All-Open-Orders
|
191
118
|
def margin_cancel_all_order(symbol:, **kwargs)
|
192
119
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
193
120
|
|
@@ -209,69 +136,76 @@ module Binance
|
|
209
136
|
# @option kwargs [Integer] :size Default:10 Max:100
|
210
137
|
# @option kwargs [String] :archived Default: false. Set to true for archived data from 6 months ago
|
211
138
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
212
|
-
# @see https://binance
|
139
|
+
# @see https://developers.binance.com/docs/margin_trading/transfer/Get-Cross-Margin-Transfer-History
|
213
140
|
def margin_transfer_history(**kwargs)
|
214
141
|
@session.sign_request(:get, '/sapi/v1/margin/transfer', params: kwargs)
|
215
142
|
end
|
216
143
|
|
217
|
-
#
|
144
|
+
# Get Interest History (USER_DATA)
|
218
145
|
#
|
219
|
-
# GET /sapi/v1/margin/
|
146
|
+
# GET /sapi/v1/margin/interestHistory
|
220
147
|
#
|
221
|
-
# @param asset [String]
|
222
148
|
# @param kwargs [Hash]
|
149
|
+
# @option kwargs [String] :asset
|
223
150
|
# @option kwargs [String] :isolatedSymbol
|
224
|
-
# @option kwargs [String] :txId
|
225
151
|
# @option kwargs [Integer] :startTime
|
226
152
|
# @option kwargs [Integer] :endTime
|
227
153
|
# @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
|
228
154
|
# @option kwargs [Integer] :size Default:10 Max:100
|
229
155
|
# @option kwargs [String] :archived Default: false. Set to true for archived data from 6 months ago
|
230
156
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
231
|
-
# @see https://binance
|
232
|
-
def
|
233
|
-
|
234
|
-
|
235
|
-
@session.sign_request(:get, '/sapi/v1/margin/loan', params: kwargs.merge(asset: asset))
|
157
|
+
# @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Get-Interest-History
|
158
|
+
def margin_interest_history(**kwargs)
|
159
|
+
@session.sign_request(:get, '/sapi/v1/margin/interestHistory', params: kwargs)
|
236
160
|
end
|
237
161
|
|
238
|
-
#
|
162
|
+
# Margin account borrow/repay (MARGIN)
|
239
163
|
#
|
240
|
-
#
|
164
|
+
# POST /sapi/v1/margin/borrow-repay
|
241
165
|
#
|
242
166
|
# @param asset [String]
|
167
|
+
# @param isIsolated [String] TRUE for Isolated Margin, FALSE for Cross Margin, Default FALSE
|
168
|
+
# @param symbol [String]
|
169
|
+
# @param amount [String]
|
170
|
+
# @param type [String] BORROW, REPAY
|
243
171
|
# @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
172
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
252
|
-
# @see https://binance
|
253
|
-
def
|
173
|
+
# @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
|
174
|
+
def margin_borrow_repay(asset:, isIsolated:, symbol:, amount:, type:, **kwargs)
|
254
175
|
Binance::Utils::Validation.require_param('asset', asset)
|
176
|
+
Binance::Utils::Validation.require_param('isIsolated', isIsolated)
|
177
|
+
Binance::Utils::Validation.require_param('symbol', symbol)
|
178
|
+
Binance::Utils::Validation.require_param('amount', amount)
|
179
|
+
Binance::Utils::Validation.require_param('type', type)
|
255
180
|
|
256
|
-
@session.sign_request(:
|
181
|
+
@session.sign_request(:post, '/sapi/v1/margin/borrow-repay', params: kwargs.merge(
|
182
|
+
asset: asset,
|
183
|
+
isIsolated: isIsolated,
|
184
|
+
symbol: symbol,
|
185
|
+
amount: amount,
|
186
|
+
type: type
|
187
|
+
))
|
257
188
|
end
|
258
189
|
|
259
|
-
#
|
190
|
+
# Query borrow/repay records in Margin account (USER_DATA)
|
260
191
|
#
|
261
|
-
# GET /sapi/v1/margin/
|
192
|
+
# GET /sapi/v1/margin/borrow-repay
|
262
193
|
#
|
194
|
+
# @param type [String] BORROW or REPAY
|
263
195
|
# @param kwargs [Hash]
|
264
196
|
# @option kwargs [String] :asset
|
265
|
-
# @option kwargs [String] :
|
197
|
+
# @option kwargs [String] :isIsolated
|
198
|
+
# @option kwargs [String] :txId
|
266
199
|
# @option kwargs [Integer] :startTime
|
267
200
|
# @option kwargs [Integer] :endTime
|
268
201
|
# @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
|
269
202
|
# @option kwargs [Integer] :size Default:10 Max:100
|
270
|
-
# @option kwargs [String] :archived Default: false. Set to true for archived data from 6 months ago
|
271
203
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
272
|
-
# @see https://binance
|
273
|
-
def
|
274
|
-
|
204
|
+
# @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Borrow-Repay
|
205
|
+
def margin_borrow_repay_record(type:, **kwargs)
|
206
|
+
Binance::Utils::Validation.require_param('type', type)
|
207
|
+
|
208
|
+
@session.sign_request(:get, '/sapi/v1/margin/borrow-repay', params: kwargs.merge(type: type))
|
275
209
|
end
|
276
210
|
|
277
211
|
# Get Force Liquidation Record (USER_DATA)
|
@@ -285,7 +219,7 @@ module Binance
|
|
285
219
|
# @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
|
286
220
|
# @option kwargs [Integer] :size Default:10 Max:100
|
287
221
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
288
|
-
# @see https://binance
|
222
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Get-Force-Liquidation-Record
|
289
223
|
def margin_force_liquidation_record(**kwargs)
|
290
224
|
@session.sign_request(:get, '/sapi/v1/margin/forceLiquidationRec', params: kwargs)
|
291
225
|
end
|
@@ -296,7 +230,7 @@ module Binance
|
|
296
230
|
#
|
297
231
|
# @param kwargs [Hash]
|
298
232
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
299
|
-
# @see https://binance
|
233
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Account-Details
|
300
234
|
def margin_account(**kwargs)
|
301
235
|
@session.sign_request(:get, '/sapi/v1/margin/account', params: kwargs)
|
302
236
|
end
|
@@ -311,7 +245,7 @@ module Binance
|
|
311
245
|
# @option kwargs [Integer] :orderId
|
312
246
|
# @option kwargs [String] :origClientOrderId
|
313
247
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
314
|
-
# @see https://binance
|
248
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Order
|
315
249
|
def margin_order(symbol:, **kwargs)
|
316
250
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
317
251
|
|
@@ -326,7 +260,7 @@ module Binance
|
|
326
260
|
# @option kwargs [String] :symbol
|
327
261
|
# @option kwargs [String] :isIsolated for isolated margin or not, "TRUE", "FALSE", default "FALSE"
|
328
262
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
329
|
-
# @see https://binance
|
263
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-Orders
|
330
264
|
def margin_open_orders(**kwargs)
|
331
265
|
@session.sign_request(:get, '/sapi/v1/margin/openOrders', params: kwargs)
|
332
266
|
end
|
@@ -343,7 +277,7 @@ module Binance
|
|
343
277
|
# @option kwargs [Integer] :endTime
|
344
278
|
# @option kwargs [Integer] :limit Default 500; max 1000.
|
345
279
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
346
|
-
# @see https://binance
|
280
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-Orders
|
347
281
|
def margin_all_orders(symbol:, **kwargs)
|
348
282
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
349
283
|
|
@@ -371,7 +305,7 @@ module Binance
|
|
371
305
|
# @option kwargs [String] :newOrderRespType
|
372
306
|
# @option kwargs [String] :sideEffectType NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
|
373
307
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
374
|
-
# @see https://binance
|
308
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-New-OCO
|
375
309
|
def margin_oco_order(symbol:, side:, quantity:, price:, stopPrice:, **kwargs)
|
376
310
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
377
311
|
Binance::Utils::Validation.require_param('side', side)
|
@@ -401,7 +335,7 @@ module Binance
|
|
401
335
|
# @option kwargs [String] :listClientOrderId Either orderListId or listClientOrderId must be provided
|
402
336
|
# @option kwargs [String] :newClientOrderId
|
403
337
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
404
|
-
# @see https://binance
|
338
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Account-Cancel-OCO
|
405
339
|
def margin_cancel_oco(symbol:, **kwargs)
|
406
340
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
407
341
|
|
@@ -420,7 +354,7 @@ module Binance
|
|
420
354
|
# @option kwargs [Integer] :orderListId Either orderListId or origClientOrderId must be provided
|
421
355
|
# @option kwargs [String] :origClientOrderId Either orderListId or origClientOrderId must be provided
|
422
356
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
423
|
-
# @see https://binance
|
357
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-OCO
|
424
358
|
def margin_get_oco(**kwargs)
|
425
359
|
@session.sign_request(:get, '/sapi/v1/margin/orderList', params: kwargs)
|
426
360
|
end
|
@@ -437,7 +371,7 @@ module Binance
|
|
437
371
|
# @option kwargs [Integer] :endTime
|
438
372
|
# @option kwargs [Integer] :limit
|
439
373
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
440
|
-
# @see https://binance
|
374
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-All-OCO
|
441
375
|
def margin_get_all_oco(**kwargs)
|
442
376
|
@session.sign_request(:get, '/sapi/v1/margin/allOrderList', params: kwargs)
|
443
377
|
end
|
@@ -450,7 +384,7 @@ module Binance
|
|
450
384
|
# @option kwargs [String] :symbol
|
451
385
|
# @option kwargs [String] :isIsolated
|
452
386
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
453
|
-
# @see https://binance
|
387
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Open-OCO
|
454
388
|
def margin_get_open_oco(**kwargs)
|
455
389
|
@session.sign_request(:get, '/sapi/v1/margin/openOrderList', params: kwargs)
|
456
390
|
end
|
@@ -466,13 +400,28 @@ module Binance
|
|
466
400
|
# @option kwargs [String] :orderfromIdId
|
467
401
|
# @option kwargs [Integer] :limit Default 500; max 1000.
|
468
402
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
469
|
-
# @see https://binance
|
403
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Query-Margin-Account-Trade-List
|
470
404
|
def margin_my_trades(symbol:, **kwargs)
|
471
405
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
472
406
|
|
473
407
|
@session.sign_request(:get, '/sapi/v1/margin/myTrades', params: kwargs.merge(symbol: symbol))
|
474
408
|
end
|
475
409
|
|
410
|
+
# Margin Manual Liquidation
|
411
|
+
#
|
412
|
+
# POST /sapi/v1/margin/manual-liquidation
|
413
|
+
#
|
414
|
+
# @param type [String] MARGIN or ISOLATED
|
415
|
+
# @param kwargs [Hash]
|
416
|
+
# @param kwargs [String] :symbol When type selects ISOLATED, symbol must be filled in
|
417
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
418
|
+
# @see https://developers.binance.com/docs/margin_trading/trade/Margin-Manual-Liquidation
|
419
|
+
def margin_manual_liquidation(type:, **kwargs)
|
420
|
+
Binance::Utils::Validation.require_param('type', type)
|
421
|
+
|
422
|
+
@session.sign_request(:post, '/sapi/v1/margin/manual-liquidation', params: kwargs.merge(type: type))
|
423
|
+
end
|
424
|
+
|
476
425
|
# Query Max Borrow (USER_DATA)
|
477
426
|
#
|
478
427
|
# GET /sapi/v1/margin/maxBorrowable
|
@@ -481,7 +430,7 @@ module Binance
|
|
481
430
|
# @param kwargs [Hash]
|
482
431
|
# @option kwargs [String] :isolatedSymbol
|
483
432
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
484
|
-
# @see https://binance
|
433
|
+
# @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Max-Borrow
|
485
434
|
def margin_max_borrowable(asset:, **kwargs)
|
486
435
|
Binance::Utils::Validation.require_param('asset', asset)
|
487
436
|
|
@@ -496,62 +445,13 @@ module Binance
|
|
496
445
|
# @param kwargs [Hash]
|
497
446
|
# @option kwargs [String] :isolatedSymbol
|
498
447
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
499
|
-
# @see https://binance
|
448
|
+
# @see https://developers.binance.com/docs/margin_trading/transfer/Query-Max-Transfer-Out-Amount
|
500
449
|
def margin_max_transferable(asset:, **kwargs)
|
501
450
|
Binance::Utils::Validation.require_param('asset', asset)
|
502
451
|
|
503
452
|
@session.sign_request(:get, '/sapi/v1/margin/maxTransferable', params: kwargs.merge(asset: asset))
|
504
453
|
end
|
505
454
|
|
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
455
|
# Query Isolated Margin Account Info (USER_DATA)
|
556
456
|
#
|
557
457
|
# GET /sapi/v1/margin/isolated/account
|
@@ -559,7 +459,7 @@ module Binance
|
|
559
459
|
# @param kwargs [Hash]
|
560
460
|
# @option kwargs [String] :symbols Max 5 symbols can be sent; separated by ",". e.g. "BTCUSDT,BNBUSDT,ADAUSDT"
|
561
461
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
562
|
-
# @see https://binance
|
462
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Account-Info
|
563
463
|
def get_isolated_margin_account(**kwargs)
|
564
464
|
@session.sign_request(:get, '/sapi/v1/margin/isolated/account', params: kwargs)
|
565
465
|
end
|
@@ -571,7 +471,7 @@ module Binance
|
|
571
471
|
# @param symbol [String]
|
572
472
|
# @param kwargs [Hash]
|
573
473
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
574
|
-
# @see https://binance
|
474
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Disable-Isolated-Margin-Account
|
575
475
|
def disable_isolated_margin_account(symbol:, **kwargs)
|
576
476
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
577
477
|
|
@@ -585,7 +485,7 @@ module Binance
|
|
585
485
|
# @param symbol [String]
|
586
486
|
# @param kwargs [Hash]
|
587
487
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
588
|
-
# @see https://binance
|
488
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Enable-Isolated-Margin-Account
|
589
489
|
def enable_isolated_margin_account(symbol:, **kwargs)
|
590
490
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
591
491
|
|
@@ -598,32 +498,18 @@ module Binance
|
|
598
498
|
#
|
599
499
|
# @param kwargs [Hash]
|
600
500
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
601
|
-
# @see https://binance
|
501
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Enabled-Isolated-Margin-Account-Limit
|
602
502
|
def get_isolated_margin_account_limit(**kwargs)
|
603
503
|
@session.sign_request(:get, '/sapi/v1/margin/isolated/accountLimit', params: kwargs)
|
604
504
|
end
|
605
505
|
|
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
506
|
# Get All Isolated Margin Symbol(USER_DATA)
|
621
507
|
#
|
622
508
|
# GET /sapi/v1/margin/isolated/allPairs
|
623
509
|
#
|
624
510
|
# @param kwargs [Hash]
|
625
511
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
626
|
-
# @see https://binance
|
512
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Get-All-Isolated-Margin-Symbol
|
627
513
|
def get_all_isolated_margin_pairs(**kwargs)
|
628
514
|
@session.sign_request(:get, '/sapi/v1/margin/isolated/allPairs', params: kwargs)
|
629
515
|
end
|
@@ -638,7 +524,7 @@ module Binance
|
|
638
524
|
# @option kwargs [String] :spotBNBBurn "true" or "false"; Determines whether to use BNB to pay for trading fees on SPOT
|
639
525
|
# @option kwargs [String] :interestBNBBurn "true" or "false"; Determines whether to use BNB to pay for margin loan's interest
|
640
526
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
641
|
-
# @see https://binance
|
527
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Toggle-BNB-Burn-On-Spot-Trade-And-Margin-Interest
|
642
528
|
def toggle_bnb_burn(**kwargs)
|
643
529
|
@session.sign_request(:post, '/sapi/v1/bnbBurn', params: kwargs)
|
644
530
|
end
|
@@ -649,7 +535,7 @@ module Binance
|
|
649
535
|
#
|
650
536
|
# @param kwargs [Hash]
|
651
537
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
652
|
-
# @see https://binance
|
538
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Get-BNB-Burn-Status
|
653
539
|
def get_bnb_burn(**kwargs)
|
654
540
|
@session.sign_request(:get, '/sapi/v1/bnbBurn', params: kwargs)
|
655
541
|
end
|
@@ -665,7 +551,7 @@ module Binance
|
|
665
551
|
# @option endTime [Integer] Default: present. Maximum range: 3 months.
|
666
552
|
# @option limit [Integer] Default: 20. Maximum: 100
|
667
553
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
668
|
-
# @see https://binance
|
554
|
+
# @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Query-Margin-Interest-Rate-History
|
669
555
|
def get_margin_interest_rate_history(asset:, **kwargs)
|
670
556
|
Binance::Utils::Validation.require_param('asset', asset)
|
671
557
|
|
@@ -680,7 +566,7 @@ module Binance
|
|
680
566
|
# @option vipLevel [Integer] Default: user's vip level
|
681
567
|
# @option coin [String]
|
682
568
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
683
|
-
# @see https://binance
|
569
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Cross-Margin-Fee-Data
|
684
570
|
def get_cross_margin_data(**kwargs)
|
685
571
|
@session.sign_request(:get, '/sapi/v1/margin/crossMarginData', params: kwargs)
|
686
572
|
end
|
@@ -693,7 +579,7 @@ module Binance
|
|
693
579
|
# @option vipLevel [Integer] Default: user's vip level
|
694
580
|
# @option symbol [String]
|
695
581
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
696
|
-
# @see https://binance
|
582
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data
|
697
583
|
def get_isolated_margin_data(**kwargs)
|
698
584
|
@session.sign_request(:get, '/sapi/v1/margin/isolatedMarginData', params: kwargs)
|
699
585
|
end
|
@@ -706,7 +592,7 @@ module Binance
|
|
706
592
|
# @param kwargs [Hash]
|
707
593
|
# @option tier [Integer]
|
708
594
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
709
|
-
# @see https://binance
|
595
|
+
# @see https://developers.binance.com/docs/margin_trading/market-data/Query-Isolated-Margin-Tier-Data
|
710
596
|
def get_isolated_margin_tier(symbol:, **kwargs)
|
711
597
|
Binance::Utils::Validation.require_param('symbol', symbol)
|
712
598
|
|
@@ -721,23 +607,10 @@ module Binance
|
|
721
607
|
# @option isIsolated [String]
|
722
608
|
# @option symbol [String]
|
723
609
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
724
|
-
# @see https://binance
|
610
|
+
# @see https://developers.binance.com/docs/margin_trading/account/Query-Isolated-Margin-Fee-Data
|
725
611
|
def get_margin_order_usage(**kwargs)
|
726
612
|
@session.sign_request(:get, '/sapi/v1/margin/rateLimit/order', params: kwargs)
|
727
613
|
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
614
|
end
|
742
615
|
end
|
743
616
|
end
|