Skip to content

Commit e16c0fd

Browse files
committed
Release v3.7.0
1 parent 36d05c4 commit e16c0fd

35 files changed

+1081
-32
lines changed

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
# Changelog
22

33
## 3.7.0 - 2024-05-03
4+
### Added
5+
- Convert
6+
- `POST /sapi/v1/convert/limit/placeOrder`
7+
- `POST /sapi/v1/convert/limit/cancelOrder`
8+
- `GET /sapi/v1/convert/limit/queryOpenOrders`
9+
10+
- Margin
11+
- `GET /sapi/v1/margin/available-inventory`
12+
- `POST /sapi/v1/margin/manual-liquidation`
13+
- `GET /sapi/v1/margin/leverageBracket`
14+
15+
- Market
16+
- `GET /api/v3/ticker/tradingDay`
17+
18+
- Trade
19+
- `GET /api/v3/myAllocations`
20+
- `GET /api/v3/account/commission`
21+
22+
- Wallet
23+
- `GET /sapi/v1/capital/deposit/address/list`
24+
- `GET /sapi/v1/spot/delist-schedule`
25+
26+
### Updated
27+
- `POST /sapi/v1/asset/dust-btc` add parameter `accountType`
28+
- `POST /sapi/v1/asset/dust` add parameter `accountType`
29+
- `GET /sapi/v1/asset/dribblet` add parameter `accountType`
30+
- `POST /sapi/v1/margin/order/oco`: New enumerate value `AUTO_BORROW_REPAY` for the field of `sideEffectType`
31+
- `POST /sapi/v1/margin/order`: New enumerate value `AUTO_BORROW_REPAY` for the field of `sideEffectType`
32+
- Update documentation
33+
- Add new handle exception in websocket read_data
34+
435
### Removed
536
- Bswap
637
- `GET /sapi/v1/bswap/pools`

binance/spot/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
1919
from binance.spot._market import ui_klines
2020
from binance.spot._market import avg_price
2121
from binance.spot._market import ticker_24hr
22+
from binance.spot._market import trading_day_ticker
2223
from binance.spot._market import ticker_price
2324
from binance.spot._market import book_ticker
2425
from binance.spot._market import rolling_window_ticker
@@ -41,6 +42,8 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
4142
from binance.spot._trade import my_trades
4243
from binance.spot._trade import get_order_rate_limit
4344
from binance.spot._trade import query_prevented_matches
45+
from binance.spot._trade import query_allocations
46+
from binance.spot._trade import query_commission_rates
4447

4548
# STREAMS
4649
from binance.spot._data_stream import new_listen_key
@@ -95,6 +98,9 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
9598
from binance.spot._margin import get_small_liability_exchange_history
9699
from binance.spot._margin import get_a_future_hourly_interest_rate
97100
from binance.spot._margin import adjust_cross_margin_max_leverage
101+
from binance.spot._margin import margin_available_inventory
102+
from binance.spot._margin import margin_manual_liquidation
103+
from binance.spot._margin import liability_coin_leverage_bracket
98104

99105
# WALLET
100106
from binance.spot._wallet import system_status
@@ -121,11 +127,13 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
121127
from binance.spot._wallet import bnb_convertible_assets
122128
from binance.spot._wallet import convertible_coins
123129
from binance.spot._wallet import toggle_auto_convertion
130+
from binance.spot._wallet import list_deposit_address
124131
from binance.spot._wallet import cloud_mining_trans_history
125132
from binance.spot._wallet import convert_transfer
126133
from binance.spot._wallet import convert_history
127134
from binance.spot._wallet import one_click_arrival_deposit_apply
128135
from binance.spot._wallet import balance
136+
from binance.spot._wallet import delist_schedule_symbols
129137

130138
# MINING
131139
from binance.spot._mining import mining_algo_list
@@ -237,6 +245,9 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
237245
from binance.spot._convert import send_quote_request
238246
from binance.spot._convert import accept_quote
239247
from binance.spot._convert import order_status
248+
from binance.spot._convert import place_limit_order
249+
from binance.spot._convert import cancel_limit_order
250+
from binance.spot._convert import query_limit_open_order
240251
from binance.spot._convert import get_convert_trade_history
241252

242253
# REBATE

binance/spot/_convert.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,88 @@ def order_status(self, **kwargs):
115115
return self.sign_request("GET", url_path, {**kwargs})
116116

117117

118+
def place_limit_order(
119+
self,
120+
baseAsset: str,
121+
quoteAsset: str,
122+
limitPrice: float,
123+
side: str,
124+
expiredType: str,
125+
**kwargs
126+
):
127+
"""Place limit order (USER_DATA)
128+
129+
POST /sapi/v1/convert/limit/placeOrder
130+
131+
https://binance-docs.github.io/apidocs/spot/en/#place-limit-order-user_data
132+
133+
Args:
134+
baseAsset (str): base asset (use the response fromIsBase from GET /sapi/v1/convert/exchangeInfo api to check which one is baseAsset)
135+
quoteAsset (str): quote asset
136+
limitPrice (float): Symbol limit price (from baseAsset to quoteAsset)
137+
side (str): BUY or SELL
138+
expiredType (str): 1_D, 3_D, 7_D, 30_D (D means day)
139+
Keyword Args:
140+
baseAmount (float, optional): Base asset amount. (One of baseAmount or quoteAmount is required)
141+
quotrAmount (float, optional): Quote asset amount. (One of baseAmount or quoteAmount is required)
142+
walletType (str, optional): SPOT or FUNDING or SPOT_FUNDING. It is to use which type of assets. Default is SPOT.
143+
recvWindow (int, optional): The value cannot be greater than 60000
144+
"""
145+
check_required_parameters(
146+
[
147+
[baseAsset, "baseAsset"],
148+
[quoteAsset, "quoteAsset"],
149+
[limitPrice, "limitPrice"],
150+
[side, "side"],
151+
[expiredType, "expiredType"],
152+
]
153+
)
154+
155+
params = {
156+
"baseAsset": baseAsset,
157+
"quoteAsset": quoteAsset,
158+
"limitPrice": limitPrice,
159+
"side": side,
160+
"expiredType": expiredType,
161+
**kwargs,
162+
}
163+
url_path = "/sapi/v1/convert/limit/placeOrder"
164+
return self.sign_request("POST", url_path, params)
165+
166+
167+
def cancel_limit_order(self, orderId: str, **kwargs):
168+
"""Cancel limit order (USER_DATA)
169+
170+
POST /sapi/v1/convert/limit/cancelOrder
171+
172+
https://binance-docs.github.io/apidocs/spot/en/#cancel-limit-order-user_data
173+
174+
Args:
175+
orderId (str): The orderId from placeOrder api
176+
Keyword Args:
177+
recvWindow (int, optional): The value cannot be greater than 60000
178+
"""
179+
check_required_parameter(orderId, "orderId")
180+
181+
params = {"orderId": orderId, **kwargs}
182+
url_path = "/sapi/v1/convert/limit/cancelOrder"
183+
return self.sign_request("POST", url_path, params)
184+
185+
186+
def query_limit_open_order(self, **kwargs):
187+
"""Query limit open orders (USER_DATA)
188+
189+
GET /sapi/v1/convert/limit/queryOpenOrders
190+
191+
https://binance-docs.github.io/apidocs/spot/en/#query-limit-open-orders-user_data
192+
193+
Keyword Args:
194+
recvWindow (int, optional): The value cannot be greater than 60000
195+
"""
196+
url_path = "/sapi/v1/convert/limit/queryOpenOrders"
197+
return self.sign_request("GET", url_path, {**kwargs})
198+
199+
118200
def get_convert_trade_history(self, startTime: int, endTime: int, **kwargs):
119201
"""Get Convert Trade History (USER_DATA)
120202

binance/spot/_margin.py

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def new_margin_order(self, symbol: str, side: str, type: str, **kwargs):
112112
icebergQty (float, optional): Used with LIMIT, STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT to create an iceberg order.
113113
newOrderRespType (str, optional): Set the response JSON. ACK, RESULT or FULL;
114114
MARKET and LIMIT order types default to FULL, all other orders default to ACK.
115-
sideEffectType (str, optional): NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT.
115+
sideEffectType (str, optional): NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY,AUTO_BORROW_REPAY; default NO_SIDE_EFFECT.
116116
timeInForce (str, optional): GTC,IOC,FOK
117-
isIsolated (str, optional): for isolated margin or not,"TRUE", "FALSE"default "FALSE".
117+
isIsolated (str, optional): for isolated margin or not,"TRUE", "FALSE" default "FALSE".
118118
recvWindow (int, optional): The value cannot be greater than 60000
119119
"""
120120

@@ -512,7 +512,7 @@ def new_margin_oco_order(
512512
stopIcebergQty (float, optional)
513513
stopLimitTimeInForce (str, optional): Valid values are GTC/FOK/IOC
514514
newOrderRespType (str, optional): Set the response JSON
515-
sideEffectType (str, optional): NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY; default NO_SIDE_EFFECT
515+
sideEffectType (str, optional): NO_SIDE_EFFECT, MARGIN_BUY, AUTO_REPAY,AUTO_BORROW_REPAY; default NO_SIDE_EFFECT
516516
recvWindow (int, optional): The value cannot be greater than 60000
517517
"""
518518

@@ -630,7 +630,7 @@ def get_margin_open_oco_orders(self, **kwargs):
630630
https://binance-docs.github.io/apidocs/spot/en/#query-margin-account-39-s-open-oco-user_data
631631
632632
Keyword Args:
633-
isIsolated (str, optional): For isolated margin or not "TRUE", "FALSE"default "FALSE"
633+
isIsolated (str, optional): For isolated margin or not "TRUE", "FALSE" default "FALSE"
634634
symbol (str, optional): Mandatory for isolated margin, not supported for cross margin
635635
recvWindow (int, optional): The value cannot be greater than 60000
636636
"""
@@ -881,3 +881,51 @@ def adjust_cross_margin_max_leverage(self, maxLeverage: int, **kwargs):
881881
params = {"maxLeverage": maxLeverage, **kwargs}
882882
url_path = "/sapi/v1/margin/max-leverage"
883883
return self.sign_request("POST", url_path, params)
884+
885+
886+
def margin_available_inventory(self, type: str, **kwargs):
887+
"""Query Margin Available Inventory (USER_DATA)
888+
889+
GET /sapi/v1/margin/available-inventory
890+
891+
https://binance-docs.github.io/apidocs/spot/en/#query-margin-available-inventory-user_data
892+
893+
Args:
894+
type (str): "MARGIN", "ISOLATED"
895+
Keyword Args:
896+
recvWindow (int, optional): The value cannot be greater than 60000
897+
"""
898+
check_required_parameter(type, "type")
899+
payload = {"type": type, **kwargs}
900+
return self.sign_request("GET", "/sapi/v1/margin/available-inventory", payload)
901+
902+
903+
def margin_manual_liquidation(self, type: str, **kwargs):
904+
"""Margin manual liquidation(MARGIN)
905+
906+
POST /sapi/v1/margin/manual-liquidation
907+
908+
https://binance-docs.github.io/apidocs/spot/en/#margin-manual-liquidation-margin
909+
910+
Args:
911+
type (str): "MARGIN", "ISOLATED"
912+
Keyword Args:
913+
symbol (str, optional): When type selects ISOLATED, symbol must be filled in
914+
recvWindow (int, optional): The value cannot be greater than 60000
915+
"""
916+
check_required_parameters([[type, "type"]])
917+
payload = {"type": type, **kwargs}
918+
return self.sign_request("POST", "/sapi/v1/margin/manual-liquidation", payload)
919+
920+
921+
def liability_coin_leverage_bracket(self, **kwargs):
922+
"""Query Liability Coin Leverage Bracket in Cross Margin Pro Mode(MARKET_DATA)
923+
924+
GET /sapi/v1/margin/leverageBracket
925+
926+
https://binance-docs.github.io/apidocs/spot/en/#query-liability-coin-leverage-bracket-in-cross-margin-pro-mode-market_data
927+
928+
Keyword Args:
929+
recvWindow (int, optional): The value cannot be greater than 60000
930+
"""
931+
return self.sign_request("GET", "/sapi/v1/margin/leverageBracket", kwargs)

binance/spot/_market.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,28 @@ def ticker_24hr(self, symbol: str = None, symbols: list = None, **kwargs):
228228
return self.query("/api/v3/ticker/24hr", params)
229229

230230

231+
def trading_day_ticker(self, symbol: str = None, symbols: list = None):
232+
"""Trading Day Ticker
233+
234+
GET /api/v3/ticker/tradingDay
235+
236+
https://binance-docs.github.io/apidocs/spot/en/#trading-day-ticker
237+
238+
Args:
239+
symbol (str, optional): Either symbol or symbols must be provided
240+
symbols (list, optional): list of trading pairs
241+
Keyword Args:
242+
timeZone (str, optional): Default: 0 (UTC)
243+
type (str, optional): Supported values: FULL or MINI. If none provided, the default is FULL.
244+
"""
245+
if symbol and symbols:
246+
raise ParameterArgumentError("symbol and symbols cannot be sent together.")
247+
248+
check_type_parameter(symbols, "symbols", list)
249+
params = {"symbol": symbol, "symbols": convert_list_to_json_array(symbols)}
250+
return self.query("/api/v3/ticker/tradingDay", params)
251+
252+
231253
def ticker_price(self, symbol: str = None, symbols: list = None):
232254
"""Symbol Price Ticker
233255

binance/spot/_trade.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def get_order_rate_limit(self, **kwargs):
442442

443443

444444
def query_prevented_matches(self, symbol: str, **kwargs):
445-
"""Query Prevented Matches
445+
"""Query Prevented Matches (USER_DATA)
446446
447447
Displays the list of orders that were expired because of STP.
448448
@@ -480,3 +480,46 @@ def query_prevented_matches(self, symbol: str, **kwargs):
480480
params = {"symbol": symbol, **kwargs}
481481
url_path = "/api/v3/myPreventedMatches"
482482
return self.sign_request("GET", url_path, params)
483+
484+
485+
def query_allocations(self, symbol: str, **kwargs):
486+
"""Query Cross-Collateral Information (USER_DATA)
487+
488+
GET /api/v3/myAllocations
489+
490+
https://binance-docs.github.io/apidocs/spot/en/#query-allocations-user_data
491+
492+
Args:
493+
symbol (str)
494+
Keyword Args:
495+
startTime (int, optional)
496+
endTime (int, optional)
497+
fromAllocationId (int, optional)
498+
limit (int, optional): Default Value: 500; Max Value: 1000
499+
orderId (int, optional)
500+
recvWindow (int, optional): The value cannot be greater than 60000
501+
"""
502+
check_required_parameter(symbol, "symbol")
503+
504+
params = {"symbol": symbol, **kwargs}
505+
url_path = "/api/v3/myAllocations"
506+
return self.sign_request("GET", url_path, params)
507+
508+
509+
def query_commission_rates(self, symbol: str, **kwargs):
510+
"""Query Commission Rates (USER_DATA)
511+
512+
GET /api/v3/account/commission
513+
514+
https://binance-docs.github.io/apidocs/spot/en/#query-commission-rates-user_data
515+
516+
Args:
517+
symbol (str)
518+
Keyword Args:
519+
recvWindow (int, optional): The value cannot be greater than 60000
520+
"""
521+
check_required_parameter(symbol, "symbol")
522+
523+
params = {"symbol": symbol, **kwargs}
524+
url_path = "/api/v3/account/commission"
525+
return self.sign_request("GET", url_path, params)

0 commit comments

Comments
 (0)