BT: Update trade open_rate on first filled order.

This commit is contained in:
eSeR1805 2022-05-05 12:19:05 +03:00
parent 25c74e26d1
commit 2bed0eab0c
No known key found for this signature in database
GPG Key ID: BA53686259B46936
1 changed files with 5 additions and 0 deletions

View File

@ -813,6 +813,11 @@ class Backtesting:
cost=stake_amount + trade.fee_open,
)
if pos_adjust and self._get_order_filled(order.price, row):
# Update trade open_rate on first filled order
# this is for cases where adjust_entry_order might have replaced the
# initial order from trade opening
if len(trade.select_filled_orders(trade.entry_side)) == 1:
trade.open_rate = order.price
order.close_bt_order(current_time)
else:
trade.open_order_id = str(self.order_id_counter)