exchanges-wrapper 1.4.12__tar.gz → 1.4.14__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-1.4.12 → exchanges_wrapper-1.4.14}/PKG-INFO +1 -1
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/__init__.py +1 -1
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/bybit_parser.py +2 -5
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/c_structures.py +0 -36
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/exch_srv.py +4 -8
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/huobi_parser.py +13 -13
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/okx_parser.py +10 -10
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/LICENSE.md +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/README.md +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/api_pb2.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/api_pb2_grpc.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/bitfinex_parser.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/client.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/definitions.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/errors.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/events.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/exch_srv_cfg.toml.template +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/http_client.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/proto/exchanges_wrapper/api.proto +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/web_sockets.py +0 -0
- {exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: exchanges-wrapper
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.14
|
|
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.9
|
|
@@ -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__ = "1.4.
|
|
15
|
+
__version__ = "1.4.14"
|
|
16
16
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
import shutil
|
|
@@ -516,14 +516,11 @@ def order_trade_list(res: [], order_id: str) -> []:
|
|
|
516
516
|
"price": price,
|
|
517
517
|
"qty": str(qty),
|
|
518
518
|
"quoteQty": quote_qty,
|
|
519
|
+
"commission": str(fee) if fee else '0',
|
|
520
|
+
"commissionAsset": trade['currency'] if fee else '',
|
|
519
521
|
"time": int(trade['transactionTime']),
|
|
520
522
|
"isBuyer": trade['side'] == 'Buy',
|
|
521
523
|
"isMaker": True,
|
|
522
524
|
"isBestMatch": True,
|
|
523
525
|
}
|
|
524
|
-
|
|
525
|
-
if fee:
|
|
526
|
-
trade_rows[trade_id]["commission"] = str(fee)
|
|
527
|
-
trade_rows[trade_id]["commissionAsset"] = str(trade['currency'])
|
|
528
|
-
|
|
529
526
|
return list(trade_rows.values())
|
|
@@ -7,42 +7,6 @@ REST_RATE_LIMIT_INTERVAL = {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
class OrderUpdateEvent:
|
|
11
|
-
def __init__(self, event_data: {}):
|
|
12
|
-
self.symbol = event_data["symbol"]
|
|
13
|
-
self.client_order_id = event_data["clientOrderId"]
|
|
14
|
-
self.side = event_data["side"]
|
|
15
|
-
self.order_type = event_data["type"]
|
|
16
|
-
self.time_in_force = event_data["timeInForce"]
|
|
17
|
-
self.order_quantity = event_data["origQty"]
|
|
18
|
-
self.order_price = event_data["price"]
|
|
19
|
-
self.stop_price = event_data.get("stopPrice")
|
|
20
|
-
self.iceberg_quantity = event_data.get("icebergQty")
|
|
21
|
-
self.order_list_id = event_data["orderListId"]
|
|
22
|
-
self.original_client_id = event_data["clientOrderId"]
|
|
23
|
-
self.execution_type = "TRADE"
|
|
24
|
-
self.order_status = event_data["status"]
|
|
25
|
-
self.order_reject_reason = "NONE"
|
|
26
|
-
self.order_id = event_data["orderId"]
|
|
27
|
-
self.last_executed_quantity = self.cumulative_filled_quantity = event_data["executedQty"]
|
|
28
|
-
self.commission_amount = event_data.get("commission_amount", "0.0")
|
|
29
|
-
self.commission_asset = event_data.get("commission_asset", "")
|
|
30
|
-
self.transaction_time = event_data.get("updateTime", event_data.get("transactTime"))
|
|
31
|
-
self.trade_id = -1
|
|
32
|
-
self.ignore_a = int()
|
|
33
|
-
self.in_order_book = True
|
|
34
|
-
self.is_maker_side = event_data.get("is_maker_side", False)
|
|
35
|
-
self.ignore_b = False
|
|
36
|
-
self.order_creation_time = event_data.get("time", self.transaction_time)
|
|
37
|
-
self.quote_asset_transacted = event_data["cummulativeQuoteQty"]
|
|
38
|
-
self.quote_order_quantity = event_data.get(
|
|
39
|
-
"origQuoteOrderQty", str(Decimal(self.order_quantity) * Decimal(self.order_price))
|
|
40
|
-
)
|
|
41
|
-
self.last_executed_price = str(Decimal(self.quote_asset_transacted) /
|
|
42
|
-
Decimal(self.cumulative_filled_quantity))
|
|
43
|
-
self.last_quote_asset_transacted = str(Decimal(self.last_executed_quantity) * Decimal(self.last_executed_price))
|
|
44
|
-
|
|
45
|
-
|
|
46
10
|
class OrderTradesEvent:
|
|
47
11
|
def __init__(self, event_data: {}):
|
|
48
12
|
self.symbol = event_data["symbol"]
|
|
@@ -19,7 +19,7 @@ from google.protobuf import json_format
|
|
|
19
19
|
from exchanges_wrapper import errors, api_pb2, api_pb2_grpc
|
|
20
20
|
from exchanges_wrapper.client import Client
|
|
21
21
|
from exchanges_wrapper.definitions import Side, OrderType, TimeInForce, ResponseType
|
|
22
|
-
from exchanges_wrapper.c_structures import
|
|
22
|
+
from exchanges_wrapper.c_structures import OrderTradesEvent, REST_RATE_LIMIT_INTERVAL
|
|
23
23
|
from exchanges_wrapper import WORK_PATH, CONFIG_FILE, LOG_FILE
|
|
24
24
|
#
|
|
25
25
|
HEARTBEAT = 1 # Sec
|
|
@@ -319,12 +319,9 @@ class Martin(api_pb2_grpc.MartinServicer):
|
|
|
319
319
|
f" {request.order_id}({request.client_order_id}) exception: {_ex}")
|
|
320
320
|
else:
|
|
321
321
|
open_client.ts_rlc = time.time()
|
|
322
|
-
if _queue and request.filled_update_call:
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
await _queue.put(weakref.ref(event)())
|
|
326
|
-
elif request.order_id:
|
|
327
|
-
await self.create_trade_stream_event(_queue, client, open_client, request, res)
|
|
322
|
+
if _queue and request.filled_update_call and Decimal(res.get('executedQty', '0')):
|
|
323
|
+
request.order_id = res.get('orderId')
|
|
324
|
+
await self.create_trade_stream_event(_queue, client, open_client, request, res)
|
|
328
325
|
json_format.ParseDict(res, response, ignore_unknown_fields=True)
|
|
329
326
|
return response
|
|
330
327
|
|
|
@@ -981,7 +978,6 @@ async def event_handler(_queue, client, trade_id, _event_type, event):
|
|
|
981
978
|
|
|
982
979
|
def is_port_in_use(port: int) -> bool:
|
|
983
980
|
import socket
|
|
984
|
-
# with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
|
|
985
981
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
986
982
|
return s.connect_ex(('localhost', port)) == 0
|
|
987
983
|
|
|
@@ -400,10 +400,10 @@ def on_order_update(_order: {}) -> {}:
|
|
|
400
400
|
#
|
|
401
401
|
if event.get('orderStatus') in ('canceled', 'partial-canceled'):
|
|
402
402
|
status = 'CANCELED'
|
|
403
|
-
elif event.get('orderStatus') == '
|
|
404
|
-
status = 'PARTIALLY_FILLED'
|
|
405
|
-
elif event.get('orderStatus') == 'filled':
|
|
403
|
+
elif event.get('orderStatus') == 'filled' and cumulative_filled_quantity >= Decimal(order_quantity):
|
|
406
404
|
status = 'FILLED'
|
|
405
|
+
elif event.get('orderStatus') == 'partial-filled' or cumulative_filled_quantity > 0:
|
|
406
|
+
status = 'PARTIALLY_FILLED'
|
|
407
407
|
else:
|
|
408
408
|
status = 'NEW'
|
|
409
409
|
return {
|
|
@@ -445,22 +445,22 @@ def on_order_update(_order: {}) -> {}:
|
|
|
445
445
|
def account_trade_list(res: []) -> []:
|
|
446
446
|
binance_trade_list = []
|
|
447
447
|
for trade in res:
|
|
448
|
-
price = trade
|
|
449
|
-
qty = trade
|
|
448
|
+
price = trade['price']
|
|
449
|
+
qty = trade['filled-amount']
|
|
450
450
|
quote_qty = str(Decimal(price) * Decimal(qty))
|
|
451
451
|
binance_trade = {
|
|
452
|
-
"symbol": trade
|
|
453
|
-
"id": trade
|
|
454
|
-
"orderId": trade
|
|
452
|
+
"symbol": trade['symbol'].upper(),
|
|
453
|
+
"id": trade['trade-id'],
|
|
454
|
+
"orderId": int(trade['order-id']),
|
|
455
455
|
"orderListId": -1,
|
|
456
456
|
"price": price,
|
|
457
457
|
"qty": qty,
|
|
458
458
|
"quoteQty": quote_qty,
|
|
459
|
-
"commission": trade
|
|
460
|
-
"commissionAsset": trade
|
|
461
|
-
"time": trade
|
|
462
|
-
"isBuyer": 'buy' in trade
|
|
463
|
-
"isMaker": trade
|
|
459
|
+
"commission": trade['filled-fees'],
|
|
460
|
+
"commissionAsset": trade['fee-currency'],
|
|
461
|
+
"time": trade['created-at'],
|
|
462
|
+
"isBuyer": 'buy' in trade['type'],
|
|
463
|
+
"isMaker": trade['role'] == 'maker',
|
|
464
464
|
"isBestMatch": True,
|
|
465
465
|
}
|
|
466
466
|
binance_trade_list.append(binance_trade)
|
|
@@ -508,22 +508,22 @@ def funding_wallet(res: []) -> []:
|
|
|
508
508
|
def order_trade_list(res: []) -> []:
|
|
509
509
|
binance_trade_list = []
|
|
510
510
|
for trade in res:
|
|
511
|
-
price = trade
|
|
512
|
-
qty = trade
|
|
511
|
+
price = trade['fillPx']
|
|
512
|
+
qty = trade['fillSz']
|
|
513
513
|
quote_qty = str(Decimal(price) * Decimal(qty))
|
|
514
514
|
binance_trade = {
|
|
515
|
-
"symbol": trade
|
|
516
|
-
"id": trade
|
|
517
|
-
"orderId": trade
|
|
515
|
+
"symbol": trade['instId'].replace('-', ''),
|
|
516
|
+
"id": int(trade['tradeId']),
|
|
517
|
+
"orderId": int(trade['ordId']),
|
|
518
518
|
"orderListId": -1,
|
|
519
519
|
"price": price,
|
|
520
520
|
"qty": qty,
|
|
521
521
|
"quoteQty": quote_qty,
|
|
522
|
-
"commission": str(abs(float(trade
|
|
523
|
-
"commissionAsset": trade
|
|
524
|
-
"time": trade
|
|
525
|
-
"isBuyer": trade
|
|
526
|
-
"isMaker": trade
|
|
522
|
+
"commission": str(abs(float(trade['fee']))),
|
|
523
|
+
"commissionAsset": trade['feeCcy'],
|
|
524
|
+
"time": trade['ts'],
|
|
525
|
+
"isBuyer": trade['side'] == 'buy',
|
|
526
|
+
"isMaker": trade['execType'] == 'M',
|
|
527
527
|
"isBestMatch": True,
|
|
528
528
|
}
|
|
529
529
|
binance_trade_list.append(binance_trade)
|
|
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
|
{exchanges_wrapper-1.4.12 → exchanges_wrapper-1.4.14}/exchanges_wrapper/exch_srv_cfg.toml.template
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|