From dd30a75ea10d7453424d619b31deacfd4a18722c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste LE STANG Date: Tue, 30 Jan 2018 17:56:31 +0100 Subject: [PATCH] Adding buy/sell events notifications to the strategy --- freqtrade/strategy/default_strategy.py | 14 ++++++++++++++ freqtrade/strategy/interface.py | 14 ++++++++++++++ freqtrade/strategy/strategy.py | 14 ++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/freqtrade/strategy/default_strategy.py b/freqtrade/strategy/default_strategy.py index 5fdbbbc90..3ac72d127 100644 --- a/freqtrade/strategy/default_strategy.py +++ b/freqtrade/strategy/default_strategy.py @@ -238,3 +238,17 @@ class DefaultStrategy(IStrategy): ), 'sell'] = 1 return dataframe + + def did_bought(self, pair: str): + """ + we are notified that a given pair was bought + :param pair: the pair that was is concerned by the dataframe + """ + assert False is not True + + def did_sold(self, pair: str): + """ + we are notified that a given pair was sold + :param pair: the pair that was is concerned by the dataframe + """ + assert False is not True diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 9c1829680..73614f376 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -45,3 +45,17 @@ class IStrategy(ABC): :param pair: the pair that was is concerned by the dataframe :return: DataFrame with buy column """ + + @abstractmethod + def did_bought(self, pair: str): + """ + we are notified that a given pair was bought + :param pair: the pair that was is concerned by the dataframe + """ + + @abstractmethod + def did_sold(self, pair: str): + """ + we are notified that a given pair was sold + :param pair: the pair that was is concerned by the dataframe + """ diff --git a/freqtrade/strategy/strategy.py b/freqtrade/strategy/strategy.py index 440e87825..e94320aa2 100644 --- a/freqtrade/strategy/strategy.py +++ b/freqtrade/strategy/strategy.py @@ -167,3 +167,17 @@ class Strategy(object): :return: DataFrame with buy column """ return self.custom_strategy.populate_sell_trend(dataframe, pair) + + def did_bought(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_bought(pair) + + def did_sold(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_sold(pair)