Skip to content

Commit d1c1f13

Browse files
2.1.34
🔧 fix(exchanges_wrapper): adjust return types for several functions to use 'list' and 'dict' annotations 🔧 fix(exchanges_wrapper): ensure consistent return types in 'fetch_server_time' and 'get_symbols' functions 🔧 fix(parsers): update 'orders', 'klines', and 'candle' functions in various parsers to use 'list' and 'dict' annotations ✨ feat(client.py): Update `UserEventsDataStream` to use new API endpoint and remove deprecated methods ✨ feat(lib.py): Remove redundant check for `binance_us` exchange ✨ fix(web_sockets.py): Adjust `ping_interval` for `binance` and `huobi` ✨ fix(web_sockets.py): Refactor message handling for `binance` events ✨ fix(requirements.txt): Upgrade `crypto-ws-api` to version 2.0.20 📝 docs(README.md): Update documentation regarding `Ed25519` API key for `Binance` ✨ chore(toml): Update `exch_srv_cfg.toml.template` with new API key requirements
1 parent 4393cf2 commit d1c1f13

File tree

15 files changed

+118
-168
lines changed

15 files changed

+118
-168
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 2.1.34 2025-04-24
2+
🔧 fix(exchanges_wrapper): adjust return types for several functions to use 'list' and 'dict' annotations
3+
🔧 fix(exchanges_wrapper): ensure consistent return types in 'fetch_server_time' and 'get_symbols' functions
4+
🔧 fix(parsers): update 'orders', 'klines', and 'candle' functions in various parsers to use 'list' and 'dict' annotations
5+
✨ feat(client.py): Update `UserEventsDataStream` to use new API endpoint and remove deprecated methods
6+
✨ feat(lib.py): Remove redundant check for `binance_us` exchange
7+
✨ fix(web_sockets.py): Adjust `ping_interval` for `binance` and `huobi`
8+
✨ fix(web_sockets.py): Refactor message handling for `binance` events
9+
✨ fix(requirements.txt): Upgrade `crypto-ws-api` to version 2.0.20
10+
📝 docs(README.md): Update documentation regarding `Ed25519` API key for `Binance`
11+
✨ chore(toml): Update `exch_srv_cfg.toml.template` with new API key requirements
12+
113
## 2.1.33 2025-03-28
214
### Update
315
* ✨ feat(requirements.txt): Update crypto-ws-api and aiohttp to latest versions.

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<a href="https://sonarcloud.io/summary/new_code?id=DogsTailFarmer_exchanges-wrapper" target="_blank"><img alt="sonarcloud" title="sonarcloud" src="https://sonarcloud.io/api/project_badges/measure?project=DogsTailFarmer_exchanges-wrapper&metric=alert_status"/></a>
1313
<a href="https://pepy.tech/project/exchanges-wrapper" target="_blank"><img alt="Downloads" title="Downloads" src="https://static.pepy.tech/badge/exchanges-wrapper/month"/></a>
1414
***
15-
From `2.1.21` must be updated `exch_srv_cfg.toml` from `exchanges_wrapper/exch_srv_cfg.toml.template`
15+
On `Binance`: now API key type [Ed25519](https://www.binance.com/en/support/faq/detail/6b9a63f1e3384cf48a2eedb82767a69a) is used instead of `HMAC`
16+
From `2.1.34` must be updated `exch_srv_cfg.toml` from `exchanges_wrapper/exch_srv_cfg.toml.template`
1617
***
1718

1819
## exchanges-wrapper vs [binance.py](https://github.com/Th0rgal/binance.py)
@@ -52,11 +53,13 @@ at real bidding. First, run applications on the [Binance Spot Test Network](http
5253

5354
## Get started
5455
### Prepare exchange account
55-
* Create account on [Binance](https://accounts.binance.com/en/register?ref=FXQ6HY5O) and get 10% discount on all trading fee
56-
* Create account on [Bitfinex](https://www.bitfinex.com/sign-up?refcode=v_4az2nCP) and get 6% rebate fee
57-
* Create account on [HUOBI](https://www.huobi.com/en-us/topic/double-reward/?invite_code=9uaw3223) and get 10% cashback on all trading fee
58-
* Create account on [OKX](https://www.okx.com/join/2607649) and get Mystery Boxes worth up to $10,000
59-
* Create account on [Bybit](https://www.bybit.com/invite?ref=9KEW1K) and get exclusive referral rewards
56+
Create account on [Binance](https://accounts.binance.com/en/register?ref=FXQ6HY5O) and get 10% discount on all trading fee
57+
Create account on [HTX](https://www.htx.com/invite/en-us/1f?invite_code=9uaw3223) From every invitee, win a Mystery Box (up to 1,500 USDT) and 30% of their trading fees.
58+
Create account on [Bitfinex](https://www.bitfinex.com/sign-up?refcode=v_4az2nCP) and get 6% rebate fee
59+
Create account on [OKX](https://okx.com/join/2607649) and will be in for the chance to earn up to 100 USDT
60+
Create account on [Bybit](https://www.bybit.com/invite?ref=9KEW1K) and get exclusive referral rewards
61+
62+
Also, you can start strategy on [Hetzner](https://hetzner.cloud/?ref=uFdrF8nsdGMc) cloud VPS only for 4.75 € per month
6063

6164
* For test purpose log in at [Binance Spot Test Network](https://testnet.binance.vision/)
6265
* Create API Key

exchanges_wrapper/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
__contact__ = "https://github.com/DogsTailFarmer"
1313
__email__ = "[email protected]"
1414
__credits__ = ["https://github.com/DanyaSWorlD"]
15-
__version__ = "2.1.33"
15+
__version__ = "2.1.34"
1616

1717
from pathlib import Path
1818
import shutil

exchanges_wrapper/client.py

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
logger = logging.getLogger(__name__)
3131

3232
STATUS_TIMEOUT = 5 # sec, also use for lifetime limit for inactive order (Bitfinex) as 60 * STATUS_TIMEOUT
33-
USER_DATA_STREAM = "/api/v3/userDataStream"
3433
ORDER_ENDPOINT = "/api/v3/order"
3534

3635
def fallback_warning(exchange, symbol=None):
@@ -161,7 +160,7 @@ async def start_user_events_listener(self, _trade_id, symbol):
161160
logger.info(f"Start '{self.exchange}' user events listener for {_trade_id}")
162161
user_data_stream = None
163162
if self.exchange == 'binance':
164-
user_data_stream = await UserEventsDataStream(self, self.endpoint_ws_auth, self.exchange, _trade_id)
163+
user_data_stream = UserEventsDataStream(self, self.endpoint_ws_api, self.exchange, _trade_id)
165164
elif self.exchange == 'bitfinex':
166165
user_data_stream = BfxPrivateEventsDataStream(self, self.endpoint_ws_auth, self.exchange, _trade_id)
167166
elif self.exchange == 'huobi':
@@ -185,7 +184,7 @@ async def start_user_events_listener(self, _trade_id, symbol):
185184
if not timeout:
186185
logger.warning(f"{self.exchange} user WSS start timeout reached for {_trade_id}")
187186
break
188-
await asyncio.sleep(0.05)
187+
await asyncio.sleep(0.1)
189188

190189
async def start_market_events_listener(self, _trade_id):
191190
_events = self.events.registered_streams.get(self.exchange, {}).get(_trade_id, set())
@@ -525,6 +524,7 @@ async def fetch_ledgers(self, symbol, limit=25):
525524
self.ledgers_id.pop(0)
526525
balances.append(i[_id])
527526
return balances
527+
return None
528528

529529
# https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#recent-trades-list
530530
async def fetch_recent_trades_list(self, symbol, limit=500):
@@ -773,6 +773,7 @@ async def one_click_arrival_deposit(self, tx_id):
773773
params=params,
774774
signed=True,
775775
)
776+
return None
776777

777778
async def fetch_api_info(self):
778779
res, _ = await self.http.send_api_call("/v5/user/query-api", signed=True)
@@ -816,7 +817,6 @@ async def create_order(
816817
trade_id,
817818
"order.place",
818819
_params=params,
819-
send_api_key=True,
820820
_signed=True
821821
)
822822
if binance_res is None:
@@ -947,7 +947,6 @@ async def fetch_order( # lgtm [py/similar-function]
947947
trade_id,
948948
"order.status",
949949
_params=params,
950-
send_api_key=True,
951950
_signed=True,
952951
)
953952
if b_res is None:
@@ -1050,7 +1049,6 @@ async def cancel_order( # lgtm [py/similar-function]
10501049
trade_id,
10511050
"order.cancel",
10521051
_params=params,
1053-
send_api_key=True,
10541052
_signed=True
10551053
)
10561054
if binance_res is None:
@@ -1152,7 +1150,6 @@ async def cancel_all_orders(self, trade_id, symbol, receive_window=None):
11521150
trade_id,
11531151
"openOrders.cancelAll",
11541152
_params=params,
1155-
send_api_key=True,
11561153
_signed=True
11571154
)
11581155
if binance_res is None:
@@ -1275,7 +1272,6 @@ async def fetch_open_orders(self, trade_id, symbol, receive_window=None, respons
12751272
trade_id,
12761273
"openOrders.status",
12771274
_params=params,
1278-
send_api_key=True,
12791275
_signed=True
12801276
)
12811277
if binance_res is None:
@@ -1522,7 +1518,6 @@ async def fetch_account_information(self, trade_id, receive_window=None):
15221518
trade_id,
15231519
"account.status",
15241520
_params=params,
1525-
send_api_key=True,
15261521
_signed=True
15271522
)
15281523
if binance_res is None:
@@ -1744,7 +1739,6 @@ async def fetch_account_trade_list(
17441739
trade_id,
17451740
"myTrades",
17461741
_params=params,
1747-
send_api_key=True,
17481742
_signed=True
17491743
)
17501744
if binance_res is None:
@@ -1839,25 +1833,3 @@ async def fetch_order_trade_list(self, trade_id, symbol, order_id):
18391833
return b_res
18401834

18411835
# endregion
1842-
1843-
# USER DATA STREAM ENDPOINTS
1844-
1845-
# https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md#create-a-listenkey
1846-
async def create_listen_key(self):
1847-
return await self.http.send_api_call(USER_DATA_STREAM, "POST")
1848-
1849-
# https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md#close-a-listenkey
1850-
async def keep_alive_listen_key(self, listen_key):
1851-
if not listen_key:
1852-
raise ValueError("This query requires a listen_key.")
1853-
return await self.http.send_api_call(
1854-
USER_DATA_STREAM, "PUT", params={"listenKey": listen_key}
1855-
)
1856-
1857-
# https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md#close-a-listenkey
1858-
async def close_listen_key(self, listen_key):
1859-
if not listen_key:
1860-
raise ValueError("This query requires a listen_key.")
1861-
return await self.http.send_api_call(
1862-
USER_DATA_STREAM, "DELETE", params={"listenKey": listen_key}
1863-
)

exchanges_wrapper/exch_srv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import traceback
1313
import asyncio
1414
import functools
15+
# noinspection PyPackageRequirements
1516
import ujson as json
1617
import logging.handlers
1718
from decimal import Decimal

exchanges_wrapper/exch_srv_cfg.toml.template

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
# Parameters for exchanges-wrapper REST API Server exch_srv.py
22
# Copyright © 2021-2025 Jerry Fedorenko aka VM
3-
# __version__ = "2.1.29"
3+
# __version__ = "2.1.34"
4+
45
# region endpoint
56
[endpoint]
67
[endpoint.binance]
78
api_public = 'https://api.binance.com'
89
api_auth = 'https://api.binance.com'
910
ws_public = 'wss://stream.binance.com:9443'
10-
ws_auth = 'wss://stream.binance.com:9443'
1111
api_test = 'https://testnet.binance.vision'
12-
ws_test = 'wss://testnet.binance.vision/ws'
1312
ws_api = 'wss://ws-api.binance.com:443/ws-api/v3'
1413
ws_api_test = 'wss://testnet.binance.vision/ws-api/v3'
1514

16-
[endpoint.binance_us]
17-
api_public = 'https://api.binance.us'
18-
api_auth = 'https://api.binance.us'
19-
ws_public = 'wss://stream.binance.us:9443'
20-
ws_auth = 'wss://stream.binance.us:9443'
21-
api_test = 'https://testnet.binance.vision'
22-
ws_test = 'wss://testnet.binance.vision/ws'
23-
ws_api = 'wss://ws-api.binance.us:443/ws-api/v3'
24-
ws_api_test = 'wss://testnet.binance.vision/ws-api/v3'
25-
2615
[endpoint.bitfinex]
2716
api_public = 'https://api-pub.bitfinex.com'
2817
api_auth = 'https://api.bitfinex.com'
@@ -58,35 +47,42 @@
5847
# endregion
5948

6049
# region Binance.com accounts
50+
# How to Generate an Ed25519 Key Pair and Register then on Binance:
51+
# https://www.binance.com/en/support/faq/detail/6b9a63f1e3384cf48a2eedb82767a69a
6152
[[accounts]]
6253
exchange = 'binance'
6354
name = 'Demo - Binance'
64-
api_key = '*********** Place API key there ************'
65-
api_secret = '*********** Place secret API key there ************'
55+
api_key = '*********** Place Ed25519 API key there ************'
56+
api_secret = """
57+
-----BEGIN PRIVATE KEY-----
58+
*********** Place PRIVATE API key there ************
59+
-----END PRIVATE KEY-----
60+
"""
6661
test_net = true
6762

6863
[[accounts]]
6964
exchange = 'binance'
7065
name = 'BinanceSub1'
71-
api_key = '*********** Place API key there ************'
72-
api_secret = '*********** Place secret API key there ************'
66+
api_key = '*********** Place Ed25519 API key there ************'
67+
api_secret = """
68+
-----BEGIN PRIVATE KEY-----
69+
*********** Place PRIVATE API key there ************
70+
-----END PRIVATE KEY-----
71+
"""
7372
test_net = false
7473

7574
[[accounts]]
7675
exchange = 'binance'
7776
name = 'BinanceSub2'
78-
api_key = '*********** Place API key there ************'
79-
api_secret = '*********** Place secret API key there ************'
77+
api_key = '*********** Place Ed25519 API key there ************'
78+
api_secret = """
79+
-----BEGIN PRIVATE KEY-----
80+
*********** Place PRIVATE API key there ************
81+
-----END PRIVATE KEY-----
82+
"""
8083
master_email = '[email protected]' # If set, 'BinanceSub1' use for collecting assets instead of Main
8184
test_net = false
8285

83-
# Binance.us accounts
84-
[[accounts]]
85-
exchange = 'binance_us'
86-
name = 'Binance US'
87-
api_key = '*********** Place API key there ************'
88-
api_secret = '*********** Place secret API key there ************'
89-
test_net = false
9086
# endregion
9187

9288
# region Bitfinex accounts

exchanges_wrapper/http_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def __init__(self, params: dict):
4545
self.rate_limit_handler = RateLimitHandler() if self.exchange == 'bybit' else None
4646

4747
def declare_exchanges_implementation(self):
48-
# noinspection PyTypeChecker
4948
self.ex_imps = {
5049
'binance': self._binance_request,
5150
'bitfinex': self._bitfinex_request,

exchanges_wrapper/lib.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ def get_account(account_name: str) -> dict:
7777
ws_public = get_ws_public(endpoint, exchange, test_net)
7878
ws_api, ws_auth = get_ws_api_auth(endpoint, exchange, test_net)
7979

80-
if exchange == 'binance_us':
81-
exchange = 'binance'
82-
8380
return {
8481
'exchange': exchange,
8582
'sub_account': sub_account,
@@ -96,7 +93,7 @@ def get_account(account_name: str) -> dict:
9693
'master_name': master_name,
9794
'two_fa': account.get('two_fa'),
9895
'ws_api': ws_api,
99-
}
96+
}
10097
return {}
10198

10299
def get_ws_add_on(endpoint, exchange):
@@ -118,7 +115,7 @@ def get_ws_api_auth(endpoint, exchange, test_net):
118115
if exchange == 'bitfinex':
119116
ws_api = ws_auth = endpoint['ws_auth']
120117
else:
121-
ws_auth = endpoint['ws_test'] if test_net else endpoint['ws_auth']
118+
ws_auth = endpoint.get('ws_test') if test_net else endpoint.get('ws_auth')
122119
ws_api = endpoint.get('ws_api_test') if test_net else endpoint.get('ws_api')
123120
if exchange == 'okx':
124121
ws_api = ws_auth

0 commit comments

Comments
 (0)