Flake8 conformant

This commit is contained in:
Arunavo Ray 2021-09-19 11:49:08 +05:30
parent e5a9e11899
commit c648b17308
2 changed files with 28 additions and 26 deletions

View File

@ -29,16 +29,17 @@ def liquidation_price(
)
if exchange_name.lower() == "binance":
if not wallet_balance or not maintenance_margin_ex_1 or not unrealized_pnl_ex_1 or not maintenance_amount \
or not position_1 or not entry_price_1 or not maintenance_margin_rate:
if not wallet_balance or not maintenance_margin_ex_1 or not unrealized_pnl_ex_1 \
or not maintenance_amount or not position_1 or not entry_price_1 \
or not maintenance_margin_rate:
raise OperationalException(
f"Parameters wallet_balance, maintenance_margin_ex_1, unrealized_pnl_ex_1, maintenance_amount, "
f"position_1, entry_price_1, maintenance_margin_rate is required by liquidation_price "
f"when exchange is {exchange_name.lower()}")
f"Parameters wallet_balance, maintenance_margin_ex_1, unrealized_pnl_ex_1, "
f"maintenance_amount, position_1, entry_price_1, maintenance_margin_rate "
f"is required by liquidation_price when exchange is {exchange_name.lower()}")
return binance(open_rate, is_short, leverage, trading_mode, collateral, wallet_balance, maintenance_margin_ex_1,
unrealized_pnl_ex_1, maintenance_amount, position_1, entry_price_1,
maintenance_margin_rate)
return binance(open_rate, is_short, leverage, trading_mode, collateral, wallet_balance,
maintenance_margin_ex_1, unrealized_pnl_ex_1, maintenance_amount,
position_1, entry_price_1, maintenance_margin_rate)
elif exchange_name.lower() == "kraken":
return kraken(open_rate, is_short, leverage, trading_mode, collateral)
elif exchange_name.lower() == "ftx":
@ -87,13 +88,13 @@ def binance(
:param collateral: cross, isolated
:param wallet_balance: Wallet Balance is crossWalletBalance in Cross-Margin Mode.
Wallet Balance is isolatedWalletBalance in Isolated Margin Mode
Wallet Balance is isolatedWalletBalance in Isolated Margin Mode
:param maintenance_margin_ex_1: Maintenance Margin of all other contracts, excluding Contract 1.
If it is an isolated margin mode, then TMM=0
:param maintenance_margin_ex_1: Maintenance Margin of all other contracts,
excluding Contract 1. If it is an isolated margin mode, then TMM=0
:param unrealized_pnl_ex_1: Unrealized PNL of all other contracts, excluding Contract 1.
If it is an isolated margin mode, then UPNL=0
If it is an isolated margin mode, then UPNL=0
:param maintenance_amount: Maintenance Amount of position (one-way mode)

View File

@ -7,22 +7,23 @@ from freqtrade.leverage import liquidation_price
@pytest.mark.parametrize(
'exchange_name, open_rate, is_short, leverage, trading_mode, collateral, wallet_balance, maintenance_margin_ex_1, '
'unrealized_pnl_ex_1, maintenance_amount, position_1, entry_price_1, maintenance_margin_rate, '
'expected',
'exchange_name, open_rate, is_short, leverage, trading_mode, collateral, wallet_balance, '
'maintenance_margin_ex_1, unrealized_pnl_ex_1, maintenance_amount, position_1, entry_price_1, '
'maintenance_margin_rate, expected',
[
("binance", 0.0, False, 1, TradingMode.FUTURES, Collateral.ISOLATED, 1535443.01, 71200.81144, -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.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, -448192.89, 16300.000,
109.488, 32481.980, 0.025, 26316.89)
("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.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,
-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,
maintenance_margin_ex_1, unrealized_pnl_ex_1, maintenance_amount, position_1,
entry_price_1, maintenance_margin_rate, expected):
def test_liquidation_price(exchange_name, open_rate, is_short, leverage, trading_mode, collateral,
wallet_balance, maintenance_margin_ex_1, unrealized_pnl_ex_1,
maintenance_amount, position_1, entry_price_1, maintenance_margin_rate,
expected):
assert isclose(round(liquidation_price(
exchange_name=exchange_name,
open_rate=open_rate,