Isolated liq branch passes all tests and has the general structure that it is supposed to, but is patchy, and doesnt get the correct maintenance amt and maintenance margin rate yet
This commit is contained in:
@@ -3582,6 +3582,24 @@ def test_calculate_funding_fees(
|
||||
) == kraken_fee
|
||||
|
||||
|
||||
def test_get_liquidation_price(mocker, default_conf):
|
||||
|
||||
api_mock = MagicMock()
|
||||
api_mock.fetch_positions = MagicMock()
|
||||
type(api_mock).has = PropertyMock(return_value={'fetchPositions': True})
|
||||
default_conf['dry_run'] = False
|
||||
|
||||
ccxt_exceptionhandlers(
|
||||
mocker,
|
||||
default_conf,
|
||||
api_mock,
|
||||
"binance",
|
||||
"get_liquidation_price",
|
||||
"fetch_positions",
|
||||
pair="XRP/USDT"
|
||||
)
|
||||
|
||||
|
||||
@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:15", "2021-09-01 08:00:00", 30.0, -0.0009140999999999999),
|
||||
|
@@ -54,7 +54,6 @@ def test_liquidation_price_is_none(
|
||||
-56354.57,
|
||||
135365.00,
|
||||
3683.979,
|
||||
1456.84,
|
||||
0.10,
|
||||
) is None
|
||||
|
||||
@@ -89,23 +88,23 @@ def test_liquidation_price_exception_thrown(
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'exchange_name, open_rate, is_short, leverage, trading_mode, collateral, wallet_balance, '
|
||||
'mm_ex_1, upnl_ex_1, maintenance_amt, position, entry_price, '
|
||||
'exchange_name, is_short, leverage, trading_mode, collateral, wallet_balance, '
|
||||
'mm_ex_1, upnl_ex_1, maintenance_amt, position, open_rate, '
|
||||
'mm_rate, expected',
|
||||
[
|
||||
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 0.0,
|
||||
("binance", False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 0.0,
|
||||
0.0, 135365.00, 3683.979, 1456.84, 0.10, 1114.78),
|
||||
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 0.0,
|
||||
("binance", False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 0.0,
|
||||
0.0, 16300.000, 109.488, 32481.980, 0.025, 18778.73),
|
||||
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.CROSS, 1535443.01, 71200.81144,
|
||||
("binance", False, 1, TradingMode.FUTURES, Collateral.CROSS, 1535443.01, 71200.81144,
|
||||
-56354.57, 135365.00, 3683.979, 1456.84, 0.10, 1153.26),
|
||||
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.CROSS, 1535443.01, 356512.508,
|
||||
("binance", False, 1, TradingMode.FUTURES, Collateral.CROSS, 1535443.01, 356512.508,
|
||||
-448192.89, 16300.000, 109.488, 32481.980, 0.025, 26316.89)
|
||||
])
|
||||
def test_liquidation_price(exchange_name, open_rate, is_short, leverage, trading_mode, collateral,
|
||||
wallet_balance, mm_ex_1, upnl_ex_1,
|
||||
maintenance_amt, position, entry_price, mm_rate,
|
||||
expected):
|
||||
def test_liquidation_price(
|
||||
exchange_name, open_rate, is_short, leverage, trading_mode, collateral, wallet_balance,
|
||||
mm_ex_1, upnl_ex_1, maintenance_amt, position, mm_rate, expected
|
||||
):
|
||||
assert isclose(round(liquidation_price(
|
||||
exchange_name=exchange_name,
|
||||
open_rate=open_rate,
|
||||
@@ -118,6 +117,5 @@ def test_liquidation_price(exchange_name, open_rate, is_short, leverage, trading
|
||||
upnl_ex_1=upnl_ex_1,
|
||||
maintenance_amt=maintenance_amt,
|
||||
position=position,
|
||||
entry_price=entry_price,
|
||||
mm_rate=mm_rate
|
||||
), 2), expected)
|
||||
|
Reference in New Issue
Block a user