@@ -59,9 +59,9 @@ async def test_ws_futures_get_order_book_ticker(futuresClientAsync):
5959@pytest .mark .skipif (sys .version_info < (3 , 8 ), reason = "websockets_proxy Python 3.8+" )
6060@pytest .mark .asyncio ()
6161async def test_ws_futures_create_get_edit_cancel_order_with_orjson (futuresClientAsync ):
62- if ' orjson' not in sys .modules :
62+ if " orjson" not in sys .modules :
6363 raise ImportError ("orjson is not available" )
64-
64+
6565 ticker = await futuresClientAsync .ws_futures_get_order_book_ticker (symbol = "LTCUSDT" )
6666 positions = await futuresClientAsync .ws_futures_v2_account_position (
6767 symbol = "LTCUSDT"
@@ -92,11 +92,16 @@ async def test_ws_futures_create_get_edit_cancel_order_with_orjson(futuresClient
9292 orderid = order ["orderId" ], symbol = order ["symbol" ]
9393 )
9494
95+
9596@pytest .mark .skipif (sys .version_info < (3 , 8 ), reason = "websockets_proxy Python 3.8+" )
9697@pytest .mark .asyncio ()
97- async def test_ws_futures_create_get_edit_cancel_order_without_orjson (futuresClientAsync ):
98- with patch .dict ('sys.modules' , {'orjson' : None }):
99- ticker = await futuresClientAsync .ws_futures_get_order_book_ticker (symbol = "LTCUSDT" )
98+ async def test_ws_futures_create_get_edit_cancel_order_without_orjson (
99+ futuresClientAsync ,
100+ ):
101+ with patch .dict ("sys.modules" , {"orjson" : None }):
102+ ticker = await futuresClientAsync .ws_futures_get_order_book_ticker (
103+ symbol = "LTCUSDT"
104+ )
100105 positions = await futuresClientAsync .ws_futures_v2_account_position (
101106 symbol = "LTCUSDT"
102107 )
@@ -170,7 +175,11 @@ async def test_ws_futures_fail_to_connect(futuresClientAsync):
170175 await futuresClientAsync .close_connection ()
171176
172177 # Mock the WebSocket API's connect method to raise an exception
173- with patch .object (futuresClientAsync .ws_future , 'connect' , side_effect = ConnectionError ("Simulated connection failure" )):
178+ with patch .object (
179+ futuresClientAsync .ws_future ,
180+ "connect" ,
181+ side_effect = ConnectionError ("Simulated connection failure" ),
182+ ):
174183 with pytest .raises (BinanceWebsocketUnableToConnect ):
175184 await futuresClientAsync .ws_futures_get_order_book (symbol = "BTCUSDT" )
176185
@@ -180,7 +189,9 @@ async def test_ws_futures_fail_to_connect(futuresClientAsync):
180189async def test_ws_futures_create_cancel_algo_order (futuresClientAsync ):
181190 """Test creating and canceling an algo order via websocket async"""
182191 ticker = await futuresClientAsync .ws_futures_get_order_book_ticker (symbol = "LTCUSDT" )
183- positions = await futuresClientAsync .ws_futures_v2_account_position (symbol = "LTCUSDT" )
192+ positions = await futuresClientAsync .ws_futures_v2_account_position (
193+ symbol = "LTCUSDT"
194+ )
184195
185196 # Create an algo order
186197 order = await futuresClientAsync .ws_futures_create_algo_order (
@@ -210,12 +221,14 @@ async def test_ws_futures_create_cancel_algo_order(futuresClientAsync):
210221async def test_ws_futures_create_conditional_order_auto_routing (futuresClientAsync ):
211222 """Test that conditional order types are automatically routed to algo endpoint"""
212223 ticker = await futuresClientAsync .ws_futures_get_order_book_ticker (symbol = "LTCUSDT" )
213- positions = await futuresClientAsync .ws_futures_v2_account_position (symbol = "LTCUSDT" )
224+ positions = await futuresClientAsync .ws_futures_v2_account_position (
225+ symbol = "LTCUSDT"
226+ )
214227
215228 # Create a STOP_MARKET order using ws_futures_create_order
216229 # It should automatically route to the algo endpoint
217230 # Use a price above current market price for BUY STOP
218- trigger_price = float (ticker ["askPrice" ]) * 1.5
231+ trigger_price = round ( float (ticker ["askPrice" ]) * 1.5 , 1 )
219232 order = await futuresClientAsync .ws_futures_create_order (
220233 symbol = ticker ["symbol" ],
221234 side = "BUY" ,
@@ -241,11 +254,13 @@ async def test_ws_futures_create_conditional_order_auto_routing(futuresClientAsy
241254async def test_ws_futures_conditional_order_with_stop_price (futuresClientAsync ):
242255 """Test that stopPrice is converted to triggerPrice for conditional orders"""
243256 ticker = await futuresClientAsync .ws_futures_get_order_book_ticker (symbol = "LTCUSDT" )
244- positions = await futuresClientAsync .ws_futures_v2_account_position (symbol = "LTCUSDT" )
257+ positions = await futuresClientAsync .ws_futures_v2_account_position (
258+ symbol = "LTCUSDT"
259+ )
245260
246261 # Create a TAKE_PROFIT_MARKET order with stopPrice (should be converted to triggerPrice)
247262 # Use a price above current market price for SELL TAKE_PROFIT
248- trigger_price = float (ticker ["askPrice" ]) * 1.5
263+ trigger_price = round ( float (ticker ["askPrice" ]) * 1.5 , 1 )
249264 order = await futuresClientAsync .ws_futures_create_order (
250265 symbol = ticker ["symbol" ],
251266 side = "SELL" ,
0 commit comments