Merge 970a4c3bf7 into 192521523f
This commit is contained in:
@@ -29,7 +29,7 @@ class DefaultStrategy(IStrategy):
|
||||
# Optimal ticker interval for the strategy
|
||||
ticker_interval = 5
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_indicators(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
@@ -196,7 +196,7 @@ class DefaultStrategy(IStrategy):
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_buy_trend(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame
|
||||
@@ -217,7 +217,7 @@ class DefaultStrategy(IStrategy):
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_sell_trend(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame
|
||||
@@ -238,3 +238,27 @@ 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
|
||||
"""
|
||||
|
||||
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
|
||||
"""
|
||||
|
||||
def did_cancel_buy(self, pair: str):
|
||||
"""
|
||||
we are notified that a given pair buy was not filled
|
||||
: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 not sold
|
||||
:param pair: the pair that was is concerned by the dataframe
|
||||
"""
|
||||
|
||||
@@ -19,26 +19,57 @@ class IStrategy(ABC):
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_indicators(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Populate indicators that will be used in the Buy and Sell strategy
|
||||
:param dataframe: Raw data from the exchange and parsed by parse_ticker_dataframe()
|
||||
:param pair: the pair that was is concerned by the dataframe
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_buy_trend(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame
|
||||
:param pair: the pair that was is concerned by the dataframe
|
||||
:return: DataFrame with buy column
|
||||
:return:
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def populate_sell_trend(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_sell_trend(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame
|
||||
: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
|
||||
"""
|
||||
|
||||
@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
|
||||
"""
|
||||
|
||||
@@ -151,27 +151,55 @@ class Strategy(object):
|
||||
|
||||
return path
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_indicators(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Populate indicators that will be used in the Buy and Sell strategy
|
||||
:param dataframe: Raw data from the exchange and parsed by parse_ticker_dataframe()
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
return self.custom_strategy.populate_indicators(dataframe)
|
||||
return self.custom_strategy.populate_indicators(dataframe, pair)
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_buy_trend(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame
|
||||
:return: DataFrame with buy column
|
||||
:return:
|
||||
"""
|
||||
return self.custom_strategy.populate_buy_trend(dataframe)
|
||||
return self.custom_strategy.populate_buy_trend(dataframe, pair)
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame) -> DataFrame:
|
||||
def populate_sell_trend(self, dataframe: DataFrame, pair: str) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
return self.custom_strategy.populate_sell_trend(dataframe)
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user