These were the major changes contributing to each release:
(2025-03-30)
- Bug fixes:
- Fix optimization hanging on MS Windows under some conditions,
primarily missing a
if __name__ == '__main__'
guard. - Restore original scale in FractionalBacktest plot (#1247)
- Fix "'CAGR [%]' must match a key in pd.Series result of bt.run()" error
- Fix grid optimization on data with timezone-aware datetime index
- Fix optimization hanging on MS Windows under some conditions,
primarily missing a
(2025-03-11)
- Enhancements:
backtesting.lib.TrailingStrategy
supports setting trailing stop-loss by percentage.backtesting.lib.MultiBacktest
multi-dataset backtesting wrapper.Backtest.run()
wrapped intqdm()
- Rename parameter
lib.FractionalBacktest(fractional_unit=)
. - Add market alpha & market beta stats (#1221)
- Plot improvements:
- Plot trade duration lines in the P&L plot section.
- Simplify PL section, use circular markers.
- Only plot trades when some trades are present.
- Set
fig.yaxis.ticker.desired_num_ticks=3
for indicator subplots. - Single legend item for indicators with singular/default names.
- Make "OHLC" itself a togglable legend item.
- Add xwheel_pan tool, conditioned on activation for now (upvote Bokeh issue).
- Reduce height of indicator charts, introduce an overridable private
global
backtesting._plotting._INDICATOR_HEIGHT
.
- Bug fixes:
- Fixed
Position.pl
occasionally not matchingPosition.pl_pct
in sign. - SL always executes before TP when hit in the same bar.
- Fix
functools.partial
objects do not always have a__module__
attr in Python 3.9 (#1233) - Fix stop-market and TP hit within the same bar.
- Fixed
- Documentation improvements (warnings, links, ...)
(2025-02-19)
- Enhancements:
- Grid optimization with mp.Pool & mp.shm.SharedMemory (#1222)
backtesting.lib.FractionalBacktest
that supports fractional tradingbacktesting.__all__
for betterfrom backtesting import *
and suggestions
- Bugs fixed:
- Fix remaining issues with
trade_on_close=True
- Fix trades reported in reverse chronological order when
finalize_trades=True
- Fix crosshair not linked across subplots
- Cast
datetime_arr.astype(np.int64)
to avoid Windos error
- Fix remaining issues with
(2025-02-04)
Enhancement: Use joblib.Parallel
for optimization.
This should vastly improve performance on Windows while not
affecting other platforms too much.
(2025-02-04)
- Enhancements:
- Add
Backtest(spread=)
; changeBacktest(commission=)
to apply twice per trade - Show paid "Commissions [$]" key in trade stats
- Allow multiple names for vector indicators (#980)
- Add columns SL and TP to
stats['trades']
(#1039) - Add entry/exit indicator values to
stats['trades']
(#1116) - Optionally finalize trades at the end of backtest run (#393)
- Add
- Bug fixes, including for some long-standing bugs:
- Fix bug in Sharpe ratio with non-zero risk-free rate (#904)
- Change price comparisons to lte/gte to align with TradingView
- Reduce optimization memory footprint (#884)
- Fix annualized stats with weekly/monthly data
- Fix
AssertionError
onfor o in self.orders: o.cancel()
- Fix plot not shown in VSCode Jupyter
- Buy&Hold duration now matches trading duration
- Fix
bt.plot(resample=True)
with categorical indicators
- Several other small bug fixes, deprecations and docs updates.
(2025-01-21)
- Enhancements:
- New
Backtest.optimize(method="sambo")
; uses SAMBO: to replacemethod="skopt"
. - New 'CAGR [%]' (compound annual growth rate) statistic.
- New
- Bug fixes:
- "stop-loss executed at a higher than market price".
- Bug with buy/sell size=0.
Order.__repr__
issue with non-numericOrder.tag
.
- Other small fixes, deprecations and docs updates.
(2025-01-21)
- Enhancements:
- 'Kelly Criterion' statistic (#640)
Backtest.plot(plot_trades=)
parameter- Order.tag for tracking orders and trades (#200)
- Small bug fixes, deprecation removals and documentation updates.
(2021-12-13)
- Fix random generation with recent NumPy.
- Fix Pandas deprecation warnings.
- Replace Bokeh 3.0 deprecations.
(2021-08-03)
- New strategy performance method
backtesting.lib.compute_stats
(#281) - Improve plotting speed (#329) and optimization performance (#295) on large datasets.
- Commission constraints now allow for market-maker's rebates.
Backtest.plot
now returns the bokeh figure object for further processing.- Other small bugs and fixes.
(2021-01-25)
- Avoid some
pandas.Index
deprecations - Fix
Backtest.plot(show_legend=False)
for recent Bokeh
(2020-11-24)
- Faster model-based optimization using scikit-optimize (#154)
- Optionally faster optimization by randomized grid search (#154)
- Annualized Return/Volatility/Sharpe/Sortino/Calmar stats (#156)
- Auto close open trades on backtest finish
- Add
Backtest.plot(plot_return=)
, akin toplot_equity=
- Update Expectancy formula (#181)
(2020-10-27)
- Add
lib.random_ohlc_data()
OHLC data generator - Aggregate Equity on 'last' when plot resampling
- Update stats calculation for Buy & Hold to be long-only (#152)
(2020-09-10)
- Link hover crosshairs across plots
- Clicking plot legend glyph toggles indicator visibility
- Fix Bokeh tooltip showing literal ' '
(2020-08-21)
(2020-08-03)
- Add
Trade.entry_time/.exit_time
- Handle SL/TP hit on the same day the position was opened
(2020-07-15)
- New Order/Trade/Position API (#47)
- Add data pandas accessors
.df
and.s
- Add
Backtest(..., exclusive_orders=)
that closes previous trades on new orders - Add
Backtest(..., hedging=)
that makes FIFO trade closing optional - Add
bt.plot(reverse_indicators=)
param - Add
bt.plot(resample=)
and auto-downsample large data - Use geometric mean return in Sharpe/Sortino stats computation
(2020-07-14)
- Add Profit Factor statistic (#85)
(2020-03-23)
- Fix support for 2-D indicators
- Fix tooltip Date field formatting with Bokeh 2.0.0
(2020-03-09)
(2020-03-02)
(2020-02-25)
(2020-02-24)
- Show number of trades on OHLC plot legend
- Add parameter agg= to lib.resample_apply()
- Reset position price (etc.) after closing position
- Fix pandas insertion error on Windos
(2019-09-23)
- Make plot span 100% of browser width
(2019-09-23)
- Avoid multiprocessing trouble on Windos (#6)
- Add scatter plot indicators
(2019-01-15)
- Initial release