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

@@ -91,7 +91,7 @@ def tickerdata_to_dataframe(data):
def preprocess(tickerdata: Dict[str, List]) -> Dict[str, DataFrame]:
"""Creates a dataframe and populates indicators for given ticker data"""
return {pair: populate_indicators(parse_ticker_dataframe(pair_data))
return {pair: populate_indicators(parse_ticker_dataframe(pair_data), pair)
for pair, pair_data in tickerdata.items()}

View File

@@ -117,7 +117,7 @@ def backtest(args) -> DataFrame:
exchange._API = Bittrex({'key': '', 'secret': ''})
for pair, pair_data in processed.items():
pair_data['buy'], pair_data['sell'] = 0, 0
ticker = populate_sell_trend(populate_buy_trend(pair_data))
ticker = populate_sell_trend(populate_buy_trend(pair_data, pair), pair)
# for each buy point
lock_pair_until = None
headers = ['buy', 'open', 'close', 'date', 'sell']

View File

@@ -61,7 +61,7 @@ TRIALS = Trials()
main._CONF = OPTIMIZE_CONFIG
def populate_indicators(dataframe: DataFrame) -> DataFrame:
def populate_indicators(dataframe: DataFrame, pair: str) -> DataFrame:
"""
Adds several different TA indicators to the given DataFrame
"""
@@ -320,7 +320,7 @@ def buy_strategy_generator(params: Dict[str, Any]) -> Callable:
"""
Define the buy strategy parameters to be used by hyperopt
"""
def populate_buy_trend(dataframe: DataFrame) -> DataFrame:
def populate_buy_trend(dataframe: DataFrame, pair: str) -> DataFrame:
conditions = []
# GUARDS AND TRENDS
if 'uptrend_long_ema' in params and params['uptrend_long_ema']['enabled']: