From 718679452d82017a0a63195776f20d9cc65f0f8a Mon Sep 17 00:00:00 2001 From: m5l14i11 Date: Sun, 15 Sep 2024 20:45:32 +0300 Subject: [PATCH] upd --- exchange/_bybit.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/exchange/_bybit.py b/exchange/_bybit.py index 996ddf62..581529dd 100644 --- a/exchange/_bybit.py +++ b/exchange/_bybit.py @@ -238,9 +238,8 @@ def close_half_position(self, symbol: Symbol, side: PositionSide): @retry(max_retries=MAX_RETRIES, handled_exceptions=EXCEPTIONS) def fetch_position(self, symbol: Symbol, side: PositionSide): positions = self.connector.fetch_positions([symbol.name]) - side = str(side).lower() position = next( - iter([position for position in positions if position["side"] == side]), + (p for p in positions if p["side"] == str(side).lower()), None, ) @@ -263,9 +262,7 @@ def fetch_account_balance(self, currency: str): @cached(TTLCache(maxsize=300, ttl=120)) def fetch_future_symbols(self): - markets = self._fetch_futures_market() - symbols = [self._create_symbol(market) for market in markets] - return symbols + return [self._create_symbol(market) for market in self._fetch_futures_market()] def fetch_ohlcv( self, @@ -325,11 +322,9 @@ def _fetch_ohlcv(self, symbol, timeframe, start_time, current_limit): @retry(max_retries=MAX_RETRIES, handled_exceptions=EXCEPTIONS) def _fetch_futures_market(self): - markets = self.connector.fetch_markets() - return [ market_info - for market_info in markets + for market_info in self.connector.fetch_markets() if market_info["linear"] and market_info["type"] != "future" and market_info["settle"] == "USDT"