Currently Jupyter Notebook, as run in Visual Studio Code, uses its verbose traceback output, outputting code samples where the exception propagated. This is the opposite of Python native traceback that only gives you the file and line number.
Example snippet:
UnboundLocalError Traceback (most recent call last)
Cell In[18], line 3
1 from tradeexecutor.backtest.backtest_runner import run_backtest_inline
----> 3 result = run_backtest_inline(
4 name=parameters.id,
5 engine_version="0.5",
6 decide_trades=decide_trades,
7 create_indicators=create_indicators,
8 client=client,
9 universe=strategy_universe,
10 parameters=parameters,
11 strategy_logging=False,
12 max_workers=1
13 )
15 state = result.state
17 trade_count = len(list(state.portfolio.get_all_trades()))
File ~/code/executor/trade-executor/tradeexecutor/backtest/backtest_runner.py:1009, in run_backtest_inline(start_at, end_at, minimum_data_lookback_range, client, decide_trades, create_trading_universe, create_indicators, indicator_combinations, indicator_storage, cycle_duration, initial_deposit, reserve_currency, trade_routing, universe, routing_model, max_slippage, candle_time_frame, log_level, data_preload, data_delay_tolerance, name, allow_missing_fees, engine_version, strategy_logging, parameters, mode, max_workers, grid_search, execution_context, execution_test_hook, *ignore)
978 execution_context.mode = mode
980 backtest_setup = BacktestSetup(
981 start_at,
982 end_at,
(...)
1006 grid_search=grid_search,
1007 )
-> 1009 result = run_backtest(
1010 backtest_setup,
1011 client,
1012 allow_missing_fees=True,
1013 execution_context=execution_context,
1014 execution_test_hook=execution_test_hook,
1015 )
1017 result.diagnostics_data["wallet"] = wallet
1019 #: TODO: Hack to pass the backtest data range to the grid search
...
-> More than 1000 lines follows
The problem is that this format is extremely long, and for complex code with long stack, it makes it painful to read due to amount of scrolling required.
- Is it possible to force Jupyter Notebook to use normal, shorter, Python traceback output?
- Are there other ways to make traceback output more manageable in Jupyter Notebook (or Visual Studio Code?)