get_analyzed_dataframe should provide dataframe with startup candles
closes #7389
This commit is contained in:
@@ -369,13 +369,14 @@ class Backtesting:
|
|||||||
# Cleanup from prior runs
|
# Cleanup from prior runs
|
||||||
pair_data.drop(HEADERS[5:] + ['buy', 'sell'], axis=1, errors='ignore')
|
pair_data.drop(HEADERS[5:] + ['buy', 'sell'], axis=1, errors='ignore')
|
||||||
df_analyzed = self.strategy.ft_advise_signals(pair_data, {'pair': pair})
|
df_analyzed = self.strategy.ft_advise_signals(pair_data, {'pair': pair})
|
||||||
# Trim startup period from analyzed dataframe
|
|
||||||
df_analyzed = processed[pair] = pair_data = trim_dataframe(
|
|
||||||
df_analyzed, self.timerange, startup_candles=self.required_startup)
|
|
||||||
# Update dataprovider cache
|
# Update dataprovider cache
|
||||||
self.dataprovider._set_cached_df(
|
self.dataprovider._set_cached_df(
|
||||||
pair, self.timeframe, df_analyzed, self.config['candle_type_def'])
|
pair, self.timeframe, df_analyzed, self.config['candle_type_def'])
|
||||||
|
|
||||||
|
# Trim startup period from analyzed dataframe
|
||||||
|
df_analyzed = processed[pair] = pair_data = trim_dataframe(
|
||||||
|
df_analyzed, self.timerange, startup_candles=self.required_startup)
|
||||||
|
|
||||||
# Create a copy of the dataframe before shifting, that way the entry signal/tag
|
# Create a copy of the dataframe before shifting, that way the entry signal/tag
|
||||||
# remains on the correct candle for callbacks.
|
# remains on the correct candle for callbacks.
|
||||||
df_analyzed = df_analyzed.copy()
|
df_analyzed = df_analyzed.copy()
|
||||||
@@ -1196,7 +1197,8 @@ class Backtesting:
|
|||||||
|
|
||||||
row_index += 1
|
row_index += 1
|
||||||
indexes[pair] = row_index
|
indexes[pair] = row_index
|
||||||
self.dataprovider._set_dataframe_max_index(row_index)
|
self.dataprovider._set_dataframe_max_index(self.required_startup + row_index)
|
||||||
|
self.dataprovider._set_dataframe_max_date(current_time)
|
||||||
current_detail_time: datetime = row[DATE_IDX].to_pydatetime()
|
current_detail_time: datetime = row[DATE_IDX].to_pydatetime()
|
||||||
trade_dir: Optional[LongShort] = self.check_for_trade_entry(row)
|
trade_dir: Optional[LongShort] = self.check_for_trade_entry(row)
|
||||||
|
|
||||||
|
|||||||
@@ -1359,11 +1359,11 @@ def test_backtest_multi_pair(default_conf, fee, mocker, tres, pair, testdatadir)
|
|||||||
|
|
||||||
# Cached data correctly removed amounts
|
# Cached data correctly removed amounts
|
||||||
offset = 1 if tres == 0 else 0
|
offset = 1 if tres == 0 else 0
|
||||||
removed_candles = len(data[pair]) - offset - backtesting.strategy.startup_candle_count
|
removed_candles = len(data[pair]) - offset
|
||||||
assert len(backtesting.dataprovider.get_analyzed_dataframe(pair, '5m')[0]) == removed_candles
|
assert len(backtesting.dataprovider.get_analyzed_dataframe(pair, '5m')[0]) == removed_candles
|
||||||
assert len(
|
assert len(
|
||||||
backtesting.dataprovider.get_analyzed_dataframe('NXT/BTC', '5m')[0]
|
backtesting.dataprovider.get_analyzed_dataframe('NXT/BTC', '5m')[0]
|
||||||
) == len(data['NXT/BTC']) - 1 - backtesting.strategy.startup_candle_count
|
) == len(data['NXT/BTC']) - 1
|
||||||
|
|
||||||
backtesting.strategy.max_open_trades = 1
|
backtesting.strategy.max_open_trades = 1
|
||||||
backtesting.config.update({'max_open_trades': 1})
|
backtesting.config.update({'max_open_trades': 1})
|
||||||
|
|||||||
Reference in New Issue
Block a user