mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Added retrier to exchange functions and reduced failing tests down to 2
This commit is contained in:
parent
aac1094078
commit
61fdf74ad9
|
@ -1521,10 +1521,23 @@ class Exchange:
|
|||
self._async_get_trade_history(pair=pair, since=since,
|
||||
until=until, from_id=from_id))
|
||||
|
||||
def get_interest_rate(self, pair: str, maker_or_taker: str, is_short: bool) -> float:
|
||||
@retrier
|
||||
def get_interest_rate(
|
||||
self,
|
||||
pair: str,
|
||||
maker_or_taker: str,
|
||||
is_short: bool
|
||||
) -> Tuple[float, float]:
|
||||
"""
|
||||
:param pair: base/quote currency pair
|
||||
:param maker_or_taker: "maker" if limit order, "taker" if market order
|
||||
:param is_short: True if requesting base interest, False if requesting quote interest
|
||||
:return: (open_interest, rollover_interest)
|
||||
"""
|
||||
# TODO-lev: implement
|
||||
return (0.0005, 0.0005)
|
||||
|
||||
@retrier
|
||||
def fill_leverage_brackets(self):
|
||||
"""
|
||||
#TODO-lev: Should maybe be renamed, leverage_brackets might not be accurate for kraken
|
||||
|
@ -1543,6 +1556,7 @@ class Exchange:
|
|||
raise OperationalException(
|
||||
f"{self.name.capitalize()}.get_max_leverage has not been implemented.")
|
||||
|
||||
@retrier
|
||||
def set_leverage(self, leverage: float, pair: Optional[str]):
|
||||
"""
|
||||
Set's the leverage before making a trade, in order to not
|
||||
|
@ -1558,7 +1572,8 @@ class Exchange:
|
|||
except ccxt.BaseError as e:
|
||||
raise OperationalException(e) from e
|
||||
|
||||
def set_margin_mode(self, symbol: str, collateral: Collateral, params: dict = {}):
|
||||
@retrier
|
||||
def set_margin_mode(self, pair: str, collateral: Collateral, params: dict = {}):
|
||||
'''
|
||||
Set's the margin mode on the exchange to cross or isolated for a specific pair
|
||||
:param symbol: base/quote currency pair (e.g. "ADA/USDT")
|
||||
|
@ -1568,7 +1583,7 @@ class Exchange:
|
|||
return
|
||||
|
||||
try:
|
||||
self._api.set_margin_mode(symbol, collateral.value, params)
|
||||
self._api.set_margin_mode(pair, collateral.value, params)
|
||||
except ccxt.DDoSProtection as e:
|
||||
raise DDosProtection(e) from e
|
||||
except (ccxt.NetworkError, ccxt.ExchangeError) as e:
|
||||
|
|
|
@ -149,7 +149,7 @@ def test_get_max_leverage_binance(default_conf, mocker, pair, nominal_value, max
|
|||
|
||||
def test_fill_leverage_brackets_binance(default_conf, mocker):
|
||||
api_mock = MagicMock()
|
||||
api_mock.load_leverage_brackets = MagicMock(return_value={{
|
||||
api_mock.load_leverage_brackets = MagicMock(return_value={
|
||||
'ADA/BUSD': [[0.0, '0.025'],
|
||||
[100000.0, '0.05'],
|
||||
[500000.0, '0.1'],
|
||||
|
@ -173,7 +173,7 @@ def test_fill_leverage_brackets_binance(default_conf, mocker):
|
|||
[250000.0, '0.125'],
|
||||
[1000000.0, '0.5']],
|
||||
|
||||
}})
|
||||
})
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="binance")
|
||||
|
||||
assert exchange._leverage_brackets == {
|
||||
|
|
|
@ -2998,8 +2998,8 @@ def test_set_leverage(mocker, default_conf, exchange_name, collateral):
|
|||
exchange_name,
|
||||
"set_leverage",
|
||||
"set_leverage",
|
||||
symbol="XRP/USDT",
|
||||
collateral=collateral
|
||||
pair="XRP/USDT",
|
||||
leverage=5.0
|
||||
)
|
||||
|
||||
|
||||
|
@ -3021,6 +3021,6 @@ def test_set_margin_mode(mocker, default_conf, exchange_name, collateral):
|
|||
exchange_name,
|
||||
"set_margin_mode",
|
||||
"set_margin_mode",
|
||||
symbol="XRP/USDT",
|
||||
pair="XRP/USDT",
|
||||
collateral=collateral
|
||||
)
|
||||
|
|
|
@ -274,7 +274,7 @@ def test_get_max_leverage_kraken(default_conf, mocker, pair, nominal_value, max_
|
|||
|
||||
def test_fill_leverage_brackets_kraken(default_conf, mocker):
|
||||
api_mock = MagicMock()
|
||||
api_mock.load_markets = MagicMock(return_value={{
|
||||
api_mock.load_markets = MagicMock(return_value={
|
||||
"ADA/BTC": {'active': True,
|
||||
'altname': 'ADAXBT',
|
||||
'base': 'ADA',
|
||||
|
@ -483,7 +483,7 @@ def test_fill_leverage_brackets_kraken(default_conf, mocker):
|
|||
[5000000, 0.0012],
|
||||
[10000000, 0.0001]]}}
|
||||
|
||||
}})
|
||||
})
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="kraken")
|
||||
|
||||
assert exchange._leverage_brackets == {
|
||||
|
|
Loading…
Reference in New Issue
Block a user