Adding cancel buy/sell events

This commit is contained in:
Jean-Baptiste LE STANG 2018-01-30 21:34:26 +01:00
parent eacb6b5a03
commit b27c8256f4
4 changed files with 44 additions and 2 deletions

View File

@ -158,6 +158,8 @@ def handle_timedout_limit_buy(trade: Trade, order: Dict) -> bool:
logger.info('Buy order timeout for %s.', trade) logger.info('Buy order timeout for %s.', trade)
rpc.send_msg('*Timeout:* Unfilled buy order for {} cancelled'.format( rpc.send_msg('*Timeout:* Unfilled buy order for {} cancelled'.format(
trade.pair.replace('_', '/'))) trade.pair.replace('_', '/')))
strategy = Strategy()
strategy.did_cancel_buy(trade.pair)
return True return True
# if trade is partially complete, edit the stake details for the trade # if trade is partially complete, edit the stake details for the trade
@ -188,6 +190,8 @@ def handle_timedout_limit_sell(trade: Trade, order: Dict) -> bool:
rpc.send_msg('*Timeout:* Unfilled sell order for {} cancelled'.format( rpc.send_msg('*Timeout:* Unfilled sell order for {} cancelled'.format(
trade.pair.replace('_', '/'))) trade.pair.replace('_', '/')))
logger.info('Sell order timeout for %s.', trade) logger.info('Sell order timeout for %s.', trade)
strategy = Strategy()
strategy.did_cancel_sell(trade.pair)
return True return True
# TODO: figure out how to handle partially complete sell orders # TODO: figure out how to handle partially complete sell orders

View File

@ -244,11 +244,21 @@ class DefaultStrategy(IStrategy):
we are notified that a given pair was bought we are notified that a given pair was bought
:param pair: the pair that was is concerned by the dataframe :param pair: the pair that was is concerned by the dataframe
""" """
assert False is not True
def did_sold(self, pair: str): def did_sold(self, pair: str):
""" """
we are notified that a given pair was sold we are notified that a given pair was sold
:param pair: the pair that was is concerned by the dataframe :param pair: the pair that was is concerned by the dataframe
""" """
assert False is not True
def did_cancel_buy(self, pair: str):
"""
we are notified that a given pair was bought
:param pair: the pair that was is concerned by the dataframe
"""
def did_cancel_sell(self, pair: str):
"""
we are notified that a given pair was sold
:param pair: the pair that was is concerned by the dataframe
"""

View File

@ -59,3 +59,17 @@ class IStrategy(ABC):
we are notified that a given pair was sold we are notified that a given pair was sold
:param pair: the pair that was is concerned by the dataframe :param pair: the pair that was is concerned by the dataframe
""" """
@abstractmethod
def did_cancel_buy(self, pair: str):
"""
we are notified that a given buy for a pair was cancelled
:param pair: the pair that was is concerned by the dataframe
"""
@abstractmethod
def did_cancel_sell(self, pair: str):
"""
we are notified that a given sell for a pair was cancelled
:param pair: the pair that was is concerned by the dataframe
"""

View File

@ -181,3 +181,17 @@ class Strategy(object):
:param pair: the pair that was is concerned by the dataframe :param pair: the pair that was is concerned by the dataframe
""" """
return self.custom_strategy.did_sold(pair) return self.custom_strategy.did_sold(pair)
def did_cancel_buy(self, pair: str):
"""
we are notified that a given pair was bought
:param pair: the pair that was is concerned by the dataframe
"""
return self.custom_strategy.did_cancel_buy(pair)
def did_cancel_sell(self, pair: str):
"""
we are notified that a given pair was sold
:param pair: the pair that was is concerned by the dataframe
"""
return self.custom_strategy.did_cancel_sell(pair)