fixed tests

This commit is contained in:
Sam Germain 2022-02-14 17:34:59 -06:00
parent f4a57b71e7
commit 3753df26fc
5 changed files with 13 additions and 8 deletions

View File

@ -31,7 +31,7 @@ class Gateio(Exchange):
# TradingMode.SPOT always supported and not required in this list # TradingMode.SPOT always supported and not required in this list
# (TradingMode.MARGIN, MarginMode.CROSS), # (TradingMode.MARGIN, MarginMode.CROSS),
# (TradingMode.FUTURES, MarginMode.CROSS), # (TradingMode.FUTURES, MarginMode.CROSS),
(TradingMode.FUTURES, MarginMode.ISOLATED) # (TradingMode.FUTURES, MarginMode.ISOLATED)
] ]
def validate_ordertypes(self, order_types: Dict) -> None: def validate_ordertypes(self, order_types: Dict) -> None:

View File

@ -65,6 +65,7 @@ class Okx(Exchange):
return pair_tiers[-1]['max'] / leverage return pair_tiers[-1]['max'] / leverage
def load_leverage_tiers(self) -> Dict[str, List[Dict]]: def load_leverage_tiers(self) -> Dict[str, List[Dict]]:
# * This is slow(~45s) on Okex, must make 90-some api calls to load all linear swap markets
if self.trading_mode == TradingMode.FUTURES: if self.trading_mode == TradingMode.FUTURES:
markets = self.markets markets = self.markets
symbols = [] symbols = []
@ -74,11 +75,13 @@ class Okx(Exchange):
and market['quote'] == self._config['stake_currency']): and market['quote'] == self._config['stake_currency']):
symbols.append(symbol) symbols.append(symbol)
tiers = {} tiers: Dict[str, List[Dict]] = {}
for symbol in symbols: for symbol in symbols:
res = self._api.fetchLeverageTiers(symbol) res = self._api.fetchLeverageTiers(symbol)
res_symbol = res[symbol] tiers[symbol] = []
tiers[symbol] = self.parse_leverage_tier(res[symbol]) for tier in res[symbol]:
tiers[symbol].append(self.parse_leverage_tier(tier))
return tiers return tiers
else: else:

View File

@ -151,7 +151,6 @@ def test_stoploss_order_dry_run_binance(default_conf, mocker):
def test_stoploss_adjust_binance( def test_stoploss_adjust_binance(
mocker, mocker,
default_conf, default_conf,
leverage_tiers,
sl1, sl1,
sl2, sl2,
sl3, sl3,

View File

@ -689,7 +689,7 @@ def test_validate_stakecurrency_error(default_conf, mocker, caplog):
def test_get_quote_currencies(default_conf, mocker): def test_get_quote_currencies(default_conf, mocker):
ex = get_patched_exchange(mocker, default_conf) ex = get_patched_exchange(mocker, default_conf)
assert set(ex.get_quote_currencies()) == set(['USD', 'ETH', 'BTC', 'USDT']) assert set(ex.get_quote_currencies()) == set(['USD', 'ETH', 'BTC', 'USDT', 'BUSD'])
@pytest.mark.parametrize('pair,expected', [ @pytest.mark.parametrize('pair,expected', [
@ -3233,6 +3233,7 @@ def test_market_is_tradable(
'future': futures, 'future': futures,
'swap': futures, 'swap': futures,
'margin': margin, 'margin': margin,
'linear': True,
**(add_dict), **(add_dict),
} }
assert ex.market_is_tradable(market) == expected_result assert ex.market_is_tradable(market) == expected_result
@ -3497,10 +3498,11 @@ def test_set_margin_mode(mocker, default_conf, margin_mode):
("okx", TradingMode.FUTURES, MarginMode.CROSS, True), ("okx", TradingMode.FUTURES, MarginMode.CROSS, True),
("binance", TradingMode.FUTURES, MarginMode.ISOLATED, False), ("binance", TradingMode.FUTURES, MarginMode.ISOLATED, False),
("gateio", TradingMode.FUTURES, MarginMode.ISOLATED, False), # ("gateio", TradingMode.FUTURES, MarginMode.ISOLATED, False),
("okx", TradingMode.FUTURES, MarginMode.ISOLATED, False), ("okx", TradingMode.FUTURES, MarginMode.ISOLATED, False),
# * Remove once implemented # * Remove once implemented
("gateio", TradingMode.FUTURES, MarginMode.ISOLATED, True),
("binance", TradingMode.MARGIN, MarginMode.CROSS, True), ("binance", TradingMode.MARGIN, MarginMode.CROSS, True),
("binance", TradingMode.FUTURES, MarginMode.CROSS, True), ("binance", TradingMode.FUTURES, MarginMode.CROSS, True),
("kraken", TradingMode.MARGIN, MarginMode.CROSS, True), ("kraken", TradingMode.MARGIN, MarginMode.CROSS, True),
@ -4351,6 +4353,7 @@ def test_get_maintenance_ratio_and_amt(
default_conf['margin_mode'] = 'isolated' default_conf['margin_mode'] = 'isolated'
mocker.patch('freqtrade.exchange.Exchange.exchange_has', return_value=True) mocker.patch('freqtrade.exchange.Exchange.exchange_has', return_value=True)
exchange = get_patched_exchange(mocker, default_conf, api_mock) exchange = get_patched_exchange(mocker, default_conf, api_mock)
exchange._leverage_tiers = leverage_tiers
exchange.get_maintenance_ratio_and_amt(pair, value) == (mmr, maintAmt) exchange.get_maintenance_ratio_and_amt(pair, value) == (mmr, maintAmt)

View File

@ -1,7 +1,7 @@
from unittest.mock import MagicMock # , PropertyMock from unittest.mock import MagicMock # , PropertyMock
from freqtrade.enums import MarginMode, TradingMode
from tests.conftest import get_patched_exchange from tests.conftest import get_patched_exchange
from freqtrade.enums import TradingMode, MarginMode
def test_get_maintenance_ratio_and_amt_okx( def test_get_maintenance_ratio_and_amt_okx(