From d0ab95e4e1194846d55473f5bc9b4af73459be67 Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Sun, 19 Sep 2021 12:36:01 +0530 Subject: [PATCH] Fixed parameter check which failed when 0.0 was passed --- freqtrade/leverage/liquidation_price.py | 12 ++++++++---- tests/leverage/test_liquidation_price.py | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/freqtrade/leverage/liquidation_price.py b/freqtrade/leverage/liquidation_price.py index 2b94f5d34..2d75ebd6d 100644 --- a/freqtrade/leverage/liquidation_price.py +++ b/freqtrade/leverage/liquidation_price.py @@ -19,7 +19,6 @@ def liquidation_price( entry_price: Optional[float], mm_rate: Optional[float] ) -> Optional[float]: - if trading_mode == TradingMode.SPOT: return None @@ -30,9 +29,8 @@ def liquidation_price( ) if exchange_name.lower() == "binance": - if not wallet_balance or not mm_ex_1 or not upnl_ex_1 \ - or not maintenance_amt or not position or not entry_price \ - or not mm_rate: + if None in [wallet_balance, mm_ex_1, upnl_ex_1, maintenance_amt, position, entry_price, + mm_rate]: raise OperationalException( f"Parameters wallet_balance, mm_ex_1, upnl_ex_1, " f"maintenance_amt, position, entry_price, mm_rate " @@ -190,3 +188,9 @@ def ftx( # If nothing was returned exception("ftx", trading_mode, collateral) + + +if __name__ == '__main__': + print(liquidation_price("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, + 1535443.01, 356512.508, + 0.0, 16300.000, 109.488, 32481.980, 0.025)) diff --git a/tests/leverage/test_liquidation_price.py b/tests/leverage/test_liquidation_price.py index a3f014bb4..e1fba4c4f 100644 --- a/tests/leverage/test_liquidation_price.py +++ b/tests/leverage/test_liquidation_price.py @@ -93,10 +93,10 @@ def test_liquidation_price_exception_thrown( 'mm_ex_1, upnl_ex_1, maintenance_amt, position, entry_price, ' 'mm_rate, expected', [ - ("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 71200.8114, - -56354.57, 135365.00, 3683.979, 1456.84, 0.10, 1114.78), - ("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 356512.508, - -448192.89, 16300.000, 109.488, 32481.980, 0.025, 18778.73), + ("binance", 0.0, 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, + 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, -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,