Skip to content

Commit f8445f4

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 24969b7 + a6f3048 commit f8445f4

File tree

3 files changed

+55
-16
lines changed

3 files changed

+55
-16
lines changed

Endpoints.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@
617617
client.futures_liquidation_orders(symbol, startTime, endTime, limit)
618618
```
619619
- **GET /fapi/v1/openInterest** (Get present open interest of a specific symbol.)
620-
> :warning: Probably broken, python code below is implemented on v1/openInterest endpoint.
621620
```python
622621
client.futures_open_interest(symbol)
623622
```

binance/client.py

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def get_recent_trades(self, **params) -> Dict:
648648
649649
:param symbol: required
650650
:type symbol: str
651-
:param limit: Default 500; max 500.
651+
:param limit: Default 500; max 1000.
652652
:type limit: int
653653
654654
:returns: API response
@@ -678,7 +678,7 @@ def get_historical_trades(self, **params) -> Dict:
678678
679679
:param symbol: required
680680
:type symbol: str
681-
:param limit: Default 500; max 500.
681+
:param limit: Default 500; max 1000.
682682
:type limit: int
683683
:param fromId: TradeId to fetch from. Default gets most recent trades.
684684
:type fromId: str
@@ -717,7 +717,7 @@ def get_aggregate_trades(self, **params) -> Dict:
717717
:type startTime: int
718718
:param endTime: Timestamp in ms to get aggregate trades until INCLUSIVE.
719719
:type endTime: int
720-
:param limit: Default 500; max 500.
720+
:param limit: Default 500; max 1000.
721721
:type limit: int
722722
723723
:returns: API response
@@ -834,7 +834,7 @@ def get_klines(self, **params) -> Dict:
834834
:type symbol: str
835835
:param interval: -
836836
:type interval: str
837-
:param limit: - Default 500; max 500.
837+
:param limit: - Default 500; max 1000.
838838
:type limit: int
839839
:param startTime:
840840
:type startTime: int
@@ -1816,7 +1816,7 @@ def get_all_orders(self, **params):
18161816
:type startTime: int
18171817
:param endTime: optional
18181818
:type endTime: int
1819-
:param limit: Default 500; max 500.
1819+
:param limit: Default 500; max 1000.
18201820
:type limit: int
18211821
:param recvWindow: the number of milliseconds the request is valid for
18221822
:type recvWindow: int
@@ -1997,7 +1997,7 @@ def get_my_trades(self, **params):
19971997
:type startTime: int
19981998
:param endTime: optional
19991999
:type endTime: int
2000-
:param limit: Default 500; max 500.
2000+
:param limit: Default 500; max 1000.
20012001
:type limit: int
20022002
:param fromId: TradeId to fetch from. Default gets most recent trades.
20032003
:type fromId: int
@@ -2139,6 +2139,35 @@ def get_account_api_trading_status(self, **params):
21392139
"""
21402140
return self._request_margin_api('get', 'account/apiTradingStatus', True, data=params)
21412141

2142+
def get_account_api_permissions(self, **params):
2143+
"""Fetch api key permissions.
2144+
2145+
https://binance-docs.github.io/apidocs/spot/en/#get-api-key-permission-user_data
2146+
2147+
:param recvWindow: the number of milliseconds the request is valid for
2148+
:type recvWindow: int
2149+
2150+
:returns: API response
2151+
2152+
.. code-block:: python
2153+
2154+
{
2155+
"ipRestrict": false,
2156+
"createTime": 1623840271000,
2157+
"enableWithdrawals": false, // This option allows you to withdraw via API. You must apply the IP Access Restriction filter in order to enable withdrawals
2158+
"enableInternalTransfer": true, // This option authorizes this key to transfer funds between your master account and your sub account instantly
2159+
"permitsUniversalTransfer": true, // Authorizes this key to be used for a dedicated universal transfer API to transfer multiple supported currencies. Each business's own transfer API rights are not affected by this authorization
2160+
"enableVanillaOptions": false, // Authorizes this key to Vanilla options trading
2161+
"enableReading": true,
2162+
"enableFutures": false, // API Key created before your futures account opened does not support futures API service
2163+
"enableMargin": false, // This option can be adjusted after the Cross Margin account transfer is completed
2164+
"enableSpotAndMarginTrading": false, // Spot and margin trading
2165+
"tradingAuthorityExpirationTime": 1628985600000 // Expiration time for spot and margin trading permission
2166+
}
2167+
2168+
"""
2169+
return self._request_margin_api('get', 'account/apiRestrictions', True, data=params)
2170+
21422171
def get_dust_log(self, **params):
21432172
"""Get log of small amounts exchanged for BNB.
21442173
@@ -2493,8 +2522,8 @@ def withdraw(self, **params):
24932522
24942523
"""
24952524
# force a name for the withdrawal if one not set
2496-
if 'asset' in params and 'name' not in params:
2497-
params['name'] = params['asset']
2525+
if 'coin' in params and 'name' not in params:
2526+
params['name'] = params['coin']
24982527
return self._request_margin_api('post', 'capital/withdraw/apply', True, data=params)
24992528

25002529
def get_deposit_history(self, **params):
@@ -6452,6 +6481,13 @@ def options_user_trades(self, **params):
64526481
"""
64536482
return self._request_options_api('get', 'userTrades', signed=True, data=params)
64546483

6484+
def close_connection(self):
6485+
if self.session:
6486+
self.session.close()
6487+
6488+
def __del__(self):
6489+
self.close_connection()
6490+
64556491

64566492
class AsyncClient(BaseClient):
64576493

@@ -6964,6 +7000,10 @@ async def get_account_api_trading_status(self, **params):
69647000
return await self._request_margin_api('get', 'account/apiTradingStatus', True, data=params)
69657001
get_account_api_trading_status.__doc__ = Client.get_account_api_trading_status.__doc__
69667002

7003+
async def get_account_api_permissions(self, **params):
7004+
return await self._request_margin_api('get', 'account/apiRestrictions', True, data=params)
7005+
get_account_api_permissions.__doc__ = Client.get_account_api_permissions.__doc__
7006+
69677007
async def get_dust_log(self, **params):
69687008
return await self._request_margin_api('get', 'asset/dribblet', True, data=params)
69697009
get_dust_log.__doc__ = Client.get_dust_log.__doc__
@@ -6996,8 +7036,8 @@ async def get_asset_details(self, **params):
69967036

69977037
async def withdraw(self, **params):
69987038
# force a name for the withdrawal if one not set
6999-
if 'asset' in params and 'name' not in params:
7000-
params['name'] = params['asset']
7039+
if 'coin' in params and 'name' not in params:
7040+
params['name'] = params['coin']
70017041
return await self._request_margin_api('post', 'capital/withdraw/apply', True, data=params)
70027042
withdraw.__doc__ = Client.withdraw.__doc__
70037043

docs/websockets.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ with `ThreadedWebsocketManager <binance.html#binance.websockets.ThreadedWebsocke
77

88
ThreadedWebsocketManager does not require asyncio programming, while BinanceSocketManager does.
99

10-
ThreadedWebsocketManager function begin with `start_`, e.g `start_ticker_socket` while BinanceSocketManager is simple `ticker_socket`
10+
ThreadedWebsocketManager function begin with `start_`, e.g `start_ticker_socket` while BinanceSocketManager is simply `ticker_socket`.
1111

1212
Multiple socket connections can be made through either manager.
1313

@@ -21,7 +21,7 @@ Websockets are setup to reconnect with a maximum of 5 retries with an exponentia
2121
ThreadedWebsocketManager Websocket Usage
2222
----------------------------------------
2323

24-
Starting sockets on the ThreadedWebsocketManager requires a callback parameter, similar to old implementations of websockets on python-binance
24+
Starting sockets on the ThreadedWebsocketManager requires a callback parameter, similar to the old implementations of websockets on python-binance.
2525

2626
ThreadedWebsocketManager takes similar parameters to the `Client <binance.html#binance.client.Client>`_ class as it
2727
creates an AsyncClient internally.
@@ -30,7 +30,7 @@ For authenticated streams `api_key` and `api_stream` are required.
3030

3131
As these use threads `start()` is required to be called before starting any sockets.
3232

33-
To keep the ThreadedWebsocketManager running using `join()` to join it to the main thread.
33+
To keep the ThreadedWebsocketManager running, use `join()` to join it to the main thread.
3434

3535
.. code:: python
3636
@@ -71,7 +71,7 @@ To keep the ThreadedWebsocketManager running using `join()` to join it to the ma
7171
7272
**Stop Individual Stream**
7373

74-
When starting a stream, a name for that stream will be returned. This can be used to stop that individual stream
74+
When starting a stream, a name for that stream will be returned. This can be used to stop that individual stream.
7575

7676
.. code:: python
7777
@@ -195,7 +195,7 @@ can do this.
195195
Websocket Errors
196196
----------------
197197

198-
If the websocket is disconnected and is unable to reconnect a message is sent to the callback to indicate this. The format is
198+
If the websocket is disconnected and is unable to reconnect, a message is sent to the callback to indicate this. The format is
199199

200200
.. code:: python
201201

0 commit comments

Comments
 (0)