fix(docs/strategy-advanced/custom_info-storage/example): only add to "custom_info" in backtesting and hyperopt

This commit is contained in:
Joe Schr 2021-03-04 19:59:57 +01:00
parent 900deb663a
commit 1304918a29

View File

@ -55,6 +55,7 @@ class AwesomeStrategy(IStrategy):
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# using "ATR" here as example # using "ATR" here as example
dataframe['atr'] = ta.ATR(dataframe) dataframe['atr'] = ta.ATR(dataframe)
if self.dp.runmode.value in ('backtest', 'hyperopt'):
# add indicator mapped to correct DatetimeIndex to custom_info # add indicator mapped to correct DatetimeIndex to custom_info
self.custom_info[metadata['pair']] = dataframe[['date', 'atr']].copy().set_index('date') self.custom_info[metadata['pair']] = dataframe[['date', 'atr']].copy().set_index('date')
return dataframe return dataframe