mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Remove custom fetch_funding_fees from bybit
This commit is contained in:
parent
78cf8a1c09
commit
2069abe314
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user