Handle funding_fee error in exchange class

This commit is contained in:
Matthias
2023-10-12 06:27:29 +02:00
parent bfe04464b4
commit 7344f20803
2 changed files with 17 additions and 12 deletions
+6 -3
View File
@@ -7,7 +7,7 @@ import ccxt
from freqtrade.constants import BuySell from freqtrade.constants import BuySell
from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode from freqtrade.enums import CandleType, MarginMode, PriceType, TradingMode
from freqtrade.exceptions import DDosProtection, OperationalException, TemporaryError from freqtrade.exceptions import DDosProtection, ExchangeError, OperationalException, TemporaryError
from freqtrade.exchange import Exchange from freqtrade.exchange import Exchange
from freqtrade.exchange.common import retrier from freqtrade.exchange.common import retrier
from freqtrade.util.datetime_helpers import dt_now, dt_ts from freqtrade.util.datetime_helpers import dt_now, dt_ts
@@ -202,8 +202,11 @@ class Bybit(Exchange):
""" """
# Bybit does not provide "applied" funding fees per position. # Bybit does not provide "applied" funding fees per position.
if self.trading_mode == TradingMode.FUTURES: if self.trading_mode == TradingMode.FUTURES:
return self._fetch_and_calculate_funding_fees( try:
pair, amount, is_short, open_date) return self._fetch_and_calculate_funding_fees(
pair, amount, is_short, open_date)
except ExchangeError:
logger.warning(f"Could not update funding fees for {pair}.")
return 0.0 return 0.0
def fetch_orders(self, pair: str, since: datetime, params: Optional[Dict] = None) -> List[Dict]: def fetch_orders(self, pair: str, since: datetime, params: Optional[Dict] = None) -> List[Dict]:
+11 -9
View File
@@ -2815,17 +2815,19 @@ class Exchange:
:param amount: Trade amount :param amount: Trade amount
:param open_date: Open date of the trade :param open_date: Open date of the trade
:return: funding fee since open_date :return: funding fee since open_date
:raises: ExchangeError if something goes wrong.
""" """
if self.trading_mode == TradingMode.FUTURES: if self.trading_mode == TradingMode.FUTURES:
if self._config['dry_run']: try:
funding_fees = self._fetch_and_calculate_funding_fees( if self._config['dry_run']:
pair, amount, is_short, open_date) funding_fees = self._fetch_and_calculate_funding_fees(
else: pair, amount, is_short, open_date)
funding_fees = self._get_funding_fees_from_exchange(pair, open_date) else:
return funding_fees funding_fees = self._get_funding_fees_from_exchange(pair, open_date)
else: return funding_fees
return 0.0 except ExchangeError:
logger.warning(f"Could not update funding fees for {pair}.")
return 0.0
def get_liquidation_price( def get_liquidation_price(
self, self,