binance-connector-ruby 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +76 -0
- data/lib/binance/session.rb +2 -1
- data/lib/binance/spot/convert.rb +133 -1
- data/lib/binance/spot/loan.rb +219 -5
- data/lib/binance/spot/margin.rb +85 -0
- data/lib/binance/spot/market.rb +73 -14
- data/lib/binance/spot/simple_earn.rb +20 -0
- data/lib/binance/spot/subaccount.rb +173 -0
- data/lib/binance/spot/trade.rb +93 -29
- data/lib/binance/spot/wallet.rb +118 -0
- data/lib/binance/spot/websocket.rb +12 -0
- data/lib/binance/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7772695ac930d9fc5f8be1a2c90acea825f57d9a7bab222fa0bc98eda4ad4b68
|
4
|
+
data.tar.gz: 4eebab3405f8a25a76e59bdf25ff42efad8d04d74571e4aa65201d9c50f397f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16d3f195fb8e3a86e79d781320a6ca7646457e4e4f85e6852c8ef309004336215b56b800a98e306179c80cbe494a1bf7f7a15c778bdb9450cd9bc8b3d9486903
|
7
|
+
data.tar.gz: 98b92b80f7965279756cb7e63a29c15d18cd44d49b4322800e189b24901ec029b02c085694d41279168d931d8b3e2f72df036ae906a9ddf78cc14b15e319e6ce
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,81 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.7.0 -2024-12-05
|
4
|
+
### Added
|
5
|
+
- Convert endpoints:
|
6
|
+
- `GET /sapi/v1/convert/exchangeInfo`
|
7
|
+
- `GET /sapi/v1/convert/assetInfo`
|
8
|
+
- `POST /sapi/v1/convert/getQuote`
|
9
|
+
- `POST /sapi/v1/convert/acceptQuote`
|
10
|
+
- `GET /sapi/v1/convert/orderStatus`
|
11
|
+
- `POST /sapi/v1/convert/limit/placeOrder`
|
12
|
+
- `POST /sapi/v1/convert/limit/cancelOrder`
|
13
|
+
- `POST /sapi/v1/convert/limit/queryOpenOrders`
|
14
|
+
|
15
|
+
- Loan endpoints:
|
16
|
+
- `GET /sapi/v2/loan/flexible/collateral/data`
|
17
|
+
- `GET /sapi/v2/loan/flexible/loanable/data`
|
18
|
+
- `POST /sapi/v2/loan/flexible/borrow`
|
19
|
+
- `POST /sapi/v2/loan/flexible/repay`
|
20
|
+
- `POST /sapi/v2/loan/flexible/adjust/ltv`
|
21
|
+
- `GET /sapi/v2/loan/flexible/ltv/adjustment/history`
|
22
|
+
- `GET /sapi/v2/loan/flexible/borrow/history`
|
23
|
+
- `GET /sapi/v2/loan/flexible/ongoing/orders`
|
24
|
+
- `GET /sapi/v2/loan/flexible/repay/history`
|
25
|
+
- `GET /sapi/v1/loan/borrow/history`
|
26
|
+
- `GET /sapi/v1/loan/ltv/adjustment/history`
|
27
|
+
- `GET /sapi/v1/loan/repay/history`
|
28
|
+
|
29
|
+
- Margin endpoints:
|
30
|
+
- `POST /sapi/v1/margin/borrow-repay`
|
31
|
+
- `GET /sapi/v1/margin/borrow-repay`
|
32
|
+
- `GET /sapi/v1/margin/available-inventory`
|
33
|
+
- `GET /sapi/v1/margin/leverageBracket`
|
34
|
+
- `POST /sapi/v1/margin/manual-liquidation`
|
35
|
+
|
36
|
+
- Market endpoints:
|
37
|
+
- `GET /api/v3/ticker/tradingDay`
|
38
|
+
- `GET /api/v3/uiKlines`
|
39
|
+
|
40
|
+
- Simple Earn endpoints:
|
41
|
+
- `POST /sapi/v1/simple-earn/locked/setRedeemOption`
|
42
|
+
|
43
|
+
- Sub Account endpoints:
|
44
|
+
- `GET /sapi/v4/sub-account/assets`
|
45
|
+
- `POST /sapi/v1/sub-account/eoptions/enable`
|
46
|
+
- `GET /sapi/v1/managed-subaccount/marginAsset`
|
47
|
+
- `GET /sapi/v1/sub-account/transaction-statistics`
|
48
|
+
- `GET /sapi/v1/managed-subaccount/fetch-future-asset`
|
49
|
+
- `GET /sapi/v1/managed-subaccount/queryTransLogForTradeParent`
|
50
|
+
- `GET /sapi/v1/managed-subaccount/query-trans-log`
|
51
|
+
- `GET /sapi/v1/managed-subaccount/queryTransLogForInvestor`
|
52
|
+
- `GET /sapi/v1/managed-subaccount/info`
|
53
|
+
|
54
|
+
- Trade endpoint:
|
55
|
+
- `GET /api/v3/myPreventedMatches`
|
56
|
+
- `GET /api/v3/myAllocations`
|
57
|
+
- `GET /api/v3/account/commission`
|
58
|
+
|
59
|
+
- Wallet endpoints:
|
60
|
+
- `GET /sapi/v1/spot/delist-schedule`
|
61
|
+
- `GET /sapi/v1/capital/deposit/address/list`
|
62
|
+
- `POST /sapi/v1/capital/deposit/credit-apply`
|
63
|
+
- `GET /sapi/v1/asset/wallet/balance`
|
64
|
+
- `POST /sapi/v1/asset/dust-btc`
|
65
|
+
- `GET /sapi/v1/asset/ledger-transfer/cloud-mining/queryByPage`
|
66
|
+
- `GET /sapi/v1/asset/custody/transfer-history`
|
67
|
+
- `GET /sapi/v1/account/info`
|
68
|
+
|
69
|
+
- Websocket:
|
70
|
+
- `<symbol>@avgPrice`
|
71
|
+
|
72
|
+
### Changed
|
73
|
+
- Added new parameter `redeemTo` to endpoint `POST /sapi/v1/simple-earn/locked/subscribe`
|
74
|
+
- Added new parameter `timeZone` to endpoint `GET /api/v3/klines`
|
75
|
+
- Added new parameters `orderRateLimitExceededMode`, `strategyId`, `strategyType`, `selfTradePreventionMode` and `cancelRestrictions` to endpoint `POST /api/v3/order/cancelReplace`
|
76
|
+
- Added new parameters `showPermissionSets` and `symbolStatus` to endpoint `GET /api/v3/exchangeInfo`
|
77
|
+
- Replaced endpoint `POST /api/v3/order/oco` by `POST /api/v3/orderList/oco`
|
78
|
+
|
3
79
|
## 1.6.0 - 2024-10-02
|
4
80
|
|
5
81
|
### Changed
|
data/lib/binance/session.rb
CHANGED
@@ -33,7 +33,8 @@ module Binance
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def process_request(conn, method, path, params)
|
36
|
-
|
36
|
+
compact = (params || {}).compact || {}
|
37
|
+
response = conn.send(method, path_with_query(path, compact), nil)
|
37
38
|
extract_response(response)
|
38
39
|
rescue Faraday::ClientError => e
|
39
40
|
raise Binance::ClientError, e.response
|
data/lib/binance/spot/convert.rb
CHANGED
@@ -5,6 +5,68 @@ module Binance
|
|
5
5
|
# Convert endpoints
|
6
6
|
# @see https://developers.binance.com/docs/convert/Introduction
|
7
7
|
module Convert
|
8
|
+
# List All Convert Pairs
|
9
|
+
#
|
10
|
+
# GET /sapi/v1/convert/exchangeInfo
|
11
|
+
#
|
12
|
+
# @param kwargs [Hash]
|
13
|
+
# @option kwargs [String] :fromAsset Either fromAsset or toAsset or both should be send. User spends coin
|
14
|
+
# @option kwargs [String] :toAsset Either fromAsset or toAsset or both should be send. User spends coin
|
15
|
+
# @see https://developers.binance.com/docs/convert/market-data
|
16
|
+
def convert_exchange_info(**kwargs)
|
17
|
+
@session.sign_request(:get, '/sapi/v1/convert/exchangeInfo', params: kwargs)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Query order quantity precision per asset (USER_DATA)
|
21
|
+
#
|
22
|
+
# GET /sapi/v1/convert/assetInfo
|
23
|
+
#
|
24
|
+
# @param kwargs [Hash]
|
25
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
26
|
+
# @see https://developers.binance.com/docs/convert/market-data/Query-order-quantity-precision-per-asset
|
27
|
+
def convert_asset_info(**kwargs)
|
28
|
+
@session.sign_request(:get, '/sapi/v1/convert/assetInfo', params: kwargs)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Send Quote Request (USER_DATA)
|
32
|
+
#
|
33
|
+
# POST /sapi/v1/convert/getQuote
|
34
|
+
#
|
35
|
+
# @param fromAsset [String]
|
36
|
+
# @param toAsset [String]
|
37
|
+
# @param kwargs [Hash]
|
38
|
+
# @option kwargs [Float] :fromAmount Either fromAmount or toAmount should be specified. When specified, it is the amount you will be debited after the conversion
|
39
|
+
# @option kwargs [Float] :toAmount Either fromAmount or toAmount should be specified. When specified, it is the amount you will be credited after the conversion
|
40
|
+
# @option kwargs [String] :walletType SPOT or FUNDING. Default is SPOT
|
41
|
+
# @option kwargs [String] :validTime 10s, 30s, 1m, default 10s
|
42
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
43
|
+
# @see https://developers.binance.com/docs/convert/trade
|
44
|
+
def convert_get_quote(fromAsset:, toAsset:, **kwargs)
|
45
|
+
Binance::Utils::Validation.require_param('fromAsset', fromAsset)
|
46
|
+
Binance::Utils::Validation.require_param('toAsset', toAsset)
|
47
|
+
|
48
|
+
@session.sign_request(:post, '/sapi/v1/convert/getQuote', params: kwargs.merge(
|
49
|
+
fromAsset: fromAsset,
|
50
|
+
toAsset: toAsset
|
51
|
+
))
|
52
|
+
end
|
53
|
+
|
54
|
+
# Accept Quote (TRADE)
|
55
|
+
#
|
56
|
+
# POST /sapi/v1/convert/acceptQuote
|
57
|
+
#
|
58
|
+
# @param quoteId [String]
|
59
|
+
# @param kwargs [Hash]
|
60
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
61
|
+
# @see https://developers.binance.com/docs/convert/trade/Accept-Quote
|
62
|
+
def convert_accept_quote(quoteId:, **kwargs)
|
63
|
+
Binance::Utils::Validation.require_param('quoteId', quoteId)
|
64
|
+
|
65
|
+
@session.sign_request(:post, '/sapi/v1/convert/acceptQuote', params: kwargs.merge(
|
66
|
+
quoteId: quoteId
|
67
|
+
))
|
68
|
+
end
|
69
|
+
|
8
70
|
# Get Convert Trade History (USER_DATA)
|
9
71
|
#
|
10
72
|
# GET /sapi/v1/convert/tradeFlow
|
@@ -14,7 +76,7 @@ module Binance
|
|
14
76
|
# @param kwargs [Hash]
|
15
77
|
# @option kwargs [Integer] :limit default 100, max 1000
|
16
78
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
17
|
-
# @see https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History
|
79
|
+
# @see https://developers.binance.com/docs/convert/trade/Get-Convert-Trade-History
|
18
80
|
def convert_trade_flow(startTime:, endTime:, **kwargs)
|
19
81
|
Binance::Utils::Validation.require_param('startTime', startTime)
|
20
82
|
Binance::Utils::Validation.require_param('endTime', endTime)
|
@@ -24,6 +86,76 @@ module Binance
|
|
24
86
|
endTime: endTime
|
25
87
|
))
|
26
88
|
end
|
89
|
+
|
90
|
+
# Order status (USER_DATA)
|
91
|
+
#
|
92
|
+
# GET /sapi/v1/convert/orderStatus
|
93
|
+
#
|
94
|
+
# @param kwargs [Hash]
|
95
|
+
# @option kwargs [String] :orderId Either orderId or quoteId is required
|
96
|
+
# @option kwargs [String] :quoteId Either orderId or quoteId is required
|
97
|
+
# @see https://developers.binance.com/docs/convert/trade/Order-Status
|
98
|
+
def convert_order_status(**kwargs)
|
99
|
+
@session.sign_request(:get, '/sapi/v1/convert/orderStatus', params: kwargs)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Place limit order (USER_DATA)
|
103
|
+
#
|
104
|
+
# POST /sapi/v1/convert/limit/placeOrder
|
105
|
+
#
|
106
|
+
# @param baseAsset [String] base asset (use the response fromIsBase from GET /sapi/v1/convert/exchangeInfo api to check which one is baseAsset)
|
107
|
+
# @param quoteAsset [String] quote asset
|
108
|
+
# @param limitPrice [Float] Symbol limit price (from baseAsset to quoteAsset)
|
109
|
+
# @param side [String] BUY or SELL
|
110
|
+
# @param expiredType [String] 1_D, 3_D, 7_D, 30_D (D means day)
|
111
|
+
# @param kwargs [Hash]
|
112
|
+
# @option kwargs [Float] :baseAmount Base asset amount. (One of baseAmount or quoteAmount is required)
|
113
|
+
# @option kwargs [Float] :quoteAmount Quote asset amount. (One of baseAmount or quoteAmount is required)
|
114
|
+
# @option kwargs [String] :walletType SPOT or FUNDING or SPOT_FUNDING. It is to use which type of assets. Default is SPOT.
|
115
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
116
|
+
# @see https://developers.binance.com/docs/convert/trade/Place-Order
|
117
|
+
def convert_limit_place_order(baseAsset:, quoteAsset:, limitPrice:, side:, expiredType:, **kwargs)
|
118
|
+
Binance::Utils::Validation.require_param('baseAsset', baseAsset)
|
119
|
+
Binance::Utils::Validation.require_param('quoteAsset', quoteAsset)
|
120
|
+
Binance::Utils::Validation.require_param('limitPrice', limitPrice)
|
121
|
+
Binance::Utils::Validation.require_param('side', side)
|
122
|
+
Binance::Utils::Validation.require_param('expiredType', expiredType)
|
123
|
+
|
124
|
+
@session.sign_request(:post, '/sapi/v1/convert/limit/placeOrder', params: kwargs.merge(
|
125
|
+
baseAsset: baseAsset,
|
126
|
+
quoteAsset: quoteAsset,
|
127
|
+
limitPrice: limitPrice,
|
128
|
+
side: side,
|
129
|
+
expiredType: expiredType
|
130
|
+
))
|
131
|
+
end
|
132
|
+
|
133
|
+
# Cancel limit order (USER_DATA)
|
134
|
+
#
|
135
|
+
# POST /sapi/v1/convert/limit/cancelOrder
|
136
|
+
#
|
137
|
+
# @param orderId [String]
|
138
|
+
# @param kwargs [Hash]
|
139
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
140
|
+
# @see https://developers.binance.com/docs/convert/trade/Cancel-Order
|
141
|
+
def convert_limit_cancel_order(orderId:, **kwargs)
|
142
|
+
Binance::Utils::Validation.require_param('orderId', orderId)
|
143
|
+
|
144
|
+
@session.sign_request(:post, '/sapi/v1/convert/limit/cancelOrder', params: kwargs.merge(
|
145
|
+
orderId: orderId
|
146
|
+
))
|
147
|
+
end
|
148
|
+
|
149
|
+
# Query limit open orders (USER_DATA)
|
150
|
+
#
|
151
|
+
# POST /sapi/v1/convert/limit/queryOpenOrders
|
152
|
+
#
|
153
|
+
# @param kwargs [Hash]
|
154
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
155
|
+
# @see https://developers.binance.com/docs/convert/trade/Query-Order
|
156
|
+
def convert_limit_query_open_orders(**kwargs)
|
157
|
+
@session.sign_request(:post, '/sapi/v1/convert/limit/queryOpenOrders', params: kwargs)
|
158
|
+
end
|
27
159
|
end
|
28
160
|
end
|
29
161
|
end
|
data/lib/binance/spot/loan.rb
CHANGED
@@ -5,21 +5,235 @@ module Binance
|
|
5
5
|
# all loan endpoints
|
6
6
|
# @see https://developers.binance.com/docs/crypto_loan/Introduction
|
7
7
|
module Loan
|
8
|
+
# Get Flexible Loan Collateral Assets Data (USER_DATA)
|
9
|
+
#
|
10
|
+
# GET /sapi/v2/loan/flexible/collateral/data
|
11
|
+
#
|
12
|
+
# @param kwargs [Hash]
|
13
|
+
# @option kwargs [String] :collateralCoin
|
14
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
15
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/market-data
|
16
|
+
def get_flexible_loan_collateral_data(**kwargs)
|
17
|
+
@session.sign_request(:get, '/sapi/v2/loan/flexible/collateral/data', params: kwargs)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get Flexible Loan Assets Data (USER_DATA)
|
21
|
+
#
|
22
|
+
# GET /sapi/v2/loan/flexible/loanable/data
|
23
|
+
#
|
24
|
+
# @param kwargs [Hash]
|
25
|
+
# @option kwargs [String] :loanCoin
|
26
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
27
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/market-data/Get-Flexible-Loan-Assets-Data
|
28
|
+
def get_flexible_loan_assets_data(**kwargs)
|
29
|
+
@session.sign_request(:get, '/sapi/v2/loan/flexible/loanable/data', params: kwargs)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Flexible Loan Borrow (TRADE)
|
33
|
+
#
|
34
|
+
# POST /sapi/v2/loan/flexible/borrow
|
35
|
+
#
|
36
|
+
# @param loanCoin [String]
|
37
|
+
# @param collateralCoin [String]
|
38
|
+
# @param kwargs [Hash]
|
39
|
+
# @option kwargs [Float] :loanAmount Mandatory when collateralAmount is empty
|
40
|
+
# @option kwargs [Float] :collateralAmount Mandatory when loanAmount is empty
|
41
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
42
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/trade
|
43
|
+
def borrow_flexible_loan(loanCoin:, collateralCoin:, **kwargs)
|
44
|
+
Binance::Utils::Validation.require_param('loanCoin', loanCoin)
|
45
|
+
Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
|
46
|
+
|
47
|
+
@session.sign_request(:post, '/sapi/v2/loan/flexible/borrow', params: kwargs.merge(
|
48
|
+
loanCoin: loanCoin,
|
49
|
+
collateralCoin: collateralCoin
|
50
|
+
))
|
51
|
+
end
|
52
|
+
|
53
|
+
# Flexible Loan Repay (TRADE)
|
54
|
+
#
|
55
|
+
# POST /sapi/v2/loan/flexible/repay
|
56
|
+
#
|
57
|
+
# @param loanCoin [String]
|
58
|
+
# @param collateralCoin [String]
|
59
|
+
# @param repayAmount [Float]
|
60
|
+
# @param kwargs [Hash]
|
61
|
+
# @option kwargs [Boolean] :collateralReturn Default: TRUE. TRUE: Return extra collateral to spot account; FALSE: Keep extra collateral in the order, and lower LTV.
|
62
|
+
# @option kwargs [Boolean] :fullRepayment Default: FALSE. TRUE: Full repayment; FALSE: Partial repayment, based on loanAmount
|
63
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
64
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/trade/Flexible-Loan-Repay
|
65
|
+
def repay_flexible_loan(loanCoin:, collateralCoin:, repayAmount:, **kwargs)
|
66
|
+
Binance::Utils::Validation.require_param('loanCoin', loanCoin)
|
67
|
+
Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
|
68
|
+
Binance::Utils::Validation.require_param('repayAmount', repayAmount)
|
69
|
+
|
70
|
+
@session.sign_request(:post, '/sapi/v2/loan/flexible/repay', params: kwargs.merge(
|
71
|
+
loanCoin: loanCoin,
|
72
|
+
collateralCoin: collateralCoin,
|
73
|
+
repayAmount: repayAmount
|
74
|
+
))
|
75
|
+
end
|
76
|
+
|
77
|
+
# Flexible Loan Adjust LTV (TRADE)
|
78
|
+
#
|
79
|
+
# POST /sapi/v2/loan/flexible/adjust/ltv
|
80
|
+
#
|
81
|
+
# @param loanCoin [String]
|
82
|
+
# @param collateralCoin [String]
|
83
|
+
# @param adjustmentAmount [Float]
|
84
|
+
# @param direction [String] ADDITIONAL or REDUCED
|
85
|
+
# @param kwargs [Hash]
|
86
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
87
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/trade/Flexible-Loan-Adjust-LTV
|
88
|
+
def adjust_flexible_loan_ltv(loanCoin:, collateralCoin:, adjustmentAmount:, direction:, **kwargs)
|
89
|
+
Binance::Utils::Validation.require_param('loanCoin', loanCoin)
|
90
|
+
Binance::Utils::Validation.require_param('collateralCoin', collateralCoin)
|
91
|
+
Binance::Utils::Validation.require_param('adjustmentAmount', adjustmentAmount)
|
92
|
+
Binance::Utils::Validation.require_param('direction', direction)
|
93
|
+
|
94
|
+
@session.sign_request(:post, '/sapi/v2/loan/flexible/adjust/ltv', params: kwargs.merge(
|
95
|
+
loanCoin: loanCoin,
|
96
|
+
collateralCoin: collateralCoin,
|
97
|
+
adjustmentAmount: adjustmentAmount,
|
98
|
+
direction: direction
|
99
|
+
))
|
100
|
+
end
|
101
|
+
|
102
|
+
# Get Flexible Loan LTV Adjustment History (USER_DATA)
|
103
|
+
#
|
104
|
+
# GET /sapi/v2/loan/flexible/ltv/adjustment/history
|
105
|
+
#
|
106
|
+
# @param kwargs [Hash]
|
107
|
+
# @option kwargs [String] :loanCoin
|
108
|
+
# @option kwargs [String] :collateralCoin
|
109
|
+
# @option kwargs [Integer] :startTime
|
110
|
+
# @option kwargs [Integer] :endTime
|
111
|
+
# @option kwargs [Integer] :current Current querying page. Start from 1; default: 1; max: 1000
|
112
|
+
# @option kwargs [Integer] :limit Default: 10; max: 100
|
113
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
114
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information
|
115
|
+
def get_flexible_loan_ltv_adjustment_history(**kwargs)
|
116
|
+
@session.sign_request(:get, '/sapi/v2/loan/flexible/ltv/adjustment/history', params: kwargs)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Get Flexible Loan Borrow History(USER_DATA)
|
120
|
+
#
|
121
|
+
# GET /sapi/v2/loan/flexible/borrow/history
|
122
|
+
#
|
123
|
+
# @param kwargs [Hash]
|
124
|
+
# @option kwargs [String] :loanCoin
|
125
|
+
# @option kwargs [String] :collateralCoin
|
126
|
+
# @option kwargs [Integer] :startTime
|
127
|
+
# @option kwargs [Integer] :endTime
|
128
|
+
# @option kwargs [Integer] :current Current querying page. Start from 1; default: 1; max: 1000
|
129
|
+
# @option kwargs [Integer] :limit Default: 10; max: 100
|
130
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
131
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Borrow-History
|
132
|
+
def get_flexible_loan_borrow_history(**kwargs)
|
133
|
+
@session.sign_request(:get, '/sapi/v2/loan/flexible/borrow/history', params: kwargs)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Get Flexible Loan Ongoing Orders (USER_DATA)
|
137
|
+
#
|
138
|
+
# GET /sapi/v2/loan/flexible/ongoing/orders
|
139
|
+
#
|
140
|
+
# @param kwargs [Hash]
|
141
|
+
# @option kwargs [String] :loanCoin
|
142
|
+
# @option kwargs [String] :collateralCoin
|
143
|
+
# @option kwargs [Integer] :current Current querying page. Start from 1; default: 1; max: 1000
|
144
|
+
# @option kwargs [Integer] :limit Default: 10; max: 100
|
145
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
146
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Ongoing-Orders
|
147
|
+
def get_flexible_loan_ongoing_orders(**kwargs)
|
148
|
+
@session.sign_request(:get, '/sapi/v2/loan/flexible/ongoing/orders', params: kwargs)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Get Flexible Loan Repayment History (USER_DATA)
|
152
|
+
#
|
153
|
+
# GET /sapi/v2/loan/flexible/repay/history
|
154
|
+
#
|
155
|
+
# @param kwargs [Hash]
|
156
|
+
# @option kwargs [String] :loanCoin
|
157
|
+
# @option kwargs [String] :collateralCoin
|
158
|
+
# @option kwargs [Integer] :startTime
|
159
|
+
# @option kwargs [Integer] :endTime
|
160
|
+
# @option kwargs [Integer] :current Current querying page. Start from 1; default: 1; max: 1000
|
161
|
+
# @option kwargs [Integer] :limit Default: 10; max: 100
|
162
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
163
|
+
# @see https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Repayment-History
|
164
|
+
def get_flexible_loan_repayment_history(**kwargs)
|
165
|
+
@session.sign_request(:get, '/sapi/v2/loan/flexible/repay/history', params: kwargs)
|
166
|
+
end
|
167
|
+
|
8
168
|
# Get Crypto Loans Income History (USER_DATA)
|
9
169
|
#
|
10
170
|
# GET /sapi/v1/loan/income
|
11
171
|
#
|
12
|
-
# @param
|
13
|
-
# @
|
172
|
+
# @param kwargs [Hash]
|
173
|
+
# @param kwargs [String] :asset
|
174
|
+
# @option kwargs [String] :type All types will be returned by default. Enum:borrowIn ,collateralSpent, repayAmount, collateralReturn(Collateral return after repayment), addCollateral
|
175
|
+
# removeCollateral, collateralReturnAfterLiquidation
|
14
176
|
# @option kwargs [Integer] :startTime
|
15
177
|
# @option kwargs [Integer] :endTime
|
16
178
|
# @option kwargs [Integer] :limit default 20, max 100
|
17
179
|
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
18
180
|
# @see https://developers.binance.com/docs/crypto_loan/stable-rate/market-data/Get-Crypto-Loans-Income-History
|
19
|
-
def get_loan_history(
|
20
|
-
|
181
|
+
def get_loan_history(**kwargs)
|
182
|
+
@session.sign_request(:get, '/sapi/v1/loan/income', params: kwargs)
|
183
|
+
end
|
21
184
|
|
22
|
-
|
185
|
+
# Get Loan Borrow History (USER_DATA)
|
186
|
+
#
|
187
|
+
# GET /sapi/v1/loan/borrow/history
|
188
|
+
#
|
189
|
+
# @param kwargs [Hash]
|
190
|
+
# @option kwargs [Integer] :orderId orderId in POST /sapi/v1/loan/borrow
|
191
|
+
# @option kwargs [String] :loanCoin
|
192
|
+
# @option kwargs [String] :collateralCoin
|
193
|
+
# @option kwargs [Integer] :startTime
|
194
|
+
# @option kwargs [Integer] :endTime
|
195
|
+
# @option kwargs [Integer] :current Current querying page. Start from 1; default: 1; max: 1000
|
196
|
+
# @option kwargs [Integer] :limit Default: 10; max: 100
|
197
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
198
|
+
# @see https://developers.binance.com/docs/crypto_loan/stable-rate/user-information
|
199
|
+
def get_loan_borrow_history(**kwargs)
|
200
|
+
@session.sign_request(:get, '/sapi/v1/loan/borrow/history', params: kwargs)
|
201
|
+
end
|
202
|
+
|
203
|
+
# Get Loan LTV Adjustment History (USER_DATA)
|
204
|
+
#
|
205
|
+
# GET /sapi/v1/loan/ltv/adjustment/history
|
206
|
+
#
|
207
|
+
# @param kwargs [Hash]
|
208
|
+
# @option kwargs [Integer] :orderId
|
209
|
+
# @option kwargs [String] :loanCoin
|
210
|
+
# @option kwargs [String] :collateralCoin
|
211
|
+
# @option kwargs [Integer] :startTime
|
212
|
+
# @option kwargs [Integer] :endTime
|
213
|
+
# @option kwargs [Integer] :current Current querying page. Start from 1; default: 1; max: 1000
|
214
|
+
# @option kwargs [Integer] :limit Default: 10; max: 100
|
215
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
216
|
+
# @see https://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-LTV-Adjustment-History
|
217
|
+
def get_loan_ltv_adjustment_history(**kwargs)
|
218
|
+
@session.sign_request(:get, '/sapi/v1/loan/ltv/adjustment/history', params: kwargs)
|
219
|
+
end
|
220
|
+
|
221
|
+
# Get Loan Repayment History (USER_DATA)
|
222
|
+
#
|
223
|
+
# GET /sapi/v1/loan/repay/history
|
224
|
+
#
|
225
|
+
# @param kwargs [Hash]
|
226
|
+
# @option kwargs [Integer] :orderId
|
227
|
+
# @option kwargs [String] :loanCoin
|
228
|
+
# @option kwargs [String] :collateralCoin
|
229
|
+
# @option kwargs [Integer] :startTime
|
230
|
+
# @option kwargs [Integer] :endTime
|
231
|
+
# @option kwargs [Integer] :current Current querying page. Start from 1; default: 1; max: 1000
|
232
|
+
# @option kwargs [Integer] :limit Default: 10; max: 100
|
233
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
234
|
+
# @see https://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-Repayment-History
|
235
|
+
def get_loan_repayment_history(**kwargs)
|
236
|
+
@session.sign_request(:get, '/sapi/v1/loan/repay/history', params: kwargs)
|
23
237
|
end
|
24
238
|
end
|
25
239
|
end
|
data/lib/binance/spot/margin.rb
CHANGED
@@ -33,6 +33,27 @@ module Binance
|
|
33
33
|
@session.limit_request(path: '/sapi/v1/margin/priceIndex', params: { symbol: symbol })
|
34
34
|
end
|
35
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
|
+
|
36
57
|
# Margin Account New Order (TRADE)
|
37
58
|
#
|
38
59
|
# POST /sapi/v1/margin/order
|
@@ -138,6 +159,55 @@ module Binance
|
|
138
159
|
@session.sign_request(:get, '/sapi/v1/margin/interestHistory', params: kwargs)
|
139
160
|
end
|
140
161
|
|
162
|
+
# Margin account borrow/repay (MARGIN)
|
163
|
+
#
|
164
|
+
# POST /sapi/v1/margin/borrow-repay
|
165
|
+
#
|
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
|
171
|
+
# @param kwargs [Hash]
|
172
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
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)
|
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)
|
180
|
+
|
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
|
+
))
|
188
|
+
end
|
189
|
+
|
190
|
+
# Query borrow/repay records in Margin account (USER_DATA)
|
191
|
+
#
|
192
|
+
# GET /sapi/v1/margin/borrow-repay
|
193
|
+
#
|
194
|
+
# @param type [String] BORROW or REPAY
|
195
|
+
# @param kwargs [Hash]
|
196
|
+
# @option kwargs [String] :asset
|
197
|
+
# @option kwargs [String] :isIsolated
|
198
|
+
# @option kwargs [String] :txId
|
199
|
+
# @option kwargs [Integer] :startTime
|
200
|
+
# @option kwargs [Integer] :endTime
|
201
|
+
# @option kwargs [Integer] :current Currently querying page. Start from 1. Default:1
|
202
|
+
# @option kwargs [Integer] :size Default:10 Max:100
|
203
|
+
# @option kwargs [Integer] :recvWindow The value cannot be greater than 60000
|
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))
|
209
|
+
end
|
210
|
+
|
141
211
|
# Get Force Liquidation Record (USER_DATA)
|
142
212
|
#
|
143
213
|
# GET /sapi/v1/margin/forceLiquidationRec
|
@@ -337,6 +407,21 @@ module Binance
|
|
337
407
|
@session.sign_request(:get, '/sapi/v1/margin/myTrades', params: kwargs.merge(symbol: symbol))
|
338
408
|
end
|
339
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
|
+
|
340
425
|
# Query Max Borrow (USER_DATA)
|
341
426
|
#
|
342
427
|
# GET /sapi/v1/margin/maxBorrowable
|