Partially revert prior commit, use correct exchange class
This commit is contained in:
parent
eee2071e32
commit
71846ecbf2
@ -5023,7 +5023,7 @@ def test_get_liquidation_price1(mocker, default_conf):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('liquidation_buffer', [0.0, 0.05])
|
||||
@pytest.mark.parametrize('liquidation_buffer', [0.0, 0.05])
|
||||
@pytest.mark.parametrize(
|
||||
"is_short,trading_mode,exchange_name,margin_mode,leverage,open_rate,amount,expected_liq", [
|
||||
(False, 'spot', 'binance', '', 5.0, 10.0, 1.0, None),
|
||||
@ -5043,17 +5043,15 @@ def test_get_liquidation_price1(mocker, default_conf):
|
||||
(False, 'futures', 'binance', 'isolated', 3, 10, 1.0, 6.723905723905723),
|
||||
(False, 'futures', 'binance', 'isolated', 5, 10, 0.6, 8.063973063973064),
|
||||
# Gateio/okx, short
|
||||
(True, 'futures', 'gateio', 'isolated', 5, 10, 1.0, 11.89108910891089),
|
||||
(True, 'futures', 'gateio', 'isolated', 5, 10, 2.0, 11.886138613861386),
|
||||
(True, 'futures', 'gateio', 'isolated', 3, 10, 1.0, 13.211221122112212),
|
||||
(True, 'futures', 'gateio', 'isolated', 5, 8, 1.0, 9.514851485148514),
|
||||
(True, 'futures', 'gateio', 'isolated', 5, 10, 1.0, 11.87413417771621),
|
||||
(True, 'futures', 'gateio', 'isolated', 5, 10, 2.0, 11.87413417771621),
|
||||
(True, 'futures', 'gateio', 'isolated', 3, 10, 1.0, 13.193482419684678),
|
||||
(True, 'futures', 'gateio', 'isolated', 5, 8, 1.0, 9.499307342172967),
|
||||
(True, 'futures', 'okx', 'isolated', 3, 10, 1.0, 13.193482419684678),
|
||||
# Gateio/okx, long
|
||||
(False, 'futures', 'gateio', 'isolated', 5.0, 10.0, 1.0, 8.070707070707071),
|
||||
(False, 'futures', 'gateio', 'isolated', 3.0, 10.0, 1.0, 6.723905723905723),
|
||||
(True, 'futures', 'okx', 'isolated', 5, 8, 1.0, 9.514851485148514),
|
||||
(False, 'futures', 'okx', 'isolated', 3.0, 10.0, 1.0, 6.723905723905723),
|
||||
# (True, 'futures', 'okx', 'isolated', 11.87413417771621),
|
||||
# (False, 'futures', 'okx', 'isolated', 8.085708510208207),
|
||||
(False, 'futures', 'gateio', 'isolated', 5.0, 10.0, 1.0, 8.085708510208207),
|
||||
(False, 'futures', 'gateio', 'isolated', 3.0, 10.0, 1.0, 6.738090425173506),
|
||||
(False, 'futures', 'okx', 'isolated', 3.0, 10.0, 1.0, 6.738090425173506),
|
||||
]
|
||||
)
|
||||
def test_get_liquidation_price(
|
||||
@ -5126,7 +5124,7 @@ def test_get_liquidation_price(
|
||||
default_conf_usdt['exchange']['name'] = exchange_name
|
||||
default_conf_usdt['margin_mode'] = margin_mode
|
||||
mocker.patch('freqtrade.exchange.Gateio.validate_ordertypes')
|
||||
exchange = get_patched_exchange(mocker, default_conf_usdt)
|
||||
exchange = get_patched_exchange(mocker, default_conf_usdt, id=exchange_name)
|
||||
|
||||
exchange.get_maintenance_ratio_and_amt = MagicMock(return_value=(0.01, 0.01))
|
||||
exchange.name = exchange_name
|
||||
@ -5137,8 +5135,8 @@ def test_get_liquidation_price(
|
||||
pair='ETH/USDT:USDT',
|
||||
open_rate=open_rate,
|
||||
amount=amount,
|
||||
stake_amount=(amount * open_rate) / leverage,
|
||||
wallet_balance=(amount * open_rate) / leverage,
|
||||
stake_amount=amount * open_rate / leverage,
|
||||
wallet_balance=amount * open_rate / leverage,
|
||||
# leverage=leverage,
|
||||
is_short=is_short,
|
||||
)
|
||||
@ -5147,7 +5145,7 @@ def test_get_liquidation_price(
|
||||
else:
|
||||
buffer_amount = liquidation_buffer * abs(open_rate - expected_liq)
|
||||
expected_liq = expected_liq - buffer_amount if is_short else expected_liq + buffer_amount
|
||||
assert pytest.approx(expected_liq) == liq
|
||||
assert isclose(expected_liq, liq)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('contract_size,order_amount', [
|
||||
|
Loading…
Reference in New Issue
Block a user