freqtrade_origin/freqtrade/enums/exitchecktuple.py

24 lines
640 B
Python
Raw Normal View History

2022-03-25 05:55:37 +00:00
from freqtrade.enums.exittype import ExitType
2022-03-25 05:50:18 +00:00
class ExitCheckTuple:
"""
NamedTuple for Exit type + reason
"""
2022-03-25 05:55:37 +00:00
exit_type: ExitType
2022-03-25 05:50:18 +00:00
exit_reason: str = ''
2022-03-25 05:55:37 +00:00
def __init__(self, exit_type: ExitType, exit_reason: str = ''):
2022-03-25 05:50:18 +00:00
self.exit_type = exit_type
self.exit_reason = exit_reason or exit_type.value
@property
def exit_flag(self):
2022-03-25 05:55:37 +00:00
return self.exit_type != ExitType.NONE
2022-05-22 08:31:29 +00:00
def __eq__(self, other):
return self.exit_type == other.exit_type and self.exit_reason == other.exit_reason
2022-05-22 09:01:18 +00:00
def __repr__(self):
return f"ExitCheckTuple({self.exit_type}, {self.exit_reason})"