Adding the pair name when populating indicators allowing the strategy to have customized context for a pair

This commit is contained in:
Jean-Baptiste LE STANG
2018-01-30 15:03:38 +01:00
parent 5f86c389b0
commit 26e288e655
14 changed files with 46 additions and 46 deletions

View File

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

View File

@@ -19,7 +19,7 @@ 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()
@@ -27,7 +27,7 @@ class IStrategy(ABC):
"""
@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
@@ -36,7 +36,7 @@ class IStrategy(ABC):
"""
@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

View File

@@ -143,27 +143,27 @@ 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)