diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fa13e1..e8768f3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.0.post2 - 2023-11-24 +### Fix +* Exception buffered_orders: 'NoneType' object is not subscriptable #68 + ## 2.0.0.post1 - 2023-11-23 ### Fix * Fix issue detected by SonarCloud diff --git a/martin_binance/__init__.py b/martin_binance/__init__.py index 2d72ce9..f0904f8 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__ = "2.0.0.post1" +__version__ = "2.0.0.post2" __maintainer__ = "Jerry Fedorenko" __contact__ = "https://github.com/DogsTailFarmer" diff --git a/martin_binance/executor.py b/martin_binance/executor.py index ecc5322..9216195 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__ = "2.0.0" +__version__ = "2.0.0.post2" __maintainer__ = "Jerry Fedorenko" __contact__ = 'https://github.com/DogsTailFarmer' ################################################################## @@ -2277,7 +2277,7 @@ def grid_handler( except AttributeError: self.message_log("grid_handler: AttributeError raised", LogLevel.WARNING) - if after_full_fill and self.orders_hold and self.order_q_placed: + if after_full_fill and self.orders_hold and self.order_q_placed and not self.grid_remove: # PLace one hold grid order and remove it from hold list _, _buy, _amount, _price = self.orders_hold.get_first() check = (len(self.orders_grid) + len(self.orders_hold)) <= 2 @@ -2899,26 +2899,26 @@ def on_cancel_order_success(self, order_id: int, cancel_all=False) -> None: self.part_amount.pop(order_id, None) self.orders_grid.remove(order_id) if self.restore_orders: - _order = self.orders_save.get_by_id(order_id) - self.orders_save.remove(order_id) - if self.check_min_amount(amount=_order['amount'], price=_order['price']): - self.orders_hold.orders_list.append(_order) - elif self.orders_save: - _order_saved = list(self.orders_save.get_last()) - _order_saved[2] += _order['amount'] - self.orders_save.remove(_order_saved[0]) - self.orders_save.append_order(*_order_saved) - self.message_log(f"Small restored amount {_order['amount']} was added" - f" to last saved order {_order_saved[0]}", tlg=True) - elif self.orders_hold: - _order_hold = list(self.orders_hold.get_last()) - _order_hold[2] += _order['amount'] - self.orders_hold.remove(_order_hold[0]) - self.orders_hold.append_order(*_order_hold) - self.message_log(f"Small restored amount {_order['amount']} was added" - f" to last held order {_order_hold[0]}", tlg=True) - else: - self.message_log("Too small restore for trade and not saved or held grid for update", tlg=True) + if _order := self.orders_save.get_by_id(order_id): + self.orders_save.remove(order_id) + if self.check_min_amount(amount=_order['amount'], price=_order['price']): + self.orders_hold.orders_list.append(_order) + elif self.orders_save: + _order_saved = list(self.orders_save.get_last()) + _order_saved[2] += _order['amount'] + self.orders_save.remove(_order_saved[0]) + self.orders_save.append_order(*_order_saved) + self.message_log(f"Small restored amount {_order['amount']} was added" + f" to last saved order {_order_saved[0]}", tlg=True) + elif self.orders_hold: + _order_hold = list(self.orders_hold.get_last()) + _order_hold[2] += _order['amount'] + self.orders_hold.remove(_order_hold[0]) + self.orders_hold.append_order(*_order_hold) + self.message_log(f"Small restored amount {_order['amount']} was added" + f" to last held order {_order_hold[0]}", tlg=True) + else: + self.message_log("Too small restore for trade and not saved or held grid for update", tlg=True) if not self.orders_save: self.restore_orders = False self.orders_hold.sort(self.cycle_buy)