From ed7f31399eec853e5947a3c9b9813bde93ebde9e Mon Sep 17 00:00:00 2001 From: DogsTailFarmer Date: Sat, 30 Sep 2023 19:51:42 +0300 Subject: [PATCH] 1.3.7.post1 --- CHANGELOG.md | 4 ++++ martin_binance/__init__.py | 2 +- martin_binance/executor.py | 9 +++++---- martin_binance/margin_wrapper.py | 7 ++++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4021d74..9d67f54 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.7.post1 - 2023-09-30 +### Fix +* Sonarcloud issues + ## 1.3.7 - 2023-09-30 ### Update * Up requirements for exchanges-wrapper==1.3.7.post2 diff --git a/martin_binance/__init__.py b/martin_binance/__init__.py index 6091540..38cce1b 100755 --- a/martin_binance/__init__.py +++ b/martin_binance/__init__.py @@ -6,7 +6,7 @@ __author__ = "Jerry Fedorenko" __copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM" __license__ = "MIT" -__version__ = "1.3.7" +__version__ = "1.3.7.post1" __maintainer__ = "Jerry Fedorenko" __contact__ = "https://github.com/DogsTailFarmer" diff --git a/martin_binance/executor.py b/martin_binance/executor.py index bd58c21..7103332 100755 --- a/martin_binance/executor.py +++ b/martin_binance/executor.py @@ -4,7 +4,7 @@ __author__ = "Jerry Fedorenko" __copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM" __license__ = "MIT" -__version__ = "1.3.7" +__version__ = "1.3.7.post1" __maintainer__ = "Jerry Fedorenko" __contact__ = 'https://github.com/DogsTailFarmer' ################################################################## @@ -19,6 +19,7 @@ # noinspection PyUnresolvedReferences import traceback # lgtm [py/unused-import] import contextlib +import math from martin_binance import Path, STANDALONE, DB_FILE # noinspection PyUnresolvedReferences @@ -507,7 +508,7 @@ def dx(_fn, _x, _delta, **_kwargs): if err >= 0: solves.append((err, x)) slope = dx(fn, x, delta, **kwargs) - if slope != 0.0: + if not math.isclose(slope, 0, abs_tol=1e-09): x -= err/slope x = max(_x + delta * tries, x + correction) else: @@ -2972,7 +2973,7 @@ def cancel_grid(self, cancel_all=False): self.orders_save.orders_list.append(self.orders_grid.get_by_id(_id)) self.message_log(f"cancel_grid order: {_id}", log_level=LogLevel.DEBUG) self.cancel_order_exp(_id, cancel_all=cancel_all) - elif self.grid_remove: + else: self.message_log("cancel_grid: Ended", log_level=LogLevel.DEBUG) self.orders_save.orders_list.clear() self.orders_hold.orders_list.clear() @@ -3344,7 +3345,7 @@ def on_place_order_success(self, place_order_id: int, order: Order) -> None: if order.amount > order.received_amount > 0: self.message_log(f"Order {place_order_id} was partially filled", color=Style.B_WHITE) self.shift_grid_threshold = None - if order.remaining_amount == 0.0: + if math.isclose(order.remaining_amount, 0, abs_tol=1e-09): self.shift_grid_threshold = None # Get actual parameter of last trade order market_order = self.get_buffered_completed_trades() diff --git a/martin_binance/margin_wrapper.py b/martin_binance/margin_wrapper.py index 12b2c80..30b6c21 100755 --- a/martin_binance/margin_wrapper.py +++ b/martin_binance/margin_wrapper.py @@ -70,6 +70,7 @@ TICKER_PKL = "ticker.pkl" MS_ORDER_ID = 'ms.order_id' MS_ORDERS = 'ms.orders' +EQUAL_STR = "================================================================" session_result = {} @@ -1000,10 +1001,10 @@ async def buffered_funds(print_info: bool = True): cls.funds = funds if print_info: - print('================================================================') + print(EQUAL_STR) print(f"Base asset balance: {balance_f}") print(f"Quote asset balance: {balance_s}") - print('================================================================') + print(EQUAL_STR) else: # print(f"buffered_funds.funds: {cls.funds}") funds = {cls.base_asset: FundsEntry(cls.funds[cls.base_asset]), @@ -1771,7 +1772,7 @@ async def main(_symbol): for i in cancel_orders: print(f"Order:{i['orderId']}, side:{i['side']}," f" amount:{i['origQty']}, price:{i['price']}, status:{i['status']}") - print('================================================================') + print(EQUAL_STR) except asyncio.CancelledError: pass # Task cancellation should not be logged as an error. except grpc.RpcError as ex: