exchanges-wrapper 2.2.2__tar.gz → 2.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/PKG-INFO +1 -1
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/__init__.py +1 -1
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/exch_srv.py +57 -36
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/parsers/huobi.py +18 -18
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/LICENSE.md +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/README.md +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/client.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/definitions.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/errors.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/events.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/exch_srv_cfg.toml.template +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/http_client.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/lib.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/martin/__init__.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/parsers/bitfinex.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/parsers/bybit.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/parsers/okx.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/proto/martin.proto +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/web_sockets.py +0 -0
- {exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: exchanges-wrapper
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.4
|
|
4
4
|
Summary: REST API and WebSocket asyncio wrapper with grpc powered multiplexer server
|
|
5
5
|
Author-email: Thomas Marchand <thomas.marchand@tuta.io>, Jerry Fedorenko <jerry.fedorenko@yahoo.com>
|
|
6
6
|
Requires-Python: >=3.12
|
|
@@ -12,7 +12,7 @@ __maintainer__ = "Jerry Fedorenko"
|
|
|
12
12
|
__contact__ = "https://github.com/DogsTailFarmer"
|
|
13
13
|
__email__ = "jerry.fedorenko@yahoo.com"
|
|
14
14
|
__credits__ = ["https://github.com/DanyaSWorlD"]
|
|
15
|
-
__version__ = "2.2.
|
|
15
|
+
__version__ = "2.2.4"
|
|
16
16
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
import shutil
|
|
@@ -478,24 +478,26 @@ class Martin(mr.MartinBase):
|
|
|
478
478
|
logger.info(f"OnKlinesUpdate: Stop loop for {open_client.name}:{request.symbol}:{_intervals}")
|
|
479
479
|
return
|
|
480
480
|
else:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
response.
|
|
484
|
-
response.
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
481
|
+
ev = _event
|
|
482
|
+
|
|
483
|
+
response.symbol = ev.symbol
|
|
484
|
+
response.interval = ev.kline_interval
|
|
485
|
+
response.candle = b""
|
|
486
|
+
response.candle = orjson.dumps([
|
|
487
|
+
ev.kline_start_time,
|
|
488
|
+
ev.kline_open_price,
|
|
489
|
+
ev.kline_high_price,
|
|
490
|
+
ev.kline_low_price,
|
|
491
|
+
ev.kline_close_price,
|
|
492
|
+
ev.kline_base_asset_volume,
|
|
493
|
+
ev.kline_close_time,
|
|
494
|
+
ev.kline_quote_asset_volume,
|
|
495
|
+
ev.kline_trades_number,
|
|
496
|
+
ev.kline_taker_buy_base_asset_volume,
|
|
497
|
+
ev.kline_taker_buy_quote_asset_volume,
|
|
498
|
+
ev.kline_ignore
|
|
499
|
+
])
|
|
500
|
+
|
|
499
501
|
yield response
|
|
500
502
|
_queue.task_done()
|
|
501
503
|
|
|
@@ -544,13 +546,13 @@ class Martin(mr.MartinBase):
|
|
|
544
546
|
return
|
|
545
547
|
else:
|
|
546
548
|
Martin.ticker_update_time[request.trade_id] = time.time()
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
549
|
+
ev = _event
|
|
550
|
+
response.open_price = ""
|
|
551
|
+
response.last_price = ""
|
|
552
|
+
response.open_price = str(ev.open_price)
|
|
553
|
+
response.last_price = str(ev.close_price)
|
|
554
|
+
response.close_time = int(ev.event_time)
|
|
555
|
+
|
|
554
556
|
yield response
|
|
555
557
|
_queue.task_done()
|
|
556
558
|
|
|
@@ -581,10 +583,21 @@ class Martin(mr.MartinBase):
|
|
|
581
583
|
logger.info(f"OnOrderBookUpdate: Stop loop for {open_client.name}: {request.symbol}")
|
|
582
584
|
return
|
|
583
585
|
else:
|
|
584
|
-
|
|
586
|
+
event_bids = _event.bids
|
|
587
|
+
event_asks = _event.asks
|
|
588
|
+
|
|
589
|
+
if event_bids and event_asks:
|
|
585
590
|
response.last_update_id = _event.last_update_id
|
|
586
|
-
|
|
587
|
-
|
|
591
|
+
|
|
592
|
+
res_bids = response.bids
|
|
593
|
+
res_asks = response.asks
|
|
594
|
+
|
|
595
|
+
res_bids.clear()
|
|
596
|
+
res_asks.clear()
|
|
597
|
+
|
|
598
|
+
res_bids.extend(orjson.dumps(v) for v in event_bids)
|
|
599
|
+
res_asks.extend(orjson.dumps(v) for v in event_asks)
|
|
600
|
+
|
|
588
601
|
yield response
|
|
589
602
|
_queue.task_done()
|
|
590
603
|
|
|
@@ -604,6 +617,7 @@ class Martin(mr.MartinBase):
|
|
|
604
617
|
logger.info(f"OnFundsUpdate: Stop user stream for {open_client.name}: {request.symbol}")
|
|
605
618
|
return
|
|
606
619
|
else:
|
|
620
|
+
response.event = b""
|
|
607
621
|
response.event = orjson.dumps(_event.balances)
|
|
608
622
|
yield response
|
|
609
623
|
_queue.task_done()
|
|
@@ -641,13 +655,18 @@ class Martin(mr.MartinBase):
|
|
|
641
655
|
[_events.append(client.events.wrap_event(balance)) for balance in balances]
|
|
642
656
|
|
|
643
657
|
for _event in _events:
|
|
644
|
-
|
|
658
|
+
ev = _event
|
|
659
|
+
ev_asset = ev.asset
|
|
660
|
+
|
|
661
|
+
if ev_asset in request.symbol:
|
|
645
662
|
balance = {
|
|
646
|
-
"event_time":
|
|
647
|
-
"asset":
|
|
648
|
-
"balance_delta":
|
|
649
|
-
"clear_time":
|
|
663
|
+
"event_time": ev.event_time,
|
|
664
|
+
"asset": ev_asset,
|
|
665
|
+
"balance_delta": ev.balance_delta,
|
|
666
|
+
"clear_time": ev.clear_time
|
|
650
667
|
}
|
|
668
|
+
|
|
669
|
+
response.event = b""
|
|
651
670
|
response.event = orjson.dumps(balance)
|
|
652
671
|
yield response
|
|
653
672
|
|
|
@@ -671,10 +690,12 @@ class Martin(mr.MartinBase):
|
|
|
671
690
|
logger.info(f"OnOrderUpdate: Stop user stream for {open_client.name}: {request.symbol}")
|
|
672
691
|
return
|
|
673
692
|
else:
|
|
674
|
-
|
|
675
|
-
|
|
693
|
+
event_dict = _event.__dict__.copy()
|
|
694
|
+
event_dict.pop('handlers', None)
|
|
695
|
+
response.result = b""
|
|
676
696
|
response.success = True
|
|
677
|
-
response.result = orjson.dumps(
|
|
697
|
+
response.result = orjson.dumps(event_dict)
|
|
698
|
+
|
|
678
699
|
yield response
|
|
679
700
|
_queue.task_done()
|
|
680
701
|
|
|
@@ -8,7 +8,7 @@ import logging
|
|
|
8
8
|
logger = logging.getLogger(__name__)
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def on_balance_update(res:
|
|
11
|
+
def on_balance_update(res: dict) -> dict:
|
|
12
12
|
return {
|
|
13
13
|
'e': 'balanceUpdate',
|
|
14
14
|
'E': res.get('transactTime'),
|
|
@@ -18,11 +18,11 @@ def on_balance_update(res: {}) -> {}:
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def fetch_server_time(res:
|
|
21
|
+
def fetch_server_time(res: dict) -> dict:
|
|
22
22
|
return {'serverTime': res}
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def exchange_info(server_time: int, _symbol_params) ->
|
|
25
|
+
def exchange_info(server_time: int, _symbol_params) -> dict:
|
|
26
26
|
_tick_size = str(10**(-_symbol_params.get('pp')))
|
|
27
27
|
_price_filter = {
|
|
28
28
|
"filterType": "PRICE_FILTER",
|
|
@@ -87,7 +87,7 @@ def orders(res: list, response_type=None) -> list:
|
|
|
87
87
|
return binance_orders
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
def order(res:
|
|
90
|
+
def order(res: dict, response_type=None) -> dict:
|
|
91
91
|
symbol = res.get('symbol').upper()
|
|
92
92
|
order_id = res.get('id')
|
|
93
93
|
order_list_id = -1
|
|
@@ -171,7 +171,7 @@ def order(res: {}, response_type=None) -> {}:
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
def order_cancelled(symbol, order_id=None, origin_client_order_id=None,) ->
|
|
174
|
+
def order_cancelled(symbol, order_id=None, origin_client_order_id=None,) -> dict:
|
|
175
175
|
return {
|
|
176
176
|
"symbol": symbol,
|
|
177
177
|
"origClientOrderId": origin_client_order_id,
|
|
@@ -190,7 +190,7 @@ def order_cancelled(symbol, order_id=None, origin_client_order_id=None,) -> {}:
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
|
|
193
|
-
def account_balances(res:
|
|
193
|
+
def account_balances(res: dict) -> dict:
|
|
194
194
|
"""
|
|
195
195
|
This function parses the Huobi API response for account information and
|
|
196
196
|
returns a dictionary with relevant details.
|
|
@@ -205,7 +205,7 @@ def account_balances(res: {}) -> {}:
|
|
|
205
205
|
# Filter out balances that have zero value
|
|
206
206
|
res[:] = [i for i in res if i.get('balance') != '0']
|
|
207
207
|
|
|
208
|
-
assets =
|
|
208
|
+
assets = dict
|
|
209
209
|
for balance in res:
|
|
210
210
|
asset = balance['currency']
|
|
211
211
|
assets.setdefault(asset, {
|
|
@@ -230,12 +230,12 @@ def account_balances(res: {}) -> {}:
|
|
|
230
230
|
return {"balances": balances}
|
|
231
231
|
|
|
232
232
|
|
|
233
|
-
def order_book(res:
|
|
233
|
+
def order_book(res: dict) -> dict:
|
|
234
234
|
res["lastUpdateId"] = res.pop("ts")
|
|
235
235
|
return res
|
|
236
236
|
|
|
237
237
|
|
|
238
|
-
def order_book_ws(res:
|
|
238
|
+
def order_book_ws(res: dict, symbol: str) -> dict:
|
|
239
239
|
return {
|
|
240
240
|
'stream': f"{symbol}@depth5",
|
|
241
241
|
'data': {'lastUpdateId': res['ts'],
|
|
@@ -245,14 +245,14 @@ def order_book_ws(res: {}, symbol: str) -> {}:
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
|
|
248
|
-
def fetch_symbol_price_ticker(res:
|
|
248
|
+
def fetch_symbol_price_ticker(res: dict, symbol) -> dict:
|
|
249
249
|
return {
|
|
250
250
|
"symbol": symbol,
|
|
251
251
|
"price": str(res.get('data')[0].get('price'))
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
|
|
255
|
-
def ticker_price_change_statistics(res:
|
|
255
|
+
def ticker_price_change_statistics(res: dict, symbol) -> dict:
|
|
256
256
|
return {
|
|
257
257
|
"symbol": symbol,
|
|
258
258
|
"priceChange": str(res.get('close') - res.get('open')),
|
|
@@ -280,8 +280,8 @@ def ticker_price_change_statistics(res: {}, symbol) -> {}:
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
|
|
283
|
-
def ticker(res:
|
|
284
|
-
tick = res.get('tick')
|
|
283
|
+
def ticker(res: dict, symbol: str = None) -> dict:
|
|
284
|
+
tick: dict = res.get('tick')
|
|
285
285
|
return {
|
|
286
286
|
'stream': f"{symbol}@miniTicker",
|
|
287
287
|
'data': {
|
|
@@ -350,9 +350,9 @@ def klines(res: list, _interval: str) -> list:
|
|
|
350
350
|
return binance_klines
|
|
351
351
|
|
|
352
352
|
|
|
353
|
-
def candle(res: dict, symbol
|
|
354
|
-
tick = res.get('tick')
|
|
355
|
-
start_time = tick.get('id')
|
|
353
|
+
def candle(res: dict, symbol = '', ch_type = '') -> dict:
|
|
354
|
+
tick: dict = res.get('tick')
|
|
355
|
+
start_time = tick.get('id') * 1000
|
|
356
356
|
_interval = ch_type.split('_')[1]
|
|
357
357
|
end_time = start_time + interval2value(interval(_interval)) * 1000 - 1
|
|
358
358
|
return {
|
|
@@ -384,7 +384,7 @@ def candle(res: dict, symbol: str = None, ch_type: str = None) -> {}:
|
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
|
|
387
|
-
def on_funds_update(data:
|
|
387
|
+
def on_funds_update(data: dict) -> dict:
|
|
388
388
|
event_time = int(time.time() * 1000)
|
|
389
389
|
binance_funds = {
|
|
390
390
|
'e': 'outboundAccountPosition',
|
|
@@ -404,7 +404,7 @@ def on_funds_update(data: {}) -> {}:
|
|
|
404
404
|
return binance_funds
|
|
405
405
|
|
|
406
406
|
|
|
407
|
-
def on_order_update(_order:
|
|
407
|
+
def on_order_update(_order: dict) -> dict:
|
|
408
408
|
event = _order['lastEvent']
|
|
409
409
|
order_quantity = event.get('orderSize', event.get('orderValue'))
|
|
410
410
|
order_price = event.get('orderPrice', event.get('tradePrice'))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{exchanges_wrapper-2.2.2 → exchanges_wrapper-2.2.4}/exchanges_wrapper/exch_srv_cfg.toml.template
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|