Remove no longer needed method get_funding_rate_history
This commit is contained in:
parent
aabca85a5f
commit
a87d2d62bb
@ -1925,42 +1925,6 @@ class Exchange:
|
|||||||
else:
|
else:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
@retrier
|
|
||||||
def get_funding_rate_history(self, pair: str, since: int) -> Dict:
|
|
||||||
"""
|
|
||||||
:param pair: quote/base currency pair
|
|
||||||
:param since: timestamp in ms of the beginning time
|
|
||||||
:param end: timestamp in ms of the end time
|
|
||||||
"""
|
|
||||||
if not self.exchange_has("fetchFundingRateHistory"):
|
|
||||||
raise ExchangeError(
|
|
||||||
f"fetch_funding_rate_history is not available using {self.name}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# TODO-lev: Gateio has a max limit into the past of 333 days, okex has a limit of 3 months
|
|
||||||
try:
|
|
||||||
funding_history: Dict = {}
|
|
||||||
response = self._api.fetch_funding_rate_history(
|
|
||||||
pair,
|
|
||||||
limit=1000,
|
|
||||||
since=since
|
|
||||||
)
|
|
||||||
for fund in response:
|
|
||||||
d = datetime.fromtimestamp(int(fund['timestamp'] / 1000), timezone.utc)
|
|
||||||
# Round down to the nearest hour, in case of a delayed timestamp
|
|
||||||
# The millisecond timestamps can be delayed ~20ms
|
|
||||||
time = int(timeframe_to_prev_date('1h', d).timestamp() * 1000)
|
|
||||||
|
|
||||||
funding_history[time] = fund['fundingRate']
|
|
||||||
return funding_history
|
|
||||||
except ccxt.DDoSProtection as e:
|
|
||||||
raise DDosProtection(e) from e
|
|
||||||
except (ccxt.NetworkError, ccxt.ExchangeError) as e:
|
|
||||||
raise TemporaryError(
|
|
||||||
f'Could not set margin mode due to {e.__class__.__name__}. Message: {e}') from e
|
|
||||||
except ccxt.BaseError as e:
|
|
||||||
raise OperationalException(e) from e
|
|
||||||
|
|
||||||
|
|
||||||
def is_exchange_known_ccxt(exchange_name: str, ccxt_module: CcxtModuleType = None) -> bool:
|
def is_exchange_known_ccxt(exchange_name: str, ccxt_module: CcxtModuleType = None) -> bool:
|
||||||
return exchange_name in ccxt_exchanges(ccxt_module)
|
return exchange_name in ccxt_exchanges(ccxt_module)
|
||||||
|
@ -3445,44 +3445,6 @@ def test__get_mark_price_history(mocker, default_conf, mark_ohlcv):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_funding_rate_history(mocker, default_conf, funding_rate_history_hourly):
|
|
||||||
api_mock = MagicMock()
|
|
||||||
api_mock.fetch_funding_rate_history = MagicMock(return_value=funding_rate_history_hourly)
|
|
||||||
type(api_mock).has = PropertyMock(return_value={'fetchFundingRateHistory': True})
|
|
||||||
|
|
||||||
# mocker.patch('freqtrade.exchange.Exchange.get_funding_fees', lambda pair, since: y)
|
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock)
|
|
||||||
funding_rates = exchange.get_funding_rate_history('ADA/USDT', 1635580800001)
|
|
||||||
|
|
||||||
assert funding_rates == {
|
|
||||||
1630454400000: -0.000008,
|
|
||||||
1630458000000: -0.000004,
|
|
||||||
1630461600000: 0.000012,
|
|
||||||
1630465200000: -0.000003,
|
|
||||||
1630468800000: -0.000007,
|
|
||||||
1630472400000: 0.000003,
|
|
||||||
1630476000000: 0.000019,
|
|
||||||
1630479600000: 0.000003,
|
|
||||||
1630483200000: -0.000003,
|
|
||||||
1630486800000: 0,
|
|
||||||
1630490400000: 0.000013,
|
|
||||||
1630494000000: 0.000077,
|
|
||||||
1630497600000: 0.000072,
|
|
||||||
1630501200000: 0.000097,
|
|
||||||
}
|
|
||||||
|
|
||||||
ccxt_exceptionhandlers(
|
|
||||||
mocker,
|
|
||||||
default_conf,
|
|
||||||
api_mock,
|
|
||||||
"binance",
|
|
||||||
"get_funding_rate_history",
|
|
||||||
"fetch_funding_rate_history",
|
|
||||||
pair="ADA/USDT",
|
|
||||||
since=1630454400000
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('exchange,rate_start,rate_end,d1,d2,amount,expected_fees', [
|
@pytest.mark.parametrize('exchange,rate_start,rate_end,d1,d2,amount,expected_fees', [
|
||||||
('binance', 0, 2, "2021-09-01 00:00:00", "2021-09-01 08:00:00", 30.0, -0.0009140999999999999),
|
('binance', 0, 2, "2021-09-01 00:00:00", "2021-09-01 08:00:00", 30.0, -0.0009140999999999999),
|
||||||
('binance', 0, 2, "2021-09-01 00:00:15", "2021-09-01 08:00:00", 30.0, -0.0009140999999999999),
|
('binance', 0, 2, "2021-09-01 00:00:15", "2021-09-01 08:00:00", 30.0, -0.0009140999999999999),
|
||||||
|
Loading…
Reference in New Issue
Block a user