Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmiei committed Nov 21, 2024
1 parent d392bf6 commit ab00ff9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 31 deletions.
28 changes: 17 additions & 11 deletions binance/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,11 @@ async def order_limit(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params):
order_limit.__doc__ = Client.order_limit.__doc__

async def order_limit_buy(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params):
params.update({
"side": self.SIDE_BUY,
})
params.update(
{
"side": self.SIDE_BUY,
}
)
return await self.order_limit(timeInForce=timeInForce, **params)

order_limit_buy.__doc__ = Client.order_limit_buy.__doc__
Expand Down Expand Up @@ -710,7 +712,7 @@ async def get_account(self, **params):

get_account.__doc__ = Client.get_account.__doc__

async def get_asset_balance(self, asset = None, **params):
async def get_asset_balance(self, asset=None, **params):
res = await self.get_account(**params)
# find asset balance in list of balances
if "balances" in res:
Expand Down Expand Up @@ -3263,10 +3265,12 @@ async def ws_order_limit(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **param
:returns: WS response
See order endpoint for full response options
"""
params.update({
"type": self.ORDER_TYPE_LIMIT,
"timeInForce": timeInForce,
})
params.update(
{
"type": self.ORDER_TYPE_LIMIT,
"timeInForce": timeInForce,
}
)
return await self.ws_create_order(**params)

async def ws_order_limit_buy(
Expand Down Expand Up @@ -3295,9 +3299,11 @@ async def ws_order_limit_buy(
:returns: WS response
See order endpoint for full response options
"""
params.update({
"side": self.SIDE_BUY,
})
params.update(
{
"side": self.SIDE_BUY,
}
)
return await self.ws_order_limit(timeInForce=timeInForce, **params)

async def ws_order_limit_sell(
Expand Down
28 changes: 17 additions & 11 deletions binance/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,9 +1359,11 @@ def order_limit_buy(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params):
:raises: BinanceRequestException, BinanceAPIException, BinanceOrderException, BinanceOrderMinAmountException, BinanceOrderMinPriceException, BinanceOrderMinTotalException, BinanceOrderUnknownSymbolException, BinanceOrderInactiveSymbolException
"""
params.update({
"side": self.SIDE_BUY,
})
params.update(
{
"side": self.SIDE_BUY,
}
)
return self.order_limit(timeInForce=timeInForce, **params)

def order_limit_sell(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params):
Expand Down Expand Up @@ -1997,7 +1999,7 @@ def get_account(self, **params):
"""
return self._get("account", True, data=params)

def get_asset_balance(self, asset = None, **params):
def get_asset_balance(self, asset=None, **params):
"""Get current asset balance.
:param asset: optional - the asset to get the balance of
Expand Down Expand Up @@ -10201,10 +10203,12 @@ def ws_order_limit(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params):
:returns: WS response
See order endpoint for full response options
"""
params.update({
"type": self.ORDER_TYPE_LIMIT,
"timeInForce": timeInForce,
})
params.update(
{
"type": self.ORDER_TYPE_LIMIT,
"timeInForce": timeInForce,
}
)
return self.ws_create_order(**params)

def ws_order_limit_buy(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params):
Expand All @@ -10231,9 +10235,11 @@ def ws_order_limit_buy(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params)
:returns: WS response
See order endpoint for full response options
"""
params.update({
"side": self.SIDE_BUY,
})
params.update(
{
"side": self.SIDE_BUY,
}
)
return self.ws_order_limit(timeInForce=timeInForce, **params)

def ws_order_limit_sell(self, timeInForce=BaseClient.TIME_IN_FORCE_GTC, **params):
Expand Down
3 changes: 2 additions & 1 deletion binance/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ def __init__(self, value):
super().__init__(message)


class UnknownDateFormat(Exception): ...
class UnknownDateFormat(Exception):
...
10 changes: 6 additions & 4 deletions binance/ws/reconnecting_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,12 @@ async def _read_loop(self):
self._log.debug(
f"Queue overflow {self.MAX_QUEUE_SIZE}. Message not filled"
)
await self._queue.put({
"e": "error",
"m": "Queue overflow. Message not filled",
})
await self._queue.put(
{
"e": "error",
"m": "Queue overflow. Message not filled",
}
)
raise BinanceWebsocketUnableToConnect
except asyncio.TimeoutError:
self._log.debug(f"no message in {self.TIMEOUT} seconds")
Expand Down
3 changes: 2 additions & 1 deletion binance/ws/threaded_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def __init__(
"session_params": session_params,
}

async def _before_socket_listener_start(self): ...
async def _before_socket_listener_start(self):
...

async def socket_listener(self):
self._client = await AsyncClient.create(loop=self._loop, **self._client_params)
Expand Down
1 change: 1 addition & 0 deletions tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ async def test_get_asset_balance(clientAsync):
async def test_get_asset_balance_no_asset_provided(clientAsync):
await clientAsync.get_asset_balance()


async def test_get_my_trades(clientAsync):
await clientAsync.get_my_trades(symbol="BTCUSDT")

Expand Down
1 change: 1 addition & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def test_get_asset_balance(client):
def test_get_asset_balance_no_asset_provided(client):
client.get_asset_balance()


def test_get_my_trades(client):
client.get_my_trades(symbol="BTCUSDT")

Expand Down
6 changes: 3 additions & 3 deletions tests/test_cryptography.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ def test_encryption():
ping=False,
)
signature = client._generate_signature(data)
assert signature == case["expected_signature"], (
f"Test failed: {case['description']}"
)
assert (
signature == case["expected_signature"]
), f"Test failed: {case['description']}"

0 comments on commit ab00ff9

Please sign in to comment.