From 678be0b773c2606b1613d8b7d00ca89512b5ef1e Mon Sep 17 00:00:00 2001 From: Reigo Reinmets Date: Thu, 13 Jan 2022 20:16:45 +0200 Subject: [PATCH] Slightly move code. --- freqtrade/optimize/backtesting.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 04fa8854f..ced716d18 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -460,13 +460,6 @@ class Backtesting: def _enter_trade(self, pair: str, row: Tuple, stake_amount: Optional[float] = None, trade: Optional[LocalTrade] = None) -> Optional[LocalTrade]: - pos_adjust = trade is not None - if stake_amount is None: - try: - stake_amount = self.wallets.get_trade_stake_amount(pair, None) - except DependencyException: - return trade - # let's call the custom entry price, using the open price as default price propose_rate = strategy_safe_wrapper(self.strategy.custom_entry_price, default_retval=row[OPEN_IDX])( @@ -479,6 +472,13 @@ class Backtesting: min_stake_amount = self.exchange.get_min_pair_stake_amount(pair, propose_rate, -0.05) or 0 max_stake_amount = self.wallets.get_available_stake_amount() + pos_adjust = trade is not None + if stake_amount is None: + try: + stake_amount = self.wallets.get_trade_stake_amount(pair, None) + except DependencyException: + return trade + if not pos_adjust: stake_amount = strategy_safe_wrapper(self.strategy.custom_stake_amount, default_retval=stake_amount)(