|
|
@@ -870,11 +870,18 @@ class Strategy(Strategy):
|
|
|
|
|
|
if desired_sides == {"buy", "sell"}:
|
|
|
current_sides = {str(order.get("side") or "").lower() for order in live_orders if isinstance(order, dict)}
|
|
|
+ tracked_sides = {str(order.get("side") or "").lower() for order in previous_orders if isinstance(order, dict)}
|
|
|
missing_sides = [side for side in ("buy", "sell") if side not in current_sides]
|
|
|
reconciled_sides: list[str] = []
|
|
|
- if missing_sides and self.state.get("center_price") and not self._grid_refresh_paused():
|
|
|
+ has_live_grid = bool(live_orders) or bool(live_ids) or bool(tracked_sides)
|
|
|
+
|
|
|
+ # If the grid is empty because both sides were skipped, do not keep
|
|
|
+ # trying to "restore" a missing side every tick. Let the normal
|
|
|
+ # reseed path decide when to try again.
|
|
|
+ if missing_sides and has_live_grid and self.state.get("center_price") and not self._grid_refresh_paused():
|
|
|
for side in missing_sides:
|
|
|
- self._log(f"adding missing {side} side after trade_sides change, live_sides={sorted(current_sides)} live_ids={live_ids}")
|
|
|
+ if current_sides or tracked_sides:
|
|
|
+ self._log(f"adding missing {side} side, live_sides={sorted(current_sides)} tracked_sides={sorted(tracked_sides)} live_ids={live_ids}")
|
|
|
self._place_side_grid(side, float(self.state.get("center_price") or price))
|
|
|
reconciled_sides.append(side)
|
|
|
live_orders = self._sync_open_orders_state()
|