Simplify leverage_prep interface
This commit is contained in:
parent
8e2d3445a7
commit
1d27cbd01f
@ -695,17 +695,12 @@ class Backtesting:
|
|||||||
trading_mode=self.trading_mode,
|
trading_mode=self.trading_mode,
|
||||||
leverage=leverage,
|
leverage=leverage,
|
||||||
interest_rate=interest_rate,
|
interest_rate=interest_rate,
|
||||||
isolated_liq=isolated_liq,
|
|
||||||
orders=[],
|
orders=[],
|
||||||
)
|
)
|
||||||
|
|
||||||
trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True)
|
trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True)
|
||||||
|
|
||||||
if self.trading_mode == TradingMode.FUTURES:
|
if self.trading_mode == TradingMode.FUTURES:
|
||||||
if isolated_liq is None:
|
|
||||||
raise OperationalException(
|
|
||||||
f'isolated_liq is none for {pair} while trading futures, '
|
|
||||||
'this should never happen')
|
|
||||||
trade.set_isolated_liq(isolated_liq)
|
trade.set_isolated_liq(isolated_liq)
|
||||||
|
|
||||||
order = Order(
|
order = Order(
|
||||||
|
@ -425,11 +425,13 @@ class LocalTrade():
|
|||||||
self.stop_loss_pct = -1 * abs(percent)
|
self.stop_loss_pct = -1 * abs(percent)
|
||||||
self.stoploss_last_update = datetime.utcnow()
|
self.stoploss_last_update = datetime.utcnow()
|
||||||
|
|
||||||
def set_isolated_liq(self, isolated_liq: float):
|
def set_isolated_liq(self, isolated_liq: Optional[float]):
|
||||||
"""
|
"""
|
||||||
Method you should use to set self.liquidation price.
|
Method you should use to set self.liquidation price.
|
||||||
Assures stop_loss is not passed the liquidation price
|
Assures stop_loss is not passed the liquidation price
|
||||||
"""
|
"""
|
||||||
|
if not isolated_liq:
|
||||||
|
return
|
||||||
if self.stop_loss is not None:
|
if self.stop_loss is not None:
|
||||||
if self.is_short:
|
if self.is_short:
|
||||||
self.stop_loss = min(self.stop_loss, isolated_liq)
|
self.stop_loss = min(self.stop_loss, isolated_liq)
|
||||||
|
Loading…
Reference in New Issue
Block a user