# Path: zaifbot/trade/tools.py
# def last_price(currency_pair, *, timestamp=None):
#     if timestamp is None:
#         return get_latest_price(currency_pair)
# 
#     candle_sticks = CandleSticks(currency_pair, '1m')
#     return candle_sticks.last_price(timestamp)
# 
# Path: zaifbot/rules/exit/base.py
# class Exit(Rule):
#     def __init__(self, name=None):
#         self.name = name or self.__class__.__name__
# 
#     def can_exit(self, trade):
#         raise NotImplementedError
# 
#     @staticmethod
#     def exit(trade):
#         trade.exit()


from zaifbot.trade.tools import last_price
from zaifbot.rules.exit.base import Exit


class SellHigherExit(Exit):
    def __init__(self, exit_price, name=None):
        super().__init__(name=name)
        self._exit_price = exit_price

    def can_exit(self, trade):

# Path: zaifbot/trade/tools.py
# def last_price(currency_pair, *, timestamp=None):
#     if timestamp is None:
#         return get_latest_price(currency_pair)
# 
#     candle_sticks = CandleSticks(currency_pair, '1m')
#     return candle_sticks.last_price(timestamp)
# 
# Path: zaifbot/rules/exit/base.py
# class Exit(Rule):
#     def __init__(self, name=None):
#         self.name = name or self.__class__.__name__
# 
#     def can_exit(self, trade):
#         raise NotImplementedError
# 
#     @staticmethod
#     def exit(trade):
#         trade.exit()


# Path: zaifbot/rules/exit/sell_higher_exit.py
from zaifbot.trade.tools import last_price
from zaifbot.rules.exit.base import Exit



class SellHigherExit(Exit):
    def __init__(self, exit_price, name=None):
        super().__init__(name=name)
        self._exit_price = exit_price

    def can_exit(self, trade):

        return self._exit_price < last_price(trade.currency_pair)