From 2069abe31411fa67ba330dd8b650d19eb03380a0 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 8 Aug 2023 20:54:58 +0200 Subject: [PATCH] Remove custom fetch_funding_fees from bybit --- freqtrade/exchange/bybit.py | 25 ------------------------- tests/exchange/test_bybit.py | 4 ---- 2 files changed, 29 deletions(-) diff --git a/freqtrade/exchange/bybit.py b/freqtrade/exchange/bybit.py index 5f3762453..626643d06 100644 --- a/freqtrade/exchange/bybit.py +++ b/freqtrade/exchange/bybit.py @@ -11,7 +11,6 @@ from freqtrade.enums.candletype import CandleType from freqtrade.exceptions import DDosProtection, OperationalException, TemporaryError from freqtrade.exchange import Exchange from freqtrade.exchange.common import retrier -from freqtrade.exchange.exchange_utils import timeframe_to_msecs logger = logging.getLogger(__name__) @@ -100,30 +99,6 @@ class Bybit(Exchange): return super().ohlcv_candle_limit(timeframe, candle_type, since_ms) - async def _fetch_funding_rate_history( - self, - pair: str, - timeframe: str, - limit: int, - since_ms: Optional[int] = None, - ) -> List[List]: - """ - Fetch funding rate history - Necessary workaround until https://github.com/ccxt/ccxt/issues/15990 is fixed. - """ - params = {} - if since_ms: - limit = self.ohlcv_candle_limit(timeframe, CandleType.FUNDING_RATE, since_ms) - until = since_ms + (timeframe_to_msecs(timeframe) * limit) - params.update({'until': until}) - # Funding rate - data = await self._api_async.fetch_funding_rate_history( - pair, since=since_ms, - params=params) - # Convert funding rate to candle pattern - data = [[x['timestamp'], x['fundingRate'], 0, 0, 0, 0] for x in data] - return data - def _lev_prep(self, pair: str, leverage: float, side: BuySell, accept_fail: bool = False): if self.trading_mode != TradingMode.SPOT: params = {'leverage': leverage} diff --git a/tests/exchange/test_bybit.py b/tests/exchange/test_bybit.py index d0d5114a1..7495f543b 100644 --- a/tests/exchange/test_bybit.py +++ b/tests/exchange/test_bybit.py @@ -3,7 +3,6 @@ from unittest.mock import MagicMock from freqtrade.enums.marginmode import MarginMode from freqtrade.enums.tradingmode import TradingMode -from freqtrade.exchange.exchange_utils import timeframe_to_msecs from tests.conftest import get_mock_coro, get_patched_exchange from tests.exchange.test_exchange import ccxt_exceptionhandlers @@ -37,12 +36,10 @@ async def test_bybit_fetch_funding_rate(default_conf, mocker): assert api_mock.fetch_funding_rate_history.call_count == 1 assert api_mock.fetch_funding_rate_history.call_args_list[0][0][0] == 'BTC/USDT:USDT' kwargs = api_mock.fetch_funding_rate_history.call_args_list[0][1] - assert kwargs['params'] == {} assert kwargs['since'] is None api_mock.fetch_funding_rate_history.reset_mock() since_ms = 1610000000000 - since_ms_end = since_ms + (timeframe_to_msecs('4h') * limit) # Test fetch_funding_rate_history (current data) await exchange._fetch_funding_rate_history( pair='BTC/USDT:USDT', @@ -54,7 +51,6 @@ async def test_bybit_fetch_funding_rate(default_conf, mocker): assert api_mock.fetch_funding_rate_history.call_count == 1 assert api_mock.fetch_funding_rate_history.call_args_list[0][0][0] == 'BTC/USDT:USDT' kwargs = api_mock.fetch_funding_rate_history.call_args_list[0][1] - assert kwargs['params'] == {'until': since_ms_end} assert kwargs['since'] == since_ms