mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
refactor: move test_liquidation_price_binance to binance test file
This commit is contained in:
@@ -170,6 +170,111 @@ def test_stoploss_adjust_binance(mocker, default_conf, sl1, sl2, sl3, side):
|
||||
assert not exchange.stoploss_adjust(sl2, order, side=side)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"exchange_name, is_short, trading_mode, margin_mode, wallet_balance, "
|
||||
"mm_ex_1, upnl_ex_1, maintenance_amt, amount, open_rate, "
|
||||
"mm_ratio, expected",
|
||||
[
|
||||
(
|
||||
"binance",
|
||||
False,
|
||||
"futures",
|
||||
"isolated",
|
||||
1535443.01,
|
||||
0.0,
|
||||
0.0,
|
||||
135365.00,
|
||||
3683.979,
|
||||
1456.84,
|
||||
0.10,
|
||||
1114.78,
|
||||
),
|
||||
(
|
||||
"binance",
|
||||
False,
|
||||
"futures",
|
||||
"isolated",
|
||||
1535443.01,
|
||||
0.0,
|
||||
0.0,
|
||||
16300.000,
|
||||
109.488,
|
||||
32481.980,
|
||||
0.025,
|
||||
18778.73,
|
||||
),
|
||||
(
|
||||
"binance",
|
||||
False,
|
||||
"futures",
|
||||
"cross",
|
||||
1535443.01,
|
||||
71200.81144,
|
||||
-56354.57,
|
||||
135365.00,
|
||||
3683.979,
|
||||
1456.84,
|
||||
0.10,
|
||||
1153.26,
|
||||
),
|
||||
(
|
||||
"binance",
|
||||
False,
|
||||
"futures",
|
||||
"cross",
|
||||
1535443.01,
|
||||
356512.508,
|
||||
-448192.89,
|
||||
16300.000,
|
||||
109.488,
|
||||
32481.980,
|
||||
0.025,
|
||||
26316.89,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_liquidation_price_binance(
|
||||
mocker,
|
||||
default_conf,
|
||||
exchange_name,
|
||||
open_rate,
|
||||
is_short,
|
||||
trading_mode,
|
||||
margin_mode,
|
||||
wallet_balance,
|
||||
mm_ex_1,
|
||||
upnl_ex_1,
|
||||
maintenance_amt,
|
||||
amount,
|
||||
mm_ratio,
|
||||
expected,
|
||||
):
|
||||
default_conf["trading_mode"] = trading_mode
|
||||
default_conf["margin_mode"] = margin_mode
|
||||
default_conf["liquidation_buffer"] = 0.0
|
||||
exchange = get_patched_exchange(mocker, default_conf, exchange=exchange_name)
|
||||
exchange.get_maintenance_ratio_and_amt = MagicMock(return_value=(mm_ratio, maintenance_amt))
|
||||
assert (
|
||||
pytest.approx(
|
||||
round(
|
||||
exchange.get_liquidation_price(
|
||||
pair="DOGE/USDT",
|
||||
open_rate=open_rate,
|
||||
is_short=is_short,
|
||||
wallet_balance=wallet_balance,
|
||||
mm_ex_1=mm_ex_1,
|
||||
upnl_ex_1=upnl_ex_1,
|
||||
amount=amount,
|
||||
stake_amount=open_rate * amount,
|
||||
leverage=5,
|
||||
),
|
||||
2,
|
||||
)
|
||||
)
|
||||
== expected
|
||||
)
|
||||
|
||||
|
||||
def test_fill_leverage_tiers_binance(default_conf, mocker):
|
||||
api_mock = MagicMock()
|
||||
api_mock.fetch_leverage_tiers = MagicMock(
|
||||
|
||||
@@ -5667,111 +5667,6 @@ def test_liquidation_price_is_none(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"exchange_name, is_short, trading_mode, margin_mode, wallet_balance, "
|
||||
"mm_ex_1, upnl_ex_1, maintenance_amt, amount, open_rate, "
|
||||
"mm_ratio, expected",
|
||||
[
|
||||
(
|
||||
"binance",
|
||||
False,
|
||||
"futures",
|
||||
"isolated",
|
||||
1535443.01,
|
||||
0.0,
|
||||
0.0,
|
||||
135365.00,
|
||||
3683.979,
|
||||
1456.84,
|
||||
0.10,
|
||||
1114.78,
|
||||
),
|
||||
(
|
||||
"binance",
|
||||
False,
|
||||
"futures",
|
||||
"isolated",
|
||||
1535443.01,
|
||||
0.0,
|
||||
0.0,
|
||||
16300.000,
|
||||
109.488,
|
||||
32481.980,
|
||||
0.025,
|
||||
18778.73,
|
||||
),
|
||||
(
|
||||
"binance",
|
||||
False,
|
||||
"futures",
|
||||
"cross",
|
||||
1535443.01,
|
||||
71200.81144,
|
||||
-56354.57,
|
||||
135365.00,
|
||||
3683.979,
|
||||
1456.84,
|
||||
0.10,
|
||||
1153.26,
|
||||
),
|
||||
(
|
||||
"binance",
|
||||
False,
|
||||
"futures",
|
||||
"cross",
|
||||
1535443.01,
|
||||
356512.508,
|
||||
-448192.89,
|
||||
16300.000,
|
||||
109.488,
|
||||
32481.980,
|
||||
0.025,
|
||||
26316.89,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_liquidation_price_binance(
|
||||
mocker,
|
||||
default_conf,
|
||||
exchange_name,
|
||||
open_rate,
|
||||
is_short,
|
||||
trading_mode,
|
||||
margin_mode,
|
||||
wallet_balance,
|
||||
mm_ex_1,
|
||||
upnl_ex_1,
|
||||
maintenance_amt,
|
||||
amount,
|
||||
mm_ratio,
|
||||
expected,
|
||||
):
|
||||
default_conf["trading_mode"] = trading_mode
|
||||
default_conf["margin_mode"] = margin_mode
|
||||
default_conf["liquidation_buffer"] = 0.0
|
||||
exchange = get_patched_exchange(mocker, default_conf, exchange=exchange_name)
|
||||
exchange.get_maintenance_ratio_and_amt = MagicMock(return_value=(mm_ratio, maintenance_amt))
|
||||
assert (
|
||||
pytest.approx(
|
||||
round(
|
||||
exchange.get_liquidation_price(
|
||||
pair="DOGE/USDT",
|
||||
open_rate=open_rate,
|
||||
is_short=is_short,
|
||||
wallet_balance=wallet_balance,
|
||||
mm_ex_1=mm_ex_1,
|
||||
upnl_ex_1=upnl_ex_1,
|
||||
amount=amount,
|
||||
stake_amount=open_rate * amount,
|
||||
leverage=5,
|
||||
),
|
||||
2,
|
||||
)
|
||||
)
|
||||
== expected
|
||||
)
|
||||
|
||||
|
||||
def test_get_max_pair_stake_amount(
|
||||
mocker,
|
||||
default_conf,
|
||||
|
||||
Reference in New Issue
Block a user