diff --git a/exchange/_bybit_ws.py b/exchange/_bybit_ws.py index 8af74bff..2e9275a4 100644 --- a/exchange/_bybit_ws.py +++ b/exchange/_bybit_ws.py @@ -52,8 +52,8 @@ async def _connect_to_websocket(self): self.ws = await websockets.connect( self.wss, open_timeout=None, - ping_interval=30, - ping_timeout=15, + ping_interval=18, + ping_timeout=10, close_timeout=None, ) diff --git a/risk/_actor.py b/risk/_actor.py index 6d66e7fb..dce7f04b 100644 --- a/risk/_actor.py +++ b/risk/_actor.py @@ -112,16 +112,11 @@ async def _handle_position_risk(self, event: NewMarketDataReceived): indexes = list(range(num_positions)) random.shuffle(indexes) - current_index = 0 - - for _ in range(num_positions): - shuffled_index = indexes[current_index] + for shuffled_index in indexes: processed_positions[shuffled_index] = await self._process_market( event, self._position[shuffled_index] ) - current_index = (current_index + 1) % num_positions - self._position = tuple(processed_positions) async def _trail_position(self, event: TrailEvent):