Fixed parameter check which failed when 0.0 was passed
This commit is contained in:
parent
d26a068adf
commit
447312d4c8
@ -19,7 +19,6 @@ def liquidation_price(
|
|||||||
entry_price: Optional[float],
|
entry_price: Optional[float],
|
||||||
mm_rate: Optional[float]
|
mm_rate: Optional[float]
|
||||||
) -> Optional[float]:
|
) -> Optional[float]:
|
||||||
|
|
||||||
if trading_mode == TradingMode.SPOT:
|
if trading_mode == TradingMode.SPOT:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -30,9 +29,8 @@ def liquidation_price(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if exchange_name.lower() == "binance":
|
if exchange_name.lower() == "binance":
|
||||||
if not wallet_balance or not mm_ex_1 or not upnl_ex_1 \
|
if None in [wallet_balance, mm_ex_1, upnl_ex_1, maintenance_amt, position, entry_price,
|
||||||
or not maintenance_amt or not position or not entry_price \
|
mm_rate]:
|
||||||
or not mm_rate:
|
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
f"Parameters wallet_balance, mm_ex_1, upnl_ex_1, "
|
f"Parameters wallet_balance, mm_ex_1, upnl_ex_1, "
|
||||||
f"maintenance_amt, position, entry_price, mm_rate "
|
f"maintenance_amt, position, entry_price, mm_rate "
|
||||||
@ -187,3 +185,9 @@ def ftx(
|
|||||||
|
|
||||||
# If nothing was returned
|
# If nothing was returned
|
||||||
exception("ftx", trading_mode, collateral)
|
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))
|
||||||
|
@ -93,10 +93,10 @@ def test_liquidation_price_exception_thrown(
|
|||||||
'mm_ex_1, upnl_ex_1, maintenance_amt, position, entry_price, '
|
'mm_ex_1, upnl_ex_1, maintenance_amt, position, entry_price, '
|
||||||
'mm_rate, expected',
|
'mm_rate, expected',
|
||||||
[
|
[
|
||||||
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 71200.8114,
|
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 0.0,
|
||||||
-56354.57, 135365.00, 3683.979, 1456.84, 0.10, 1114.78),
|
0.0, 135365.00, 3683.979, 1456.84, 0.10, 1114.78),
|
||||||
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 356512.508,
|
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 0.0,
|
||||||
-448192.89, 16300.000, 109.488, 32481.980, 0.025, 18778.73),
|
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", 0.0, False, 1, TradingMode.FUTURES, Collateral.CROSS, 1535443.01, 71200.81144,
|
||||||
-56354.57, 135365.00, 3683.979, 1456.84, 0.10, 1153.26),
|
-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", 0.0, False, 1, TradingMode.FUTURES, Collateral.CROSS, 1535443.01, 356512.508,
|
||||||
|
Loading…
Reference in New Issue
Block a user