diff --git a/CHANGELOG.md b/CHANGELOG.md index d8bbaed..6e8a3d1 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.4.14 2024-02-19 +### Fix +* Exception in fetch_order: 'KeyError': 'commission' +* `fetch_order_trade_list()`: variables type inconsistent +* HTX: correcting order Status depending on cumulative_filled_quantity + ## 1.4.13 2024-02-18 ### Fix * `FetchOrder()`: conditions for generating a trading event(s) diff --git a/exchanges_wrapper/__init__.py b/exchanges_wrapper/__init__.py index da8e31c..b852b3a 100644 --- a/exchanges_wrapper/__init__.py +++ b/exchanges_wrapper/__init__.py @@ -12,7 +12,7 @@ __contact__ = "https://github.com/DogsTailFarmer" __email__ = "jerry.fedorenko@yahoo.com" __credits__ = ["https://github.com/DanyaSWorlD"] -__version__ = "1.4.13" +__version__ = "1.4.14" from pathlib import Path import shutil diff --git a/exchanges_wrapper/bybit_parser.py b/exchanges_wrapper/bybit_parser.py index 8ed40cf..65c6d3e 100644 --- a/exchanges_wrapper/bybit_parser.py +++ b/exchanges_wrapper/bybit_parser.py @@ -516,14 +516,11 @@ def order_trade_list(res: [], order_id: str) -> []: "price": price, "qty": str(qty), "quoteQty": quote_qty, + "commission": str(fee) if fee else '0', + "commissionAsset": trade['currency'] if fee else '', "time": int(trade['transactionTime']), "isBuyer": trade['side'] == 'Buy', "isMaker": True, "isBestMatch": True, } - - if fee: - trade_rows[trade_id]["commission"] = str(fee) - trade_rows[trade_id]["commissionAsset"] = str(trade['currency']) - return list(trade_rows.values()) diff --git a/exchanges_wrapper/huobi_parser.py b/exchanges_wrapper/huobi_parser.py index cd79b0d..5b97c3f 100644 --- a/exchanges_wrapper/huobi_parser.py +++ b/exchanges_wrapper/huobi_parser.py @@ -400,10 +400,10 @@ def on_order_update(_order: {}) -> {}: # if event.get('orderStatus') in ('canceled', 'partial-canceled'): status = 'CANCELED' - elif event.get('orderStatus') == 'partial-filled': - status = 'PARTIALLY_FILLED' - elif event.get('orderStatus') == 'filled': + elif event.get('orderStatus') == 'filled' and cumulative_filled_quantity >= Decimal(order_quantity): status = 'FILLED' + elif event.get('orderStatus') == 'partial-filled' or cumulative_filled_quantity > 0: + status = 'PARTIALLY_FILLED' else: status = 'NEW' return { @@ -445,22 +445,22 @@ def on_order_update(_order: {}) -> {}: def account_trade_list(res: []) -> []: binance_trade_list = [] for trade in res: - price = trade.get('price') - qty = trade.get('filled-amount') + price = trade['price'] + qty = trade['filled-amount'] quote_qty = str(Decimal(price) * Decimal(qty)) binance_trade = { - "symbol": trade.get('symbol').upper(), - "id": trade.get('trade-id'), - "orderId": trade.get('order-id'), + "symbol": trade['symbol'].upper(), + "id": trade['trade-id'], + "orderId": int(trade['order-id']), "orderListId": -1, "price": price, "qty": qty, "quoteQty": quote_qty, - "commission": trade.get('filled-fees'), - "commissionAsset": trade.get('fee-currency'), - "time": trade.get('created-at'), - "isBuyer": 'buy' in trade.get('type'), - "isMaker": trade.get('role') == 'maker', + "commission": trade['filled-fees'], + "commissionAsset": trade['fee-currency'], + "time": trade['created-at'], + "isBuyer": 'buy' in trade['type'], + "isMaker": trade['role'] == 'maker', "isBestMatch": True, } binance_trade_list.append(binance_trade) diff --git a/exchanges_wrapper/okx_parser.py b/exchanges_wrapper/okx_parser.py index 6a91a05..2ef775e 100644 --- a/exchanges_wrapper/okx_parser.py +++ b/exchanges_wrapper/okx_parser.py @@ -508,22 +508,22 @@ def funding_wallet(res: []) -> []: def order_trade_list(res: []) -> []: binance_trade_list = [] for trade in res: - price = trade.get('fillPx') - qty = trade.get('fillSz') + price = trade['fillPx'] + qty = trade['fillSz'] quote_qty = str(Decimal(price) * Decimal(qty)) binance_trade = { - "symbol": trade.get('instId').replace('-', ''), - "id": trade.get('tradeId'), - "orderId": trade.get('ordId'), + "symbol": trade['instId'].replace('-', ''), + "id": int(trade['tradeId']), + "orderId": int(trade['ordId']), "orderListId": -1, "price": price, "qty": qty, "quoteQty": quote_qty, - "commission": str(abs(float(trade.get('fee')))), - "commissionAsset": trade.get('feeCcy'), - "time": trade.get('ts'), - "isBuyer": trade.get('side') == 'buy', - "isMaker": trade.get('execType') == 'M', + "commission": str(abs(float(trade['fee']))), + "commissionAsset": trade['feeCcy'], + "time": trade['ts'], + "isBuyer": trade['side'] == 'buy', + "isMaker": trade['execType'] == 'M', "isBestMatch": True, } binance_trade_list.append(binance_trade)