Skip to content

Commit 925fe11

Browse files
authored
1.18.0 release (#173)
1 parent 328c1ec commit 925fe11

26 files changed

+688
-23
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
## 1.18.0 - 2022-09-29
4+
5+
### Added
6+
- New endpoints for Crypto Loan:
7+
- `POST /sapi/v1/loan/borrow` - Crypto Loan Borrow
8+
- `GET /sapi/v1/loan/borrow/history` - Get Loan Borrow History
9+
- `GET/sapi/v1/loan/ongoing/orders` - Get Loan Ongoing Orders
10+
- `POST/sapi/v1/loan/repay` - Crypto Loan Repay
11+
- `GET/sapi/v1/loan/repay/history` - Get Loan Repayment History
12+
- `POST/sapi/v1/loan/adjust/ltv` - Crypto Loan Adjust LTV
13+
- `GET/sapi/v1/loan/ltv/adjustment/history` - Get Loan LTV Adjustment History
14+
15+
### Changed
16+
- Changes to `GET /api/v3/exchangeInfo`:
17+
- New optional parameter `permissions` added to display all symbols with the permissions matching the parameter provided. (eg.SPOT, MARGIN, LEVERAGED)
18+
- If not provided, the default value will be `["SPOT","MARGIN", "LEVERAGED"]`
19+
- Cannot be combined with symbol or symbols
20+
321
## 1.17.0 - 2022-09-05
422

523
### Added

binance/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.17.0"
1+
__version__ = "1.18.0"

binance/spot/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ def __init__(self, key=None, secret=None, **kwargs):
250250

251251
# CRYPTO LOANS
252252
from binance.spot.loan import loan_history
253+
from binance.spot.loan import loan_borrow
254+
from binance.spot.loan import loan_borrow_history
255+
from binance.spot.loan import loan_ongoing_orders
256+
from binance.spot.loan import loan_repay
257+
from binance.spot.loan import loan_repay_history
258+
from binance.spot.loan import loan_adjust_ltv
259+
from binance.spot.loan import loan_adjust_ltv_history
253260

254261
# PAY
255262
from binance.spot.pay import pay_history

binance/spot/loan.py

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from binance.lib.utils import check_required_parameter
1+
from binance.lib.utils import check_required_parameters, check_required_parameter
22

33

44
def loan_history(self, asset: str, **kwargs):
@@ -24,3 +24,164 @@ def loan_history(self, asset: str, **kwargs):
2424

2525
payload = {"asset": asset, **kwargs}
2626
return self.sign_request("GET", "/sapi/v1/loan/income", payload)
27+
28+
29+
def loan_borrow(self, loanCoin: str, collateralCoin: str, loanTerm: int, **kwargs):
30+
"""Crypto Loan Borrow (TRADE)
31+
32+
POST /sapi/v1/loan/borrow
33+
34+
https://binance-docs.github.io/apidocs/spot/en/#borrow-crypto-loan-borrow-trade
35+
36+
Args:
37+
loanCoin (str)
38+
collateralCoin (str)
39+
loanTerm (int): 7/14/30/90/180 days
40+
Keyword Args:
41+
loanAmount (float, optional): Mandatory when collateralAmount is empty
42+
collateralAmount (float, optional): Mandatory when loanAmount is empty
43+
recvWindow (int, optional): The value cannot be greater than 60000
44+
"""
45+
46+
check_required_parameters(
47+
[
48+
[loanCoin, "loanCoin"],
49+
[collateralCoin, "collateralCoin"],
50+
[loanTerm, "loanTerm"],
51+
]
52+
)
53+
54+
payload = {
55+
"loanCoin": loanCoin,
56+
"collateralCoin": collateralCoin,
57+
"loanTerm": loanTerm,
58+
**kwargs,
59+
}
60+
return self.sign_request("POST", "/sapi/v1/loan/borrow", payload)
61+
62+
63+
def loan_borrow_history(self, **kwargs):
64+
"""Get Loan Borrow History (USER_DATA)
65+
66+
GET /sapi/v1/loan/borrow/history
67+
68+
https://binance-docs.github.io/apidocs/spot/en/#borrow-get-loan-borrow-history-user_data
69+
70+
Keyword Args:
71+
orderId (int, optional): orderId in POST /sapi/v1/loan/borrow
72+
loanCoin (str, optional)
73+
collateralCoin (str, optional)
74+
startTime (int, optional)
75+
endTime (int, optional)
76+
current (int, optional): Current querying page. Start from 1; default: 1; max: 1000.
77+
limit (int, optional): Default: 10; max: 100
78+
recvWindow (int, optional): The value cannot be greater than 60000
79+
"""
80+
81+
return self.sign_request("GET", "/sapi/v1/loan/borrow/history", kwargs)
82+
83+
84+
def loan_ongoing_orders(self, **kwargs):
85+
"""Get Loan Ongoing Orders (USER_DATA)
86+
87+
GET /sapi/v1/loan/ongoing/orders
88+
89+
https://binance-docs.github.io/apidocs/spot/en/#borrow-get-loan-ongoing-orders-user_data
90+
91+
Keyword Args:
92+
orderId (int, optional): orderId in POST /sapi/v1/loan/borrow
93+
loanCoin (str, optional)
94+
collateralCoin (str, optional)
95+
current (int, optional): Current querying page. Start from 1; default: 1; max: 1000
96+
limit (int, optional): Default: 10; max: 100
97+
recvWindow (int, optional): The value cannot be greater than 60000
98+
"""
99+
100+
return self.sign_request("GET", "/sapi/v1/loan/ongoing/orders", kwargs)
101+
102+
103+
def loan_repay(self, orderId: int, amount: float, **kwargs):
104+
"""Crypto Loan Repay (TRADE)
105+
106+
POST /sapi/v1/loan/repay
107+
108+
https://binance-docs.github.io/apidocs/spot/en/#repay-crypto-loan-repay-trade
109+
110+
Args:
111+
orderId (int)
112+
amount (float)
113+
Keyword Args:
114+
type (int, optional): Default: 1. 1 for "repay with borrowed coin"; 2 for "repay with collateral"
115+
collateralReturn (boolean, optional): Default: TRUE. TRUE: Return extra collateral to spot account; FALSE: Keep extra collateral in the order.
116+
recvWindow (int, optional): The value cannot be greater than 60000
117+
"""
118+
119+
check_required_parameters([[orderId, "orderId"], [amount, "amount"]])
120+
121+
payload = {"orderId": orderId, "amount": amount, **kwargs}
122+
return self.sign_request("POST", "/sapi/v1/loan/repay", payload)
123+
124+
125+
def loan_repay_history(self, **kwargs):
126+
"""Get Loan Repayment History (USER_DATA)
127+
128+
GET /sapi/v1/loan/repay/history
129+
130+
https://binance-docs.github.io/apidocs/spot/en/#repay-get-loan-repayment-history-user_data
131+
132+
Keyword Args:
133+
orderId (int, optional)
134+
loanCoin (str, optional)
135+
collateralCoin (str, optional)
136+
startTime (int, optional)
137+
endTime (int, optional)
138+
current (int, optional): Current querying page. Start from 1; default: 1; max: 1000.
139+
limit (int, optional): Default: 10; max: 100
140+
recvWindow (int, optional): The value cannot be greater than 60000
141+
"""
142+
143+
return self.sign_request("GET", "/sapi/v1/loan/repay/history", kwargs)
144+
145+
146+
def loan_adjust_ltv(self, orderId: int, amount: float, direction: str, **kwargs):
147+
"""Crypto Loan Adjust LTV (TRADE)
148+
149+
POST /sapi/v1/loan/adjust/ltv
150+
151+
https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-crypto-loan-adjust-ltv-trade
152+
153+
Args:
154+
orderId (int)
155+
amount (float)
156+
direction (str): "ADDITIONAL", "REDUCED"
157+
Keyword Args:
158+
recvWindow (int, optional): The value cannot be greater than 60000
159+
"""
160+
161+
check_required_parameters(
162+
[[orderId, "orderId"], [amount, "amount"], [direction, "direction"]]
163+
)
164+
165+
payload = {"orderId": orderId, "amount": amount, "direction": direction, **kwargs}
166+
return self.sign_request("POST", "/sapi/v1/loan/adjust/ltv", payload)
167+
168+
169+
def loan_adjust_ltv_history(self, **kwargs):
170+
"""Get Loan LTV Adjustment History (USER_DATA)
171+
172+
GET /sapi/v1/loan/ltv/adjustment/history
173+
174+
https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-get-loan-ltv-adjustment-history-user_data
175+
176+
Keyword Args:
177+
orderId (int, optional)
178+
loanCoin (str, optional)
179+
collateralCoin (str, optional)
180+
startTime (int, optional)
181+
endTime (int, optional)
182+
current (int, optional): Current querying page. Start from 1; default: 1; max: 1000
183+
limit (int, optional): Default: 10; max: 100
184+
recvWindow (int, optional): The value cannot be greater than 60000
185+
"""
186+
187+
return self.sign_request("GET", "/sapi/v1/loan/ltv/adjustment/history", kwargs)

binance/spot/market.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def time(self):
3535
return self.query(url_path)
3636

3737

38-
def exchange_info(self, symbol: str = None, symbols: list = None):
38+
def exchange_info(
39+
self, symbol: str = None, symbols: list = None, permissions: list = None
40+
):
3941
"""Exchange Information
4042
Current exchange trading rules and symbol information
4143
@@ -46,13 +48,24 @@ def exchange_info(self, symbol: str = None, symbols: list = None):
4648
Args:
4749
symbol (str, optional): the trading pair
4850
symbols (list, optional): list of trading pairs
51+
permissions (list, optional): display all symbols with the permissions matching the parameter provided (eg.SPOT, MARGIN, LEVERAGED)
4952
"""
5053

5154
url_path = "/api/v3/exchangeInfo"
5255
if symbol and symbols:
5356
raise ParameterArgumentError("symbol and symbols cannot be sent together.")
57+
if symbol and permissions or symbols and permissions:
58+
raise ParameterArgumentError(
59+
"permissions cannot be sent together with symbol or symbols"
60+
)
5461
check_type_parameter(symbols, "symbols", list)
55-
params = {"symbol": symbol, "symbols": convert_list_to_json_array(symbols)}
62+
check_type_parameter(permissions, "permissions", list)
63+
64+
params = {
65+
"symbol": symbol,
66+
"symbols": convert_list_to_json_array(symbols),
67+
"permissions": convert_list_to_json_array(permissions),
68+
}
5669
return self.query(url_path, params)
5770

5871

binance/spot/savings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def savings_project_list(self, type: str, **kwargs):
130130
Keyword Args:
131131
asset (str, optional)
132132
status (str, optional): "ALL", "SUBSCRIBABLE", "UNSUBSCRIBABLE"; default "ALL"
133-
isSortAsc (bool, optional): default "true"
133+
isSortAsc (bool, optional): By default, it's True
134134
sortBy (str, optional): "START_TIME", "LOT_SIZE", "INTEREST_RATE", "DURATION"; default "START_TIME"
135135
current (int, optional): Currently querying page. Start from 1. Default:1
136136
size (int, optional): Default:10, Max:100

binance/spot/sub_account.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def sub_account_enable_leverage_token(self, email: str, enableBlvt: bool, **kwar
590590
591591
Args:
592592
email (str): Sub-account email
593-
enableBlvt (bool): Only true for now
593+
enableBlvt (bool): Only True for now
594594
Keyword Args:
595595
recvWindow (int, optional): The value cannot be greater than 60000
596596
"""
@@ -688,6 +688,7 @@ def sub_account_api_toggle_ip_restriction(
688688
subAccountApiKey (str)
689689
ipRestrict (bool): True or False
690690
Keyword Args:
691+
thirdParty (bool, optional): False by default
691692
recvWindow (int, optional)
692693
"""
693694

@@ -726,6 +727,7 @@ def sub_account_api_add_ip(
726727
subAccountApiKey (str)
727728
ipAddress (str): Can be added in batches, separated by commas
728729
Keyword Args:
730+
thirdPartyName (str, optional)
729731
recvWindow (int, optional)
730732
"""
731733

@@ -791,6 +793,7 @@ def sub_account_api_delete_ip(
791793
subAccountApiKey (str)
792794
ipAddress (str): Can be added in batches, separated by commas
793795
Keyword Args:
796+
thirdPartyName (str, optional)
794797
recvWindow (int, optional)
795798
"""
796799

binance/spot/wallet.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def withdraw(self, coin: str, amount: float, address: str, **kwargs):
103103
withdrawOrderId (str, optional): Client id for withdraw
104104
network (str, optional)
105105
addressTag (str, optional): Secondary address identifier for coins like XRP,XMR etc.
106-
transactionFeeFlag (bool, optional): When making internal transfer, true for returning the fee to the destination account; false for returning the fee back to the departure account. Default false.
106+
transactionFeeFlag (bool, optional): When making internal transfer, True for returning the fee to the destination account; False for returning the fee back to the departure account. Default False.
107107
name (str, optional): Description of the address. Space in name should be encoded into %20.
108108
walletType (int, optional): The wallet type for withdraw,0-spot wallet,1-funding wallet. Default is spot wallet
109109
recvWindow (int, optional): The value cannot be greater than 60000
@@ -225,11 +225,11 @@ def dust_log(self, **kwargs):
225225

226226

227227
def user_universal_transfer(self, type: str, asset: str, amount: str, **kwargs):
228-
"""User Universal Transfer
228+
"""User Universal Transfer (USER_DATA)
229229
230230
POST /sapi/v1/asset/transfer
231231
232-
https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer
232+
https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer-user_data
233233
234234
Args:
235235
type (str)
@@ -247,11 +247,11 @@ def user_universal_transfer(self, type: str, asset: str, amount: str, **kwargs):
247247

248248

249249
def user_universal_transfer_history(self, type: str, **kwargs):
250-
"""Query User Universal Transfer History
250+
"""Query User Universal Transfer History (USER_DATA)
251251
252252
GET /sapi/v1/asset/transfer
253253
254-
https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history
254+
https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history-user_data
255255
256256
Args:
257257
type (str)

0 commit comments

Comments
 (0)