Skip to content

Commit 24dd6f9

Browse files
committed
Fix logging init for BacktestNode exceptions
1 parent eb2265d commit 24dd6f9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

RELEASES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ None
1212
- Fixed composite bar requests (#1923), thanks @faysou
1313
- Fixed average price calculation for `ValueBarAggregator` (#1927), thanks @faysou
1414
- Fixed breaking protobuf issue by pinning `protobuf` and `grpcio` for dYdX (#1929), thanks @davidsblom
15+
- Fixed edge case where exceptions raised in `BacktestNode` prior to engine init would not produce logs, thanks for reporting @faysou
1516

1617
---
1718

nautilus_trader/backtest/node.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from nautilus_trader.backtest.results import BacktestResult
2626
from nautilus_trader.common.component import Logger
2727
from nautilus_trader.common.component import LogGuard
28+
from nautilus_trader.common.component import init_logging
29+
from nautilus_trader.common.component import is_logging_initialized
2830
from nautilus_trader.common.config import ActorFactory
2931
from nautilus_trader.common.config import InvalidConfiguration
3032
from nautilus_trader.core import nautilus_pyo3
@@ -159,6 +161,9 @@ def run(self) -> list[BacktestResult]:
159161
)
160162
results.append(result)
161163
except Exception as e:
164+
if not is_logging_initialized:
165+
init_logging()
166+
162167
# Broad catch all prevents a single backtest run from halting
163168
# the execution of the other backtests (such as a zero balance exception).
164169
Logger(type(self).__name__).error(f"Error running backtest: {e}")

0 commit comments

Comments
 (0)