Allow closing trades without message
This commit is contained in:
parent
b606936eb7
commit
9f34aebdaa
@ -243,7 +243,7 @@ class Backtesting:
|
|||||||
|
|
||||||
trade.close_date = sell_row[DATE_IDX]
|
trade.close_date = sell_row[DATE_IDX]
|
||||||
trade.sell_reason = sell.sell_type
|
trade.sell_reason = sell.sell_type
|
||||||
trade.close(closerate)
|
trade.close(closerate, show_msg=False)
|
||||||
|
|
||||||
return BacktestResult(pair=trade.pair,
|
return BacktestResult(pair=trade.pair,
|
||||||
profit_percent=trade.calc_profit_ratio(rate=closerate),
|
profit_percent=trade.calc_profit_ratio(rate=closerate),
|
||||||
|
@ -411,7 +411,7 @@ class Trade(_DECL_BASE):
|
|||||||
raise ValueError(f'Unknown order type: {order_type}')
|
raise ValueError(f'Unknown order type: {order_type}')
|
||||||
cleanup_db()
|
cleanup_db()
|
||||||
|
|
||||||
def close(self, rate: float) -> None:
|
def close(self, rate: float, *, show_msg: bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
Sets close_rate to the given rate, calculates total profit
|
Sets close_rate to the given rate, calculates total profit
|
||||||
and marks trade as closed
|
and marks trade as closed
|
||||||
@ -423,6 +423,7 @@ class Trade(_DECL_BASE):
|
|||||||
self.is_open = False
|
self.is_open = False
|
||||||
self.sell_order_status = 'closed'
|
self.sell_order_status = 'closed'
|
||||||
self.open_order_id = None
|
self.open_order_id = None
|
||||||
|
if show_msg:
|
||||||
logger.info(
|
logger.info(
|
||||||
'Marking %s as closed as the trade is fulfilled and found no open orders for it.',
|
'Marking %s as closed as the trade is fulfilled and found no open orders for it.',
|
||||||
self
|
self
|
||||||
|
Loading…
Reference in New Issue
Block a user