BacktestNode won't clear data in streaming mode, add the line 'engine.clear_data()' to fix.
def _run_streaming(
self,
run_config_id: str,
engine: BacktestEngine,
data_configs: list[BacktestDataConfig],
batch_size_bytes: int,
) -> None:
# Create session for entire stream
session = DataBackendSession(chunk_size=batch_size_bytes)
# Add query for all data configs
for config in data_configs:
catalog = self.load_catalog(config)
if config.data_type == Bar:
# TODO: Temporary hack - improve bars config and decide implementation with `filter_expr`
assert config.instrument_id, "No `instrument_id` for Bar data config"
assert config.bar_spec, "No `bar_spec` for Bar data config"
bar_type = config.instrument_id + "-" + config.bar_spec + "-EXTERNAL"
else:
bar_type = None
session = catalog.backend_session(
data_cls=config.data_type,
instrument_ids=(
[config.instrument_id] if config.instrument_id and not bar_type else []
),
bar_types=[bar_type] if bar_type else [],
start=config.start_time,
end=config.end_time,
session=session,
)
# Stream data
for chunk in session.to_query_result():
engine.add_data(
data=capsule_to_list(chunk),
validate=False, # Cannot validate mixed type stream
sort=True, # Temporarily sorting # Already sorted from kmerge
)
engine.run(
run_config_id=run_config_id,
streaming=True,
)
# FIXME: SHOULD CLEAR data consumed
engine.clear_data()
engine.end()
engine.dispose()
Expected Behavior
backTestNode should clear data in every backtest round
Actual Behavior
miss call to clear_data()
Steps to Reproduce the Problem
Run any backtest through BacktestNode in streaming mode
Bug Report
BacktestNode won't clear data in streaming mode, add the line 'engine.clear_data()' to fix.
Expected Behavior
backTestNode should clear data in every backtest round
Actual Behavior
miss call to clear_data()
Steps to Reproduce the Problem
Run any backtest through BacktestNode in streaming mode
Specifications
nautilus_trader
version: 1.190.0