From ef7f01d9e75a8e57f689004f267a0a509b18f80d Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Mon, 20 Sep 2021 21:44:00 -0600 Subject: [PATCH] added position and wallet_balance to LocalTrade.set_isolated_liq --- freqtrade/persistence/models.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index 4a1b394e9..6a91fc26d 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -347,12 +347,22 @@ class LocalTrade(): self.stop_loss_pct = -1 * abs(percent) self.stoploss_last_update = datetime.utcnow() - def set_isolated_liq(self, isolated_liq: Optional[float]): + def set_isolated_liq( + self, + isolated_liq: Optional[float], + wallet_balance: Optional[float], + current_price: Optional[float] + ): """ Method you should use to set self.liquidation price. Assures stop_loss is not passed the liquidation price """ if not isolated_liq: + if not wallet_balance or not current_price: + raise OperationalException( + "wallet balance must be passed to LocalTrade.set_isolated_liq when param" + "isolated_liq is None" + ) isolated_liq = liquidation_price( exchange_name=self.exchange, open_rate=self.open_rate, @@ -362,9 +372,9 @@ class LocalTrade(): collateral=Collateral.ISOLATED, mm_ex_1=0.0, upnl_ex_1=0.0, - # TODO-lev: position=amount * current_price, + position=self.amount * current_price, + wallet_balance=wallet_balance, # TODO-lev: maintenance_amt, - # TODO-lev: wallet_balance, # TODO-lev: mm_rate, )