mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Properly close out orders in backtesting
This commit is contained in:
parent
c499bb051f
commit
f709222943
|
@ -1094,6 +1094,7 @@ class Backtesting:
|
||||||
# 5. Process exit orders.
|
# 5. Process exit orders.
|
||||||
order = trade.select_order(trade.exit_side, is_open=True)
|
order = trade.select_order(trade.exit_side, is_open=True)
|
||||||
if order and self._get_order_filled(order.price, row):
|
if order and self._get_order_filled(order.price, row):
|
||||||
|
order.close_bt_order(current_time, trade)
|
||||||
trade.open_order_id = None
|
trade.open_order_id = None
|
||||||
trade.close_date = current_time
|
trade.close_date = current_time
|
||||||
trade.close(order.price, show_msg=False)
|
trade.close(order.price, show_msg=False)
|
||||||
|
|
|
@ -166,6 +166,7 @@ class Order(_DECL_BASE):
|
||||||
def close_bt_order(self, close_date: datetime, trade: 'LocalTrade'):
|
def close_bt_order(self, close_date: datetime, trade: 'LocalTrade'):
|
||||||
self.order_filled_date = close_date
|
self.order_filled_date = close_date
|
||||||
self.filled = self.amount
|
self.filled = self.amount
|
||||||
|
self.remaining = 0
|
||||||
self.status = 'closed'
|
self.status = 'closed'
|
||||||
self.ft_is_open = False
|
self.ft_is_open = False
|
||||||
if (self.ft_order_side == trade.entry_side
|
if (self.ft_order_side == trade.entry_side
|
||||||
|
|
Loading…
Reference in New Issue
Block a user