Skip to content

Commit

Permalink
Fix logging init for BacktestNode exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Sep 14, 2024
1 parent eb2265d commit 24dd6f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ None
- Fixed composite bar requests (#1923), thanks @faysou
- Fixed average price calculation for `ValueBarAggregator` (#1927), thanks @faysou
- Fixed breaking protobuf issue by pinning `protobuf` and `grpcio` for dYdX (#1929), thanks @davidsblom
- Fixed edge case where exceptions raised in `BacktestNode` prior to engine init would not produce logs, thanks for reporting @faysou

---

Expand Down
5 changes: 5 additions & 0 deletions nautilus_trader/backtest/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from nautilus_trader.backtest.results import BacktestResult
from nautilus_trader.common.component import Logger
from nautilus_trader.common.component import LogGuard
from nautilus_trader.common.component import init_logging
from nautilus_trader.common.component import is_logging_initialized
from nautilus_trader.common.config import ActorFactory
from nautilus_trader.common.config import InvalidConfiguration
from nautilus_trader.core import nautilus_pyo3
Expand Down Expand Up @@ -159,6 +161,9 @@ def run(self) -> list[BacktestResult]:
)
results.append(result)
except Exception as e:
if not is_logging_initialized:
init_logging()

# Broad catch all prevents a single backtest run from halting
# the execution of the other backtests (such as a zero balance exception).
Logger(type(self).__name__).error(f"Error running backtest: {e}")
Expand Down

0 comments on commit 24dd6f9

Please sign in to comment.