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,8 +55,9 @@ 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)
# add indicator mapped to correct DatetimeIndex to custom_info if self.dp.runmode.value in ('backtest', 'hyperopt'):
self.custom_info[metadata['pair']] = dataframe[['date', 'atr']].copy().set_index('date') # add indicator mapped to correct DatetimeIndex to custom_info
self.custom_info[metadata['pair']] = dataframe[['date', 'atr']].copy().set_index('date')
return dataframe return dataframe
``` ```