Don't modify leverage through DCA
This commit is contained in:
parent
536f54cfc6
commit
1b6548c8d8
@ -643,7 +643,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
|
|
||||||
if not stake_amount:
|
if not stake_amount:
|
||||||
return False
|
return False
|
||||||
|
if not pos_adjust:
|
||||||
max_leverage = self.exchange.get_max_leverage(pair, stake_amount)
|
max_leverage = self.exchange.get_max_leverage(pair, stake_amount)
|
||||||
leverage = strategy_safe_wrapper(self.strategy.leverage, default_retval=1.0)(
|
leverage = strategy_safe_wrapper(self.strategy.leverage, default_retval=1.0)(
|
||||||
pair=pair,
|
pair=pair,
|
||||||
@ -655,6 +655,9 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
) if self.trading_mode != TradingMode.SPOT else 1.0
|
) if self.trading_mode != TradingMode.SPOT else 1.0
|
||||||
# Cap leverage between 1.0 and max_leverage.
|
# Cap leverage between 1.0 and max_leverage.
|
||||||
leverage = min(max(leverage, 1.0), max_leverage)
|
leverage = min(max(leverage, 1.0), max_leverage)
|
||||||
|
else:
|
||||||
|
# Changing leverage currently not possible
|
||||||
|
leverage = trade.leverage if trade else 1.0
|
||||||
if pos_adjust:
|
if pos_adjust:
|
||||||
logger.info(f"Position adjust: about to create a new order for {pair} with stake: "
|
logger.info(f"Position adjust: about to create a new order for {pair} with stake: "
|
||||||
f"{stake_amount} for {trade}")
|
f"{stake_amount} for {trade}")
|
||||||
|
@ -639,6 +639,7 @@ class Backtesting:
|
|||||||
# If not pos adjust, trade is None
|
# If not pos adjust, trade is None
|
||||||
return trade
|
return trade
|
||||||
|
|
||||||
|
if not pos_adjust:
|
||||||
max_leverage = self.exchange.get_max_leverage(pair, stake_amount)
|
max_leverage = self.exchange.get_max_leverage(pair, stake_amount)
|
||||||
leverage = strategy_safe_wrapper(self.strategy.leverage, default_retval=1.0)(
|
leverage = strategy_safe_wrapper(self.strategy.leverage, default_retval=1.0)(
|
||||||
pair=pair,
|
pair=pair,
|
||||||
@ -650,6 +651,8 @@ class Backtesting:
|
|||||||
) if self._can_short else 1.0
|
) if self._can_short else 1.0
|
||||||
# Cap leverage between 1.0 and max_leverage.
|
# Cap leverage between 1.0 and max_leverage.
|
||||||
leverage = min(max(leverage, 1.0), max_leverage)
|
leverage = min(max(leverage, 1.0), max_leverage)
|
||||||
|
else:
|
||||||
|
leverage = trade.leverage if trade else 1.0
|
||||||
|
|
||||||
order_type = self.strategy.order_types['buy']
|
order_type = self.strategy.order_types['buy']
|
||||||
time_in_force = self.strategy.order_time_in_force['buy']
|
time_in_force = self.strategy.order_time_in_force['buy']
|
||||||
|
@ -889,8 +889,7 @@ class LocalTrade():
|
|||||||
total_stake += tmp_price * tmp_amount
|
total_stake += tmp_price * tmp_amount
|
||||||
|
|
||||||
if total_amount > 0:
|
if total_amount > 0:
|
||||||
# TODO-lev: This should update leverage as well -
|
# Leverage not updated, as we don't allow changing leverage through DCA at the moment.
|
||||||
# as averaged trades might have different leverage
|
|
||||||
self.open_rate = total_stake / total_amount
|
self.open_rate = total_stake / total_amount
|
||||||
self.stake_amount = total_stake
|
self.stake_amount = total_stake
|
||||||
self.amount = total_amount
|
self.amount = total_amount
|
||||||
|
Loading…
Reference in New Issue
Block a user