Fixed parameter check which failed when 0.0 was passed

This commit is contained in:
Arunavo Ray 2021-09-19 12:36:01 +05:30 committed by Sam Germain
parent d26a068adf
commit 447312d4c8
2 changed files with 12 additions and 8 deletions

View File

@ -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 "
@ -187,3 +185,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))

View File

@ -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,