diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 9cfeedd75..8d5dc77d6 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -462,11 +462,11 @@ class Backtesting: def _enter_trade(self, pair: str, row: Tuple, stake_amount: Optional[float] = None, trade: Optional[LocalTrade] = None) -> Optional[LocalTrade]: - + current_time = row[DATE_IDX].to_pydatetime() # 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])( - pair=pair, current_time=row[DATE_IDX].to_pydatetime(), + pair=pair, current_time=current_time, proposed_rate=row[OPEN_IDX]) # default value is the open rate # Move rate to within the candle's low/high rate @@ -484,7 +484,7 @@ class Backtesting: stake_amount = strategy_safe_wrapper(self.strategy.custom_stake_amount, default_retval=stake_amount)( - pair=pair, current_time=row[DATE_IDX].to_pydatetime(), current_rate=propose_rate, + pair=pair, current_time=current_time, current_rate=propose_rate, proposed_stake=stake_amount, min_stake=min_stake_amount, max_stake=max_stake_amount) stake_amount = self.wallets.validate_stake_amount(pair, stake_amount, min_stake_amount) @@ -500,7 +500,7 @@ class Backtesting: if not pos_adjust: if not strategy_safe_wrapper(self.strategy.confirm_trade_entry, default_retval=True)( pair=pair, order_type=order_type, amount=stake_amount, rate=propose_rate, - time_in_force=time_in_force, current_time=row[DATE_IDX].to_pydatetime()): + time_in_force=time_in_force, current_time=current_time): return None if stake_amount and (not min_stake_amount or stake_amount > min_stake_amount): @@ -511,7 +511,7 @@ class Backtesting: trade = LocalTrade( pair=pair, open_rate=propose_rate, - open_date=row[DATE_IDX].to_pydatetime(), + open_date=current_time, stake_amount=stake_amount, amount=amount, fee_open=self.fee, @@ -531,6 +531,9 @@ class Backtesting: side="buy", order_type="market", status="closed", + order_date=current_time, + order_filled_date=current_time, + order_update_date=current_time, price=propose_rate, average=propose_rate, amount=amount,