Adding buy/sell events notifications to the strategy

This commit is contained in:
Jean-Baptiste LE STANG 2018-01-30 17:56:31 +01:00
parent c75e5a8020
commit dd30a75ea1
3 changed files with 42 additions and 0 deletions

View File

@ -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

View File

@ -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
"""

View File

@ -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)