Added parameters explicitly to liquidation_price functions
This commit is contained in:
@@ -14,7 +14,7 @@ from sqlalchemy.pool import StaticPool
|
||||
from sqlalchemy.sql.schema import UniqueConstraint
|
||||
|
||||
from freqtrade.constants import DATETIME_PRINT_FORMAT
|
||||
from freqtrade.enums import SellType
|
||||
from freqtrade.enums import Collateral, SellType, TradingMode
|
||||
from freqtrade.exceptions import DependencyException, OperationalException
|
||||
from freqtrade.leverage import interest, liquidation_price
|
||||
from freqtrade.misc import safe_value_fallback
|
||||
@@ -265,6 +265,8 @@ class LocalTrade():
|
||||
buy_tag: Optional[str] = None
|
||||
timeframe: Optional[int] = None
|
||||
|
||||
trading_mode: TradingMode
|
||||
|
||||
# Leverage trading properties
|
||||
is_short: bool = False
|
||||
isolated_liq: Optional[float] = None
|
||||
@@ -344,17 +346,23 @@ class LocalTrade():
|
||||
self.stop_loss_pct = -1 * abs(percent)
|
||||
self.stoploss_last_update = datetime.utcnow()
|
||||
|
||||
def set_isolated_liq(self, **k):
|
||||
def set_isolated_liq(self, isolated_liq: Optional[float]):
|
||||
"""
|
||||
Method you should use to set self.liquidation price.
|
||||
Assures stop_loss is not passed the liquidation price
|
||||
"""
|
||||
if k['isolated_liq']:
|
||||
isolated_liq: float = k['isolated_liq']
|
||||
else:
|
||||
isolated_liq: float = liquidation_price(
|
||||
exchange=self.exchange_name,
|
||||
**k
|
||||
if not isolated_liq:
|
||||
isolated_liq = liquidation_price(
|
||||
exchange_name=self.exchange,
|
||||
open_rate=self.open_rate,
|
||||
is_short=self.is_short,
|
||||
leverage=self.leverage,
|
||||
trading_mode=self.trading_mode,
|
||||
collateral=Collateral.ISOLATED
|
||||
)
|
||||
if isolated_liq is None:
|
||||
raise OperationalException(
|
||||
"leverage/isolated_liq returned None. This exception should never happen"
|
||||
)
|
||||
|
||||
if self.stop_loss is not None:
|
||||
|
Reference in New Issue
Block a user