Skip to content

Commit 6e223f2

Browse files
committed
2 parents 8d0f625 + 52877c0 commit 6e223f2

15 files changed

+98
-412
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=================================
2-
Welcome to python-binance v1.0.28
2+
Welcome to python-binance v1.0.29
33
=================================
44

55
.. image:: https://img.shields.io/pypi/v/python-binance.svg

binance/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
"""
66

7-
__version__ = "1.0.28"
7+
__version__ = "1.0.29"
88

99
from binance.async_client import AsyncClient # noqa
1010
from binance.client import Client # noqa

binance/base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BaseClient:
3636
OPTIONS_TESTNET_URL = "https://testnet.binanceops.{}/eapi"
3737
PAPI_URL = "https://papi.binance.{}/papi"
3838
WS_API_URL = "wss://ws-api.binance.{}/ws-api/v3"
39-
WS_API_TESTNET_URL = "wss://testnet.binance.vision/ws-api/v3"
39+
WS_API_TESTNET_URL = "wss://ws-api.testnet.binance.vision/ws-api/v3"
4040
WS_FUTURES_URL = "wss://ws-fapi.binance.{}/ws-fapi/v1"
4141
WS_FUTURES_TESTNET_URL = "wss://testnet.binancefuture.com/ws-fapi/v1"
4242
PUBLIC_API_VERSION = "v1"

binance/ws/streams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BinanceSocketType(str, Enum):
2525

2626
class BinanceSocketManager:
2727
STREAM_URL = "wss://stream.binance.{}:9443/"
28-
STREAM_TESTNET_URL = "wss://testnet.binance.vision/"
28+
STREAM_TESTNET_URL = "wss://stream.testnet.binance.vision/"
2929
FSTREAM_URL = "wss://fstream.binance.{}/"
3030
FSTREAM_TESTNET_URL = "wss://stream.binancefuture.com/"
3131
DSTREAM_URL = "wss://dstream.binance.{}/"

docs/changelog.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
Changelog
22
=========
33

4+
v1.0.29 - 2025-05-19
5+
^^^^^^^^^^^^^^^^^^^^
6+
7+
**Fixed**
8+
9+
- Ws tesnet spot URLs update
10+
411

5-
v1.0.28 - 2024-02-27
12+
v1.0.28 - 2025-02-27
613
^^^^^^^^^^^^^^^^^^^^
714

815
**Added**

tests/conftest.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import pytest_asyncio
23
from binance.client import Client
34
from binance.async_client import AsyncClient
45
import os
@@ -61,21 +62,27 @@ def futuresClient():
6162
)
6263

6364

64-
@pytest.fixture(scope="function")
65-
def clientAsync():
66-
return AsyncClient(api_key, api_secret, https_proxy=proxy, testnet=testnet)
65+
@pytest_asyncio.fixture(scope="function")
66+
async def clientAsync():
67+
client = AsyncClient(api_key, api_secret, https_proxy=proxy, testnet=testnet)
68+
yield client
69+
await client.close_connection()
6770

6871

69-
@pytest.fixture(scope="function")
70-
def futuresClientAsync():
71-
return AsyncClient(
72+
@pytest_asyncio.fixture(scope="function")
73+
async def futuresClientAsync():
74+
client = AsyncClient(
7275
futures_api_key, futures_api_secret, https_proxy=proxy, testnet=testnet
7376
)
77+
yield client
78+
await client.close_connection()
7479

7580

76-
@pytest.fixture(scope="function")
77-
def liveClientAsync():
78-
return AsyncClient(api_key, api_secret, https_proxy=proxy, testnet=False)
81+
@pytest_asyncio.fixture(scope="function")
82+
async def liveClientAsync():
83+
client = AsyncClient(api_key, api_secret, https_proxy=proxy, testnet=False)
84+
yield client
85+
await client.close_connection()
7986

8087
@pytest.fixture(scope="function")
8188
def manager():

tests/test_async_client.py

Lines changed: 49 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,117 +18,94 @@ async def test_clientAsync_initialization(clientAsync):
1818
@pytest.mark.skip(reason="Endpoint not documented")
1919
async def test_get_products(clientAsync):
2020
await clientAsync.get_products()
21-
21+
2222

2323
async def test_get_exchange_info(clientAsync):
2424
await clientAsync.get_exchange_info()
25-
26-
25+
2726
async def test_get_symbol_info(clientAsync):
2827
await clientAsync.get_symbol_info("BTCUSDT")
29-
28+
3029

3130
async def test_ping(clientAsync):
3231
await clientAsync.ping()
33-
34-
32+
3533
async def test_get_server_time(clientAsync):
3634
await clientAsync.get_server_time()
37-
38-
35+
3936
async def test_get_all_tickers(clientAsync):
4037
await clientAsync.get_all_tickers()
4138

42-
4339
async def test_get_orderbook_tickers(clientAsync):
4440
await clientAsync.get_orderbook_tickers()
45-
46-
41+
4742
async def test_get_order_book(clientAsync):
4843
await clientAsync.get_order_book(symbol="BTCUSDT")
49-
50-
44+
5145
async def test_get_recent_trades(clientAsync):
5246
await clientAsync.get_recent_trades(symbol="BTCUSDT")
5347

5448

5549
async def test_get_historical_trades(clientAsync):
5650
await clientAsync.get_historical_trades(symbol="BTCUSDT")
57-
51+
5852

5953
async def test_get_aggregate_trades(clientAsync):
6054
await clientAsync.get_aggregate_trades(symbol="BTCUSDT")
61-
62-
55+
6356
async def test_get_klines(clientAsync):
6457
await clientAsync.get_klines(symbol="BTCUSDT", interval="1d")
65-
66-
58+
6759
async def test_get_uiklines(clientAsync):
6860
await clientAsync.get_ui_klines(symbol="BTCUSDT", interval="1d")
69-
70-
61+
7162
async def test_futures_mark_price_klines(clientAsync):
7263
await clientAsync.futures_mark_price_klines(symbol="BTCUSDT", interval="1h")
73-
74-
64+
7565
async def test_futures_index_price_klines(clientAsync):
7666
await clientAsync.futures_index_price_klines(pair="BTCUSDT", interval="1h")
77-
78-
67+
7968
async def test_futures_premium_index_klines(clientAsync):
8069
await clientAsync.futures_premium_index_klines(symbol="BTCUSDT", interval="1h")
81-
82-
70+
8371
@pytest.mark.skip(reason="network error")
8472
async def test_futures_coin_premium_index_klines(clientAsync):
8573
await clientAsync.futures_coin_premium_index_klines(symbol="BTCUSD", interval="1h")
86-
87-
74+
8875
async def test_get_avg_price(clientAsync):
8976
await clientAsync.get_avg_price(symbol="BTCUSDT")
90-
91-
77+
9278
async def test_get_ticker(clientAsync):
9379
await clientAsync.get_ticker(symbol="BTCUSDT")
94-
95-
80+
9681
async def test_get_symbol_ticker(clientAsync):
9782
await clientAsync.get_symbol_ticker(symbol="BTCUSDT")
98-
99-
83+
10084
async def test_get_orderbook_ticker(clientAsync):
10185
await clientAsync.get_orderbook_ticker(symbol="BTCUSDT")
102-
103-
86+
10487
async def test_get_account(clientAsync):
10588
await clientAsync.get_account()
106-
107-
89+
10890
async def test_get_asset_balance(clientAsync):
10991
await clientAsync.get_asset_balance(asset="BTC")
110-
111-
92+
11293
async def test_get_asset_balance_no_asset_provided(clientAsync):
11394
await clientAsync.get_asset_balance()
114-
115-
95+
11696
async def test_get_my_trades(clientAsync):
11797
await clientAsync.get_my_trades(symbol="BTCUSDT")
118-
119-
98+
12099
async def test_get_system_status(clientAsync):
121100
await clientAsync.get_system_status()
122-
123-
101+
124102
# User Stream Endpoints
125103

126104

127105
async def test_stream_get_listen_key_and_close(clientAsync):
128106
listen_key = await clientAsync.stream_get_listen_key()
129107
await clientAsync.stream_close(listen_key)
130-
131-
108+
132109
# Quoting interface endpoints
133110

134111

@@ -139,76 +116,62 @@ async def test_stream_get_listen_key_and_close(clientAsync):
139116

140117
async def test_ws_get_order_book(clientAsync):
141118
await clientAsync.ws_get_order_book(symbol="BTCUSDT")
142-
143-
119+
144120
async def test_ws_get_recent_trades(clientAsync):
145121
await clientAsync.ws_get_recent_trades(symbol="BTCUSDT")
146-
147-
122+
148123
async def test_ws_get_historical_trades(clientAsync):
149124
await clientAsync.ws_get_historical_trades(symbol="BTCUSDT")
150-
151-
125+
152126
async def test_ws_get_aggregate_trades(clientAsync):
153127
await clientAsync.ws_get_aggregate_trades(symbol="BTCUSDT")
154-
155-
128+
156129
async def test_ws_get_klines(clientAsync):
157130
await clientAsync.ws_get_klines(symbol="BTCUSDT", interval="1m")
158-
159-
131+
160132
async def test_ws_get_uiKlines(clientAsync):
161133
await clientAsync.ws_get_uiKlines(symbol="BTCUSDT", interval="1m")
162-
163-
134+
164135
async def test_ws_get_avg_price(clientAsync):
165136
await clientAsync.ws_get_avg_price(symbol="BTCUSDT")
166-
167-
137+
168138
async def test_ws_get_ticker(clientAsync):
169139
ticker = await clientAsync.ws_get_ticker(symbol="BTCUSDT")
170-
171-
140+
172141
async def test_ws_get_trading_day_ticker(clientAsync):
173142
await clientAsync.ws_get_trading_day_ticker(symbol="BTCUSDT")
174-
175-
143+
176144
async def test_ws_get_symbol_ticker_window(clientAsync):
177145
await clientAsync.ws_get_symbol_ticker_window(symbol="BTCUSDT")
178-
179-
146+
180147
async def test_ws_get_symbol_ticker(clientAsync):
181148
await clientAsync.ws_get_symbol_ticker(symbol="BTCUSDT")
182-
183-
149+
184150
async def test_ws_get_orderbook_ticker(clientAsync):
185151
await clientAsync.ws_get_orderbook_ticker(symbol="BTCUSDT")
186-
187-
152+
188153
async def test_ws_ping(clientAsync):
189154
await clientAsync.ws_ping()
190-
191-
155+
192156
async def test_ws_get_time(clientAsync):
193157
await clientAsync.ws_get_time()
194-
195-
158+
196159
async def test_ws_get_exchange_info(clientAsync):
197160
await clientAsync.ws_get_exchange_info(symbol="BTCUSDT")
198-
161+
199162
@pytest.mark.skip(reason="can't test margin endpoints")
200163
async def test_margin_next_hourly_interest_rate(clientAsync):
201164
await clientAsync.margin_next_hourly_interest_rate(
202165
assets="BTC",
203166
isIsolated="FALSE"
204167
)
205-
168+
206169
@pytest.mark.skip(reason="can't test margin endpoints")
207170
async def test_margin_interest_history(clientAsync):
208171
await clientAsync.margin_interest_history(
209172
asset="BTC",
210173
)
211-
174+
212175
@pytest.mark.skip(reason="can't test margin endpoints")
213176
async def test_margin_borrow_repay(clientAsync):
214177
await clientAsync.margin_borrow_repay(
@@ -218,27 +181,26 @@ async def test_margin_borrow_repay(clientAsync):
218181
symbol="BTCUSDT",
219182
type="BORROW"
220183
)
221-
184+
222185
@pytest.mark.skip(reason="can't test margin endpoints")
223186
async def test_margin_get_borrow_repay_records(clientAsync):
224187
await clientAsync.margin_get_borrow_repay_records(
225188
asset="BTC",
226189
isolatedSymbol="BTCUSDT",
227190
)
228-
191+
229192
@pytest.mark.skip(reason="can't test margin endpoints")
230193
async def test_margin_interest_rate_history(clientAsync):
231194
await clientAsync.margin_interest_rate_history(
232195
asset="BTC",
233196
)
234-
197+
235198
@pytest.mark.skip(reason="can't test margin endpoints")
236199
async def test_margin_max_borrowable(clientAsync):
237200
await clientAsync.margin_max_borrowable(
238201
asset="BTC",
239202
)
240-
241-
203+
242204
async def test_time_unit_microseconds():
243205
micro_client = AsyncClient(
244206
api_key, api_secret, https_proxy=proxy, testnet=testnet, time_unit="MICROSECOND"
@@ -247,7 +209,7 @@ async def test_time_unit_microseconds():
247209
assert len(str(micro_trades[0]["time"])) >= 16, (
248210
"Time should be in microseconds (16+ digits)"
249211
)
250-
212+
await micro_client.close_connection()
251213

252214
async def test_time_unit_milloseconds():
253215
milli_client = AsyncClient(
@@ -257,6 +219,7 @@ async def test_time_unit_milloseconds():
257219
assert len(str(milli_trades[0]["time"])) == 13, (
258220
"Time should be in milliseconds (13 digits)"
259221
)
222+
await milli_client.close_connection()
260223

261224

262225
async def test_handle_response(clientAsync):
@@ -295,3 +258,4 @@ async def test_handle_response(clientAsync):
295258
mock_response._body = b'error message'
296259
with pytest.raises(BinanceAPIException):
297260
await clientAsync._handle_response(mock_response)
261+

0 commit comments

Comments
 (0)